Merge "Add a maintenance script to list variants and languages with then"
[lhc/web/wiklou.git] / includes / installer / MysqlUpdater.php
index 8b77cb1..2f77021 100644 (file)
@@ -254,6 +254,7 @@ class MysqlUpdater extends DatabaseUpdater {
                        // 1.24
                        array( 'addField', 'page_props', 'pp_sortkey', 'patch-pp_sortkey.sql' ),
                        array( 'dropField', 'recentchanges', 'rc_cur_time', 'patch-drop-rc_cur_time.sql' ),
+                       array( 'addIndex', 'watchlist', 'wl_user_notificationtimestamp', 'patch-watchlist-user-notificationtimestamp-index.sql' ),
                );
        }
 
@@ -647,25 +648,23 @@ class MysqlUpdater extends DatabaseUpdater {
                );
 
                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" );
                }
        }