?
avatar mahagr
mahagr
14 Dec 2016

Steps to reproduce the issue

Install Joomla 3.4 and update it from admin.

Expected result

Update should succeed.

Actual result

Fatal error: Undefined class constant 'PRODUCT' in libraries/joomla/updater/update.php on line 300

Additional comments

Replacing above line with something like this should fix the issue:

if (defined('JVersion::PRODUCT')) {
    $product = JVersion::PRODUCT;
    $release = JVersion::RELEASE;
    $dev_level = JVersion::DEV_LEVEL;
} else {
    // Compatible with older Joomla versions.
    $ver = new JVersion;
    $product = $ver->PRODUCT;
    $release = $ver->RELEASE;
    $dev_level = $ver->DEV_LEVEL;
}

... and then use the new variables...

avatar mahagr mahagr - open - 14 Dec 2016
avatar joomla-cms-bot joomla-cms-bot - change - 14 Dec 2016
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 14 Dec 2016
avatar mahagr mahagr - change - 14 Dec 2016
The description was changed
avatar mahagr mahagr - edited - 14 Dec 2016
avatar mahagr mahagr - change - 14 Dec 2016
The description was changed
avatar mahagr mahagr - edited - 14 Dec 2016
avatar mahagr mahagr - edited - 14 Dec 2016
avatar mahagr mahagr - change - 14 Dec 2016
The description was changed
avatar mahagr mahagr - edited - 14 Dec 2016
avatar mahagr mahagr - change - 14 Dec 2016
The description was changed
avatar mahagr mahagr - edited - 14 Dec 2016
avatar mahagr
mahagr - comment - 14 Dec 2016

Workaround:

Before updating Joomla, edit libraries/cms/version/version.php and add these into the class:

	/** @var  string  Product name. */
	const PRODUCT = 'Joomla!';

	/** @var  string  Release version. */
	const RELEASE = '3.4';

	/** @var  string  Maintenance version. */
	const DEV_LEVEL = '8';

Just remember to update the version information and save the file. After that upgrade works from admin...

avatar tonypartridge
tonypartridge - comment - 21 Dec 2016

Do you want to send a pull request so we can review?

avatar zero-24
zero-24 - comment - 21 Dec 2016

how can you reproduce that?

If you are on 3.4.x at this place the old code from 3.4 is executed => no problem.
If you updated to 3.6.x the new code is used and worked (as the constants exists)

avatar zero-24
zero-24 - comment - 21 Dec 2016

Btw the code change (4c4d626) is and work there since 3.5.0 so the same problem needs to popup also on 3.4.8 -> 3.5.0 but it don't do?

avatar zero-24
zero-24 - comment - 21 Dec 2016

I have just double checked that and can't reproduce it by updating from 3.4.8 -> 3.6.5 => No issues.

Can you please double check your introducions to reproduce the issue?

avatar mahagr
mahagr - comment - 22 Dec 2016

I had to step into another task, but I've not forgotten this one. What seems to happen to me is that the old version of JVersion gets used with the new version of the updater script.

I'm using phpbrew with default php.ini (except for small tweak in download size) with opcache.revalidate_freq=2, which may cause the issue.

I think the issue may be related to above setting, I do now remember that there was issue with revalidate_freq which caused a long discussion on how to fix it.

The issue happens to me every time on a clean Joomla install. I may have an idea how to fix it, though -- I will get back to you shortly on this.

avatar zero-24
zero-24 - comment - 22 Dec 2016

If the 3rd Party Code is not broken this script should clear that kind of cache (if your setting not ignore this) https://github.com/joomla/joomla-cms/blob/staging/administrator/components/com_joomlaupdate/restore_finalisation.php

The only szenario i know that 3rd Party script don't trigger that file is when you come from 2.5 as a very old version gets expected.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 Feb 2017

@mahagr is there a PR coming?

avatar mahagr
mahagr - comment - 7 Feb 2017

I was again reallocated to another project and because of it I never had time to look into this one.

I did confirm, though, that the issue comes from opcache.revalidate_freq > 1, which means that some of the classes (like JVersion) were cached from the previous request and is affecting the update script.

There are a few ways that this could be worked around. One way would be to detect if JVersion comes from the old version, attempt to clear opcache and redirect to a page, which asks you to complete the installation with some explanation of what is going on.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Feb 2017

@mbabker have done PRs about Cache, one is #13357

avatar mahagr
mahagr - comment - 7 Feb 2017

This issue has nothing to do with cache, but PHP using an old version of the class.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Feb 2017

to high for me, read opcache and thought "Cache"...

avatar mbabker
mbabker - comment - 7 Feb 2017

There is no way to detect if the JVersion class comes from an old request or whatever without explicitly flushing all the caches and reloading the file first. Which kinda defeats the point of having a cache at that point.

As long as you're updating with the update component, its finalization step (the last thing it does before moving from restore.php back to the Joomla environment) tries to clear byte code cache.

avatar mahagr
mahagr - comment - 7 Feb 2017

Can someone try updating some older version (3.3 or below) with opcache.revalidate_freq=600?

avatar nibra nibra - change - 16 Mar 2017
Category Documentation
avatar nibra nibra - change - 16 Mar 2017
Status New Confirmed
avatar nibra
nibra - comment - 16 Mar 2017

This seems to be nothing, we can fix from Joomla's side. The problem needs to be documented together with a description on how to solve it through correct server settings.


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

avatar zero-24
zero-24 - comment - 16 Mar 2017

Thanks for the update @nibra please dokument that behavior and link it back here. ?

avatar zero-24 zero-24 - close - 16 Mar 2017
avatar zero-24 zero-24 - change - 16 Mar 2017
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2017-03-16 19:00:12
Closed_By zero-24
avatar nibra nibra - change - 16 Mar 2017
Status Closed Confirmed
Closed_Date 2017-03-16 19:00:12
Closed_By zero-24
avatar joomla-cms-bot joomla-cms-bot - reopen - 16 Mar 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 16 Mar 2017

Set to "open" on behalf of @nibra by The JTracker Application at issues.joomla.org/joomla-cms/13201

avatar nibra
nibra - comment - 16 Mar 2017

Should not be closed before the documentation is created / updated. Otherwise, it will go lost.


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

avatar zero-24 zero-24 - change - 16 Mar 2017
Labels Added: ?
avatar zero-24 zero-24 - labeled - 16 Mar 2017
avatar zero-24
zero-24 - comment - 16 Mar 2017

There for we have the doc label (that i have just added)? But you are the leader so you can decide. Thanks.

avatar nibra nibra - change - 16 Mar 2017
Status Confirmed Closed
Closed_Date 0000-00-00 00:00:00 2017-03-16 23:20:18
Closed_By nibra
avatar joomla-cms-bot joomla-cms-bot - close - 16 Mar 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 16 Mar 2017

Set to "closed" on behalf of @nibra by The JTracker Application at issues.joomla.org/joomla-cms/13201

avatar nibra
nibra - comment - 16 Mar 2017
avatar zero-24 zero-24 - change - 16 Mar 2017
Labels Removed: ?
avatar zero-24 zero-24 - unlabeled - 16 Mar 2017
avatar mahagr
mahagr - comment - 17 Mar 2017

True, I didn't find a proper solution for this even after a few tries. It is nice to see it documented, though!

avatar mahagr
mahagr - comment - 17 Mar 2017

@nibra Can you fix the documentation, though.. The value needs to be 0 (turned off) instead of 1 second.

avatar nibra
nibra - comment - 17 Mar 2017

Fixed documentation.

Add a Comment

Login with GitHub to post a comment