Unexpected error when checking for update

Permalink
Dear forum,

Whenever I try to check for an update (and when I access the welcome page in dashboard) an unexpected error is returned.

/index.php/dashboard/system/update/update/check_for_updates

shows

"Call to a member function clear() on null"

I have been updating this site since 8.3.2. I am currently on 8.4.2. The website has been showing this error since version 8.4.0. I have another website on the same server that is also running 8.4.2 but doesn't show the error. Any help on getting rid of this error greatly appreciated. I'm not an expert on PHP or SQL (and have no ambition to become one), but I'd love to hear what could be done about this without reinstalling concrete5 and regenerating SQL tables.

Cheers,

Gino

 
Justin1978 replied on at Permalink Reply
Justin1978
It sounds like a script is trying to clear the cache on a null value instead of the cache repository. Do you have any custom script or add-ons installed? Can you show the stack trace? That's a bunch of error info that comes after this error. You have to enable show detailed error info in your dashboard under debug settings to get the error details.
dtecta replied on at Permalink Reply
Thank you for the quick response. The only plugin I'm using is reCAPTHA. The failing line is

$dbConfig->clear('concrete.marketplace.token');

in Marketplace.php. Wat is $dbConfig and where does it get a proper value?
Justin1978 replied on at Permalink Reply
Justin1978
$dbConfig is supposed to be an instance of \Concrete\Core\Config\Repository\Repository.

What happened here is that you actually discovered a bug in Concrete5 ;)

I checked 8.4.2 against 8.3.0 and the file has changed.

If you want to fix it temporarily this is what you could do:
Open this file:
/updates/concrete5-8.4.2/concrete/src/Marketplace/Marketplace.php


You will see this code on line 71:
$csToken = $this->databaseConfig->get('concrete.marketplace.token');


Now add the following line above or below that line so that it looks like this:
$dbConfig = Core::make('config/database');
$csToken = $this->databaseConfig->get('concrete.marketplace.token');


I haven't tested it because I don't have this version installed but that should fix your problem for the moment. If it doesn't work simply remove the line and let me know and I'll go ahead and install it and figure out what else is broken.

This bug has to be fixed by Concrete5 or you will have te same problem after your next update. I'm not sure if the bug has been reported yet. Do you want to report it or do want me to report it?
Justin1978 replied on at Permalink Reply
Justin1978
Sorry, that might work but this is better:

edit lines 90 and 91:
if ($this->connectionError == self::E_DELETED_SITE_TOKEN) {
       $dbConfig->clear('concrete.marketplace.token');
       $dbConfig->clear('concrete.marketplace.url_token');
}


So that they look like this:

if ($this->connectionError == self::E_DELETED_SITE_TOKEN) {
       $this->databaseConfig->clear('concrete.marketplace.token');
       $this->databaseConfig->clear('concrete.marketplace.url_token');
}
dtecta replied on at Permalink Reply
Are you sure about this being a bug? I have another site that doesn't show the problem. That one was updated from 8.3.2 straight to 8.4.2. The one that has the problem has been updated with 8.3.2, 8.4.0, 8.4.1, and 8.4.2. I should also mention that I update by unzipping straight into the update directory and then calling "Apply Update" from within the dashboard. Somehow, downloading and installing within the dashboard never worked for me. If you think this is a bug then please, go ahead and report it. Thanks for your help so far.
Justin1978 replied on at Permalink Reply
Justin1978
That's strange. Looking at the file I can see that variable is never declared and thus undefined. My IDE (PhpStorm) also confirms that. It looks like they refactored that Marketplace class and forgot to refactor that part. The config repository is now a property of the Marketplace class while it used to be declared locally. They forgot to refactor the usages of that local instance.
Justin1978 replied on at Permalink Reply
Justin1978
Ok, I just installed 8.4.2 in order to reproduce the bug. The reason your other sites don't break is probably because they have different configuration settings. The method has early return statements in case some settings are enabled or disabled so they never hit the bug.

It looks like you have a connection error referring to a deleted site token, that's what causes the script to do a clear on null. It looks like the update checks have to be done with a token; in order to authenticate you but for some reason that fails.

So one bug (connection error) triggers other bug (clear on null). So there are two bugs but the first one is more relevant for you. The Concrete5 guys could probably tell you more about that because this involves a script that connects with their server.

If you contact them refer to this discussion and the following error: E_DELETED_SITE_TOKEN.
dtecta replied on at Permalink Reply
Hi Justin,

Thanks a lot for getting to the bottom of this. How do I restore the token? I'm wondering how I managed to delete it. I recall that at some point I deleted the full update directory. I assumed that installing meant that the extracted directory in update could be removed. This turned out wrong and I reextracted the latest concrete update in the update directory. Perhaps something got lost. Thanks again!

Kind regards,

Gino
Justin1978 replied on at Permalink Reply
Justin1978
Well, I think normally the token gets deleted from the database and your site will fetch or generate a new token and store it. But that's the part that's broken. I had a look at their develop branche on GitHub and it looks like they already fixed the bug, meaning it will be available with the next release. So you could wait for the next update or otherwise apply the fix I described above.