Page MenuHomePhabricator

updateVarDumps emits PHP notice due to bad serialized data
Closed, ResolvedPublic

Description

See https://pastebin.com/U2EjQeCf:

...Re-storing serialized dumps as JSON-encoded arrays for all rows (3/4).
PHP Notice:  unserialize(): Error at offset 493 of 5608 bytes in /(wiki path)/extensions/AbuseFilter/maintenance/updateVarDumps.php on line 526
[9f481c3285afaa7bdc402410] [no req]   TypeError from line 569 of /(wiki path)/extensions/AbuseFilter/maintenance/updateVarDumps.php: Argument 1 passed to UpdateVarDumps::updateVariables() must be of the type array, bool given, called in /(wiki path)/extensions/AbuseFilter/maintenance/updateVarDumps.php on line 531
Backtrace:
#0 /(wiki path)/extensions/AbuseFilter/maintenance/updateVarDumps.php(531): UpdateVarDumps->updateVariables()
#1 /(wiki path)/extensions/AbuseFilter/maintenance/updateVarDumps.php(485): UpdateVarDumps->doUpdateText()
#2 /(wiki path)/extensions/AbuseFilter/maintenance/updateVarDumps.php(103): UpdateVarDumps->updateText()
#3 /(wiki path)/maintenance/includes/LoggedUpdateMaintenance.php(45): UpdateVarDumps->doDBUpdates()
#4 /(wiki path)/maintenance/update.php(193): LoggedUpdateMaintenance->execute()
#5 /(wiki path)/maintenance/doMaintenance.php(107): UpdateMediaWiki->execute()
#6 /(wiki path)/maintenance/update.php(253): require_once(string)
#7 {main}

Investigation result:
I tried playing around with the truncated dump at T264513#6514943 (padded to reach the lengths hardcoded in the PHP serialization format). Results:

  • The bug cannot be reproduced by putting that dump in the abuse_filter_log table, i.e. what would have happened in 2009, because the script would recognize and rebuild it in step 1
  • However, it can be reproduced if that same truncated dump is inserted into the text table, and the same error message reported above is shown when running the script

So my theories are:

  1. An unknown bug caused the truncated dump to get to the text table
  2. The truncated dump was in the abuse_filter_log table; the script tried rebuilding it but failed without knowing, producing another truncated dump that was inserted into the text table.
  3. Something else

None of these is really convincing, and it's hard to tell without further data. However, we don't need to investigate the root cause unless this bug is seen again.

Event Timeline

Daimona triaged this task as High priority.Oct 3 2020, 10:08 PM

Redacted dump:

...Checking for missing dumps (1/4)
...deleted 0 rows with blank afl_var_dump, and rebuilt 0 rows.
...Moving serialized data away from the abuse_filter_log table (2/4).
...moved 0 abuse_filter_log rows and rebuilt 0 truncated dumps.
...Re-storing serialized dumps as JSON-encoded arrays for all rows (3/4).
string(5608) "a:21:{s:10:"minor_edit";b:0;s:9:"user_name";s:6:"(user)";s:8:"user_age";i:65236196;s:11:"user_groups";a:3:{i:0;s:1:"*";i:1;s:4:"user";i:2;s:14:"emailconfirmed";}s:11:"user_mobile";b:0;s:17:"article_articleid";i:0;s:17:"article_namespace";i:3;s:12:"article_text";s:6:"(user)";s:20:"article_prefixedtext";s:16:"User talk:(user)";s:6:"action";s:4:"edit";s:7:"summary";s:0:"";s:17:"old_content_model";s:0:"";s:17:"new_content_model";s:8:"wikitext";s:12:"old_wikitext";s:0:"";s:12:"new_wikitext";s:5288:"==Welcome==
{| class="toccolours" style="margin: 0.5em 0; background:#E5E7E4; border: 1px solid #78C850; -moz-border-radius: 15px;" cellspacing="1" width="100%"
| style="background: #C2C5BE; border: 1px solid #78C850; -moz-border-radius-topright: 15px; -moz-border-radius-topleft: 15px;" |
<div style="float: center;">[[File:(site) logo.png|50px|left]]<b><big>Welcome to the (site), (user)!</big></b><br><br>As a new user, you may wish to learn a few things that will be useful in your uploading:</div>
|-
|
{| width="100%" style="background-color:#E5E7E4;"
|style="width: 55%; border:1px solid #E5E7E4; background-color:#E5E7E4; vertical-align:top"|
{| width="100%" cellpadding="0" cellspacing="5" style="vertical-align:top; background-color:#E5E7E4"
|-
!<div style="margin: 0; background-color:#C2C5BE; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid #78C850; text-align:left; color:#A2958D; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">[[(wiki):Manual of style|Manual of Style]]</div>
<div style=text-align:left;>
The Manual of Style, or MoS, outlines the format and guidelines of all images on (site).
</div>
!<div style="margin: 0; background-color:#C2C5BE; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid #78C850; text-align:left; color:#A2958D; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">[[(wiki):Administrators|List of Admins]]</div>
<div style=text-align:left;>
All of our administrators are here to help! Talk to them if you have any questions or problems with the (wiki).
</div>
!<div style="margin: 0; background-color:#C2C5BE; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid #78C850; text-align:left; color:#A2958D; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">[[(wiki):Tagging images|Tagging Guidelines]]</div>
<div style=text-align:left;>
Tagging images with correct licenses and categories is a must. These guidelines will help you learn more about tagging images.
</div>
|}
|}
|-
|
<div style="margin: 0; background-color:#C2C5BE; font-family: sans-serif; font-size:120%; font-weight:bold; border:1px solid #78C850; text-align:left; color:#A2958D; padding-left:0.4em; padding-top: 0.2em; padding-bottom: 0.2em;">Miscellaneous</div>
<div style=text-align:left;>
*Please '''read''' the checklist when you upload media files. The checklist is there to make sure you are doing everything necessary when uploading said media files.
*Be sure to '''[[(wiki):Tagging images|tag]]''' and '''[[(wiki):Manual of style#Categories|categorize]]''' all images. This helps organize the vast amount of images we have here.
*Check if your image already exists by searching through categories, and (other wiki) pages. This action will help prevent unnecessary duplicates from appearing.
*When adding a licensing tag to anime or game screenshots, please avoid just choosing "Screenshot". This is not descriptive and places the images in the wrong category. Make sure to choose "Screenshot from a game," or "Screenshot from the anime." This will put them in the right categories, and help keep the (wiki) clean.
*Does your image have a purpose? Will you be using it on a (network) Project? Avoid uploading images because you think they are "Cute" or "Awesome". That clutters the (wiki).
*Personal images are limited to two for each User. Personal images include personal logos, personal sprites, drawings, cards and mostly any image that would only be used in the User: namespace and have no encyclopedic value to (network) and its affiliates. Please tag these with the {{template|i-Personal}} template for easier organization. Under no circumstance should a photograph of one's self ever be uploaded onto (site).
*In addition, please upload images with meaningful names. Names that are just numbers, for example, do not describe anything about the image, and can make it difficult for searchers. Names are just as important as licenses and categories, so make them descriptive. Please be sure that the filenames contain alphanumeric characters only.
*Due to the many automated templates used on the wiki, lowercase extensions are imperative. That means jpg and png instead of JPG and PNG. It looks cleaner, it works better, and it does not cause any problems. Make sure to always use lowercase extensions.
*If you're confused about the requirements for uploading files, have a look at [[:File:(site) Howto.png|this guide]].
</div>
|-
| style="background: #C2C5BE; border: 1px solid #78C850; -moz-border-radius-bottomright: 15px; -moz-border-radius-bottomleft: 15px;" |
<div style="float: left;">&nbsp;Thank you, and have a good time uploading here!</div><div style="float: right; height: 20px; background: white; border-left: 10px solid #f3f5f1; -moz-border-radius-bottomright: 15px;">&nbsp;[[User:(user)|<span style="border:1px solid black;padding:1px;font-size:85%;color:darkred;font-family:Segoe Script">(user)</span>]]'''''[[User talk:(user)|<sup>"

Change 631951 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@master] Minor updates related to var dumps

https://gerrit.wikimedia.org/r/631951

Change 631817 had a related patch set uploaded (by Daimona Eaytoy; owner: Daimona Eaytoy):
[mediawiki/extensions/AbuseFilter@REL1_35] Minor updates related to var dumps

https://gerrit.wikimedia.org/r/631817

Daimona's patch worked, and I was able to continue my upgrade for both of my wiki sites. I ran into this error originally while upgrading from 1.29 to 1.35, and I saw it with both sites. I would like to know if this could potentially introduce database corruption down the line, however.

I would like to know if this could potentially introduce database corruption down the line, however.

The error itself didn't introduce data corruption, and the script is going to fix everything. The only problem is that the truncated dumps won't be fully available, but that's already the case (the difference being: going to the web interface now would result in an uncaught exception, doing so later would result in partial data being shown).

Change 631951 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@master] Minor updates related to var dumps

https://gerrit.wikimedia.org/r/631951

Change 631817 merged by jenkins-bot:
[mediawiki/extensions/AbuseFilter@REL1_35] Minor updates related to var dumps

https://gerrit.wikimedia.org/r/631817