Page 1 of 3

[BUG] Version 3.1.0 PHP error (corrupted database few days after update)

Posted: Sun Jul 12, 2020 5:09 pm
by jbwonderadmin
I recently updated manually from version 2.7.0 to 3.1.0. It worked for a few days. However, I am now getting an error when loading

Code: Select all

Fatal error: Uncaught TypeError: Return value of Wcms::getDb() must be an instance of stdClass, null returned in [web directory]/index.php:543 Stack trace: #0 [web directory]/index.php(92): Wcms->getDb() #1 [web directory]/index.php(14): Wcms->__construct() #2 {main} thrown in [web directory]/index.php on line 543
Hosting running Apache, PHP 7.2 (ea-php72). I use the Clean theme.

I have found other examples of public-facing sites with the same or similar errors, so I don't think it's just my config.
http://www.kreitmann.fr/
https://www.techarea.ch/

Re: Version 3.1.0 PHP error

Posted: Mon Jul 13, 2020 4:30 pm
by wiz
Hi jbwonderadmin, hope you have a warm welcome to the community.

In regards to the report, this is the third reported occurence after 3.1.0 rolled out.

It seems all updates go through normally and the website works, then after logging in after a few days the database gets corrupted.
We're looking into this.

Is there any plugins you have been using. If so, which ones?

Thank you for the report, it helps debug these issues faster.

Re: Version 3.1.0 PHP error

Posted: Mon Jul 13, 2020 7:27 pm
by StephanStanisic
Hmm, this is the same issue I've encountered. Could you take a look at data/database.js? With me it was empty.

Re: Version 3.1.0 PHP error

Posted: Wed Jul 15, 2020 3:28 am
by jbwonderadmin
Interesting. I updated to 3.1.0 and last touched the site on June 22. database.js is indeed empty, last modified July 4. Thankfully I have the 2.7.0 database.js backed up so the content is safe.

I don't think I am using any plugins.

Apologies if this was duplicative. I didn't see a topic on this issue in this forum.

Re: Version 3.1.0 PHP error

Posted: Wed Jul 15, 2020 5:21 am
by wiz
jbwonderadmin, thanks for getting back to us.

Any report and feedback is appreciated and there hasn't been any topic on the matter, you're awesome!
Was your database.js file empty or was there anything inside of it when it was corrupted?

To check if you're using plugins, log into your website, open the settings and click on the plugins tab. If there are any plugins installed you will be able to see then.

Another way to check is to simply open your "plugins" folder on your server and see if it's empty.

Re: Version 3.1.0 PHP error

Posted: Thu Jul 16, 2020 6:59 pm
by jbwonderadmin
The database.js file still exists but is now 0 bytes. I don't know if there was some intermediate point where it had been corrupted but not yet wiped. There was data for a whole functioning site, maybe 10 pages or so, in the database.js file and the site had been displaying/behaving correctly when initially set up and for at least a few days after.

The plugins directory is empty and I never installed any that I can recall.

Re: Version 3.1.0 PHP error

Posted: Sun Jul 19, 2020 2:55 pm
by wiz
Hopefully the latest pull request (still pending) will prevent this issue from happening in the future.

Is there any way you guys can reproduce this so we can re-test it?
I tried overbloating the databse and resetting the cache (deleting the cache.js) and hoped that the database would be corrupted, but couldn't get to this situation.

Re: Version 3.1.0 PHP error

Posted: Fri Jul 24, 2020 9:14 am
by StephanStanisic
It seems to happen after a long period of inactivity, so maybe something with the last fetch date?

Both with me and jbwonderadmin it happened after we hadn't logged in for a while, for me that would have been almost two months.

Re: Version 3.1.0 PHP error

Posted: Fri Jul 24, 2020 12:38 pm
by wiz
Let's keep this thread open if anything similar happens, hopefully the latest patch fixes this and we can avoid any database corruption in the future.
The exact same thing happened to me and haven't been able to reproduce it ever since.

Thanks for digging into this Steph, all the info helps.

Re: Version 3.1.0 PHP error

Posted: Sat Aug 01, 2020 8:05 pm
by VoidConflict
I had this error happen today on version 3.1.1 with a server running PHP 7.3. When it happened my web page quit responding so I thought my server went down but my host showed me error logs that brought me to this forum. Since I thought it was a server issue I don't really remember what I was doing when it happened. Whether it occurred after a login/logout or posting new info I don't know (I was doing both multiple times before it happened). Looking at the database with the issue only part of the end was cut off. I have 3 plugins installed: additional-contents, contact-form, hits-counter.