? ? Pending

User tests: Successful: Unsuccessful:

avatar johansundell
johansundell
6 Oct 2017

Pull Request for Issue # .

Summary of Changes

As far as I know it is not possible to import class constants, but when looking for an update to an extension Joomla was trying to do that.

I copied the const to the outside of the Updater class

Testing Instructions

Install this extension http://pixpro.net/pixext/downloads/module/mod_helloworld/0.0.1/e8e9e3c9f3a9dd3f1d2792d83269ad64.zip and see if it has any updates.

Link to update xml http://pixpro.net/pixext/updates/module/mod_helloworld/e8e9e3c9f3a9dd3f1d2792d83269ad64.xml

Expected result

It should have an update with version no 0.0.2

Actual result

It has an update with version no 0.0.6

Documentation Changes Required

avatar joomla-cms-bot joomla-cms-bot - change - 6 Oct 2017
Category Libraries
avatar johansundell johansundell - open - 6 Oct 2017
avatar johansundell johansundell - change - 6 Oct 2017
Status New Pending
avatar mbabker
mbabker - comment - 6 Oct 2017

Yes, it is possible to use class constants. Otherwise Joomla\CMS\Version::MAJOR_VERSION would fail, and that doesn't.

As is, this PR is invalid because there isn't actually a bug with the import of constants, plus you are defining these constants at the namespace level and not in the class. What is the specific bug (with error message(s) if available) you are seeing?

avatar johansundell
johansundell - comment - 6 Oct 2017

not when you are trying to get the value with constant() function

The error is that even if my joomla installation is on "stable" it finds updates that are in "dev" mode

avatar mbabker
mbabker - comment - 6 Oct 2017

To get a class constant you have to pass the fully qualified class name to the constant() function.

// Works
$major = constant('Joomla\\CMS\\Version::MAJOR_VERSION');

// Does not work, will give an undefined constant message
$major = constant('MAJOR_VERSION');
avatar johansundell
johansundell - comment - 6 Oct 2017

It does not on my PHP version 5.6

protected function stabilityTagToInteger($tag)
	{
		$constant = '\\Joomla\\CMS\\Update\\Updater::STABILITY_' . strtoupper($tag);

		if (defined($constant))
		{
			return constant($constant);
		}

		return Updater::STABILITY_STABLE;
	}
avatar johansundell johansundell - change - 6 Oct 2017
Labels Added: ?
avatar ggppdk ggppdk - test_item - 6 Oct 2017 - Tested successfully
avatar ggppdk
ggppdk - comment - 6 Oct 2017

I have tested this item successfully on 24ec81b

Thanks at @johansundell, @csthomas too for this fix,
we had to remove multiple update tags (each of different stability level) because of the bug
i was going to look into this, but did not get time for it


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18255.

avatar csthomas csthomas - test_item - 6 Oct 2017 - Tested successfully
avatar csthomas
csthomas - comment - 6 Oct 2017

I have tested this item successfully on 24ec81b


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18255.

avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Oct 2017
Status Pending Ready to Commit
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 Oct 2017

RTC after two successful tests.

avatar mbabker mbabker - change - 6 Oct 2017
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-10-06 22:05:01
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 6 Oct 2017
avatar mbabker mbabker - merge - 6 Oct 2017

Add a Comment

Login with GitHub to post a comment