r93565 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93564‎ | r93565 | r93566 >
Date:02:29, 31 July 2011
Author:mah
Status:resolved (Comments)
Tags:
Comment:
Add back one insertion to the templatelinks table that was removed in
the IWTransclusion merge and ended up breaking ArticleTablesTest::testbug14404
Modified paths:
  • /branches/iwtransclusion/phase3v3/includes/LinksUpdate.php (modified) (history)

Diff [purge]

Index: branches/iwtransclusion/phase3v3/includes/LinksUpdate.php
@@ -380,13 +380,17 @@
381381 if ( count( $insertions ) ) {
382382 if ( isset( $insertions['globaltemplatelinks'] ) ) {
383383 $this->mDb->insert( 'globaltemplatelinks', $insertions['globaltemplatelinks'], __METHOD__, 'IGNORE' );
 384+ unset( $insertions['globaltemplatelinks'] );
384385 }
385386 if ( isset( $insertions['globalnamespaces'] ) ) {
386387 $this->mDb->insert( 'globalnamespaces', $insertions['globalnamespaces'], __METHOD__, 'IGNORE' );
 388+ unset( $insertions['globalnamespaces'] );
387389 }
388390 if ( isset( $insertions['globalinterwiki'] ) ) {
389391 $this->mDb->insert( 'globalinterwiki', $insertions['globalinterwiki'], __METHOD__, 'IGNORE' );
 392+ unset( $insertions['globalinterwiki'] );
390393 }
 394+ $this->mDb->insert( $table, $insertions, __METHOD__, 'IGNORE' );
391395 }
392396 }
393397

Follow-up revisions

RevisionCommit summaryAuthorDate
r94310re r93565 — move unset() before count() as suggested by Roanmah00:24, 12 August 2011

Comments

#Comment by Catrope (talk | contribs)   21:57, 10 August 2011
  1. The data format for $insertions should be documented so I have a chance of understanding what this code is even supposed to do
  2. count( $insertions ) should be checked again after removing things from it
#Comment by Catrope (talk | contribs)   21:58, 10 August 2011

In fact, it's better to put the if ( isset( $insertions['foo'] ) ) blocks outside of the if ( count( $insertions ) ) block so the count is only checked when it's actually needed, and isn't checked twice.

#Comment by Hexmode (talk | contribs)   00:27, 12 August 2011

did that in r93565.... I'm not sure if I can document $insertions, but I'll look.

Status & tagging log