Page MenuHomePhabricator

namespaceDupes.php crashed when trying to fix templatelinks
Closed, DuplicatePublic

Description

zabe@mwmaint2002:~$ mwscript namespaceDupes.php --wiki=ukwiki --fix
0 pages to fix, 0 were resolvable.

Wikimedia\Rdbms\DBQueryError from line 1203 of /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/Database.php: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '1=0 WHERE tl_from = '123917' AND tl_target_id = 37166' at line 1
Function: NamespaceDupes::checkLinkTable
Query: UPDATE IGNORE `templatelinks` SET 1=0 WHERE tl_from = '123917' AND tl_target_id = 37166

#0 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/Database.php(1187): Wikimedia\Rdbms\Database->getQueryException('You have an err...', 1064, 'UPDATE IGNORE `...', 'NamespaceDupes:...')
#1 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/Database.php(1161): Wikimedia\Rdbms\Database->getQueryExceptionAndLog('You have an err...', 1064, 'UPDATE IGNORE `...', 'NamespaceDupes:...')
#2 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/Database.php(652): Wikimedia\Rdbms\Database->reportQueryError('You have an err...', 1064, 'UPDATE IGNORE `...', 'NamespaceDupes:...', false)
#3 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/Database.php(1501): Wikimedia\Rdbms\Database->query(Object(Wikimedia\Rdbms\Query), 'NamespaceDupes:...')
#4 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/DBConnRef.php(119): Wikimedia\Rdbms\Database->update('templatelinks', Array, Array, 'NamespaceDupes:...', Array)
#5 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/database/DBConnRef.php(413): Wikimedia\Rdbms\DBConnRef->__call('update', Array)
#6 /srv/mediawiki/php-1.42.0-wmf.14/includes/libs/rdbms/querybuilder/UpdateQueryBuilder.php(332): Wikimedia\Rdbms\DBConnRef->update('templatelinks', Array, Array, 'NamespaceDupes:...', Array)
#7 /srv/mediawiki/php-1.42.0-wmf.14/maintenance/namespaceDupes.php(452): Wikimedia\Rdbms\UpdateQueryBuilder->execute()
#8 /srv/mediawiki/php-1.42.0-wmf.14/maintenance/namespaceDupes.php(222): NamespaceDupes->checkLinkTable('templatelinks', 'tl', 2, 'User', Array)
#9 /srv/mediawiki/php-1.42.0-wmf.14/maintenance/namespaceDupes.php(113): NamespaceDupes->checkAll(Array)
#10 /srv/mediawiki/php-1.42.0-wmf.14/maintenance/includes/MaintenanceRunner.php(698): NamespaceDupes->execute()
#11 /srv/mediawiki/php-1.42.0-wmf.14/maintenance/run.php(51): MediaWiki\Maintenance\MaintenanceRunner->run()
#12 /srv/mediawiki/multiversion/MWScript.php(158): require_once('/srv/mediawiki/...')
#13 {main}
zabe@mwmaint2002:~$

Event Timeline

MariaDB [ukwiki_p]> select * from linktarget where lt_id = 37166;
+-------+--------------+----------+
| lt_id | lt_namespace | lt_title |
+-------+--------------+----------+
| 37166 |            0 | User:A4  |
+-------+--------------+----------+
1 row in set (0.003 sec)

but the new row does not exists at the moment (or is not used, replica does not show unused linktargets)

MariaDB [ukwiki_p]> select * from linktarget where lt_namespace = 2 and lt_title = 'A4';
Empty set (0.002 sec)

The User is the canonical namespace form, not sure why it was stored on the first insert in the database and why it needs a run of the maintenance script at all now.

I said this before, I say it again. As long as namespaceDupes.php continues to re-invent the wheel and violate DRY, it's going to break with every nominal change (I lost track how many times this has been broken already).

Just force a reparse or all pages linked to the affected page.

Change 992474 had a related patch set uploaded (by Umherirrender; author: Umherirrender):

[mediawiki/core@master] maintenance: Acquire new linktarget in namespaceDupes.php

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

MariaDB [ukwiki_p]> select * from linktarget where lt_id = 37166;
+-------+--------------+----------+
| lt_id | lt_namespace | lt_title |
+-------+--------------+----------+
| 37166 |            0 | User:A4  |
+-------+--------------+----------+
1 row in set (0.003 sec)

but the new row does not exists at the moment (or is not used, replica does not show unused linktargets)

MariaDB [ukwiki_p]> select * from linktarget where lt_namespace = 2 and lt_title = 'A4';
Empty set (0.002 sec)

The User is the canonical namespace form, not sure why it was stored on the first insert in the database and why it needs a run of the maintenance script at all now.

That is another issue, now tracked as T355706: Using interwiki on {{PAGESIZE:}} stores external title in linktarget