X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=maintenance%2FnamespaceDupes.php;h=cbc389be62b7d79793d3e2816fab8aa60736b1e8;hb=b1e4006b440185c7e8304c03946bb0155b0edc83;hp=a1520916ec90558b73345411fc79932d6f897129;hpb=2e040b99eda6c99cf472b3896f62d2f21315e808;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/namespaceDupes.php b/maintenance/namespaceDupes.php index a1520916ec..cbc389be62 100644 --- a/maintenance/namespaceDupes.php +++ b/maintenance/namespaceDupes.php @@ -186,8 +186,8 @@ class NamespaceConflictChecker extends Maintenance { /** * @todo Do this for real - * @param int $ns - * @param string $name + * @param int $key + * @param string $prefix * @param bool $fix * @param string $suffix * @return bool @@ -208,35 +208,29 @@ class NamespaceConflictChecker extends Maintenance { * @return array */ private function getConflicts( $ns, $name ) { - $page = 'page'; - $table = $this->db->tableName( $page ); - - $prefix = $this->db->strencode( $name ); - $encNamespace = $this->db->addQuotes( $ns ); - - $titleSql = "TRIM(LEADING '$prefix:' FROM {$page}_title)"; + $titleSql = "TRIM(LEADING {$this->db->addQuotes( "$name:" )} FROM page_title)"; if ( $ns == 0 ) { // An interwiki; try an alternate encoding with '-' for ':' - $titleSql = $this->db->buildConcat( array( "'$prefix-'", $titleSql ) ); - } - - $sql = "SELECT {$page}_id AS id, - {$page}_title AS oldtitle, - $encNamespace + {$page}_namespace AS namespace, - $titleSql AS title, - {$page}_namespace AS oldnamespace - FROM {$table} - WHERE ( {$page}_namespace=0 OR {$page}_namespace=1 ) - AND {$page}_title " . $this->db->buildLike( $name . ':', $this->db->anyString() ); - - $result = $this->db->query( $sql, __METHOD__ ); - - $set = array(); - foreach ( $result as $row ) { - $set[] = $row; + $titleSql = $this->db->buildConcat( array( + $this->db->addQuotes( "$name-" ), + $titleSql, + ) ); } - return $set; + return iterator_to_array( $this->db->select( 'page', + array( + 'id' => 'page_id', + 'oldtitle' => 'page_title', + 'namespace' => $this->db->addQuotes( $ns ) . ' + page_namespace', + 'title' => $titleSql, + 'oldnamespace' => 'page_namespace', + ), + array( + 'page_namespace' => array( 0, 1 ), + 'page_title' . $this->db->buildLike( "$name:", $this->db->anyString() ), + ), + __METHOD__ + ) ); } /**