);
global $wgContLang;
- foreach ( MWNamespace::getCanonicalNamespaces() as $ns => $name ) {
+ foreach ( $wgContLang->getNamespaces() as $ns => $name ) {
if ( $ns == 0 ) {
continue;
}
$this->output( "Cleaning up broken links for namespace $ns... " );
-
- $pagelinks = $this->db->tableName( 'pagelinks' );
- $name = $wgContLang->getNsText( $ns );
- $prefix = $this->db->strencode( $name );
- $likeprefix = str_replace( '_', '\\_', $prefix );
-
- $sql = "UPDATE $pagelinks
- SET pl_namespace=$ns,
- pl_title=TRIM(LEADING '$prefix:' FROM pl_title)
- WHERE pl_namespace=0
- AND pl_title LIKE '$likeprefix:%'";
-
- $this->db->query( $sql, __METHOD__ );
+ $this->db->update( 'pagelinks',
+ array(
+ 'pl_namespace' => $ns,
+ "pl_title = TRIM(LEADING {$this->db->addQuotes( "$name:" )} FROM pl_title)",
+ ),
+ array(
+ 'pl_namespace' => 0,
+ 'pl_title' . $this->db->buildLike( "$name:", $this->db->anyString() ),
+ ),
+ __METHOD__
+ );
$this->output( "done.\n" );
}
}
}
}
- $searchon = $this->db->strencode( join( ',', $q ) );
+ $searchon = $this->db->addQuotes( join( ',', $q ) );
$field = $this->getIndexField( $fulltext );
- return "$field, '$searchon'";
+ return "$field, $searchon";
}
/**
wfDebug( __METHOD__ . ": Can't understand search query '{$filteredText}'\n" );
}
- $searchon = $this->db->strencode( $searchon );
+ $searchon = $this->db->addQuotes( $searchon );
$field = $this->getIndexField( $fulltext );
- return " MATCH($field) AGAINST('$searchon' IN BOOLEAN MODE) ";
+ return " MATCH($field) AGAINST($searchon IN BOOLEAN MODE) ";
}
function regexTerm( $string, $wildcard ) {
wfDebug( __METHOD__ . ": Can't understand search query '{$filteredText}'\n" );
}
- $searchon = $this->db->strencode( $searchon );
+ $searchon = $this->db->addQuotes( $searchon );
$field = $this->getIndexField( $fulltext );
- return " $field MATCH '$searchon' ";
+ return " $field MATCH $searchon ";
}
function regexTerm( $string, $wildcard ) {
* @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 ) );
+ $titleSql = $this->db->buildConcat( array(
+ $this->db->addQuotes( "$name-" ),
+ $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;
- }
-
- 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__
+ ) );
}
/**
// Some logs don't go in RC. This should check for that
$basicRCLogs = array_diff( $wgLogTypes, array_keys( $wgLogRestrictions ) );
- // Escape...blah blah
- $selectLogs = array();
- foreach ( $basicRCLogs as $logtype ) {
- $safetype = $dbw->strencode( $logtype );
- $selectLogs[] = "'$safetype'";
- }
-
$cutoff = time() - $wgRCMaxAge;
list( $logging, $page ) = $dbw->tableNamesN( 'logging', 'page' );
$dbw->insertSelect(
array(
'log_timestamp > ' . $dbw->addQuotes( $dbw->timestamp( $cutoff ) ),
'log_user=user_id',
- 'log_type IN(' . implode( ',', $selectLogs ) . ')'
+ 'log_type' => $basicRCLogs,
),
__METHOD__,
array(), // INSERT options