We use MediaWiki – better known as the Wikipedia engine – as our internal knowledge base. Recently, I encountered a bug. It took us a while to track down and fix, so in the interest of saving other people time, I'd like to share it.
The Bug
I uploaded a file to the wiki, and while the upload was a success, a PHP error appeared at the top of the page:
Notice: unserialize(): Error at offset 51 of 56 bytes in /var/<path-to-docroot>/includes/LocalisationCache.php on line 1007
Notice: unserialize(): Error at offset 21 of 26 bytes in /var/<path-to-docroot>/includes/LocalisationCache.php on line 1007
Notice: unserialize(): Error at offset 13 of 18 bytes in /var/<path-to-docroot>/includes/LocalisationCache.php on line 1007
It's worth noting that this a notice, one of PHP's least urgent errors. Somewhat like a compiler warning, it doesn't stop the code from running, it just warns you that there may be bugs in your code. Most people run with notices disabled. We don't like flawed code to slip through so we report all errors.
Attempts to Reproduce
First thing we did was check the development sandbox section of the deployment system. Oddly, the dev code did not have the problem.
Next, we tried updating the staging virtual host with the latest code and a copy of the production database. Again, the bug could not be reproduced. It happened only in the production environment. Odd.
Solution
Next Dave looked into it. Here's the transcript from the bug ticket:
I did some debugging as well: * redeployed the SVN code to production (still causes an error in the production environment) * dumped and recreated the production database (still errors in prod)
Eventually, I ran across this documentation about the table that controls the "LocalisationCache"
> The l10n_cache table. Its content can be deleted and excluded from > backups as it will be regenerated when needed.
....so I just did a `DELETE FROM l10n_cache`, deleting everything from the table.
That seems to have fixed it.
If this ever comes up again and someone finds this ticket – an easier way of troubleshooting, instead of uploading images, is to just visit the Version page – http://wiki.imarc.net/Special:... – when the localisation cache is messed up, just visiting that page caused the serialize offset error.