From: Reedy Date: Sat, 9 Sep 2017 16:28:09 +0000 (+0100) Subject: installer: Reuse $db->makeList() rather than reinventing the wheel X-Git-Tag: 1.31.0-rc.0~1848 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=ce65e570c5b72c0cd948de01a3b881cffc4f7be3;p=lhc%2Fweb%2Fwiklou.git installer: Reuse $db->makeList() rather than reinventing the wheel Change-Id: Ib1f896e5bed17bc240fe585fd6d5f753995a12e1 --- diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index bcc2705651..466ad0f074 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -21,6 +21,7 @@ * @ingroup Deployment */ use Wikimedia\Rdbms\MySQLField; +use Wikimedia\Rdbms\IDatabase; use MediaWiki\MediaWikiServices; /** @@ -530,25 +531,12 @@ class MysqlUpdater extends DatabaseUpdater { ) ); } $sql = "SELECT cur_title, cur_namespace, cur_id, cur_timestamp FROM $cur WHERE "; - $firstCond = true; + $dupeTitles = []; foreach ( $duplicate as $ns => $titles ) { - if ( $firstCond ) { - $firstCond = false; - } else { - $sql .= ' OR '; - } - $sql .= "( cur_namespace = {$ns} AND cur_title in ("; - $first = true; - foreach ( $titles as $t ) { - if ( $first ) { - $sql .= $this->db->addQuotes( $t ); - $first = false; - } else { - $sql .= ', ' . $this->db->addQuotes( $t ); - } - } - $sql .= ") ) \n"; + $dupeTitles[] = "( cur_namespace = {$ns} AND cur_title in (" + . $this->db->makeList( $titles ) . ") ) \n"; } + $sql .= $this->db->makeList( $dupeTitles, IDatabase::LIST_OR ); # By sorting descending, the most recent entry will be the first in the list. # All following entries will be deleted by the next while-loop. $sql .= 'ORDER BY cur_namespace, cur_title, cur_timestamp DESC';