Index: trunk/extensions/TitleKey/TitleKey_body.php |
— | — | @@ -109,25 +109,35 @@ |
110 | 110 | * |
111 | 111 | * Status info is sent to stdout. |
112 | 112 | */ |
113 | | - static function schemaUpdates() { |
114 | | - global $wgDBtype; |
115 | | - $db = wfGetDB( DB_MASTER ); |
| 113 | + static function schemaUpdates( $updater = null ) { |
| 114 | + if ( $updater === null ) { // < 1.17 |
| 115 | + self::runUpdates( wfGetDB( DB_MASTER ) ); |
| 116 | + } else { |
| 117 | + $updater->addExtensionUpdate( array( array( __CLASS__, 'addDBtable' ) ) ); |
| 118 | + } |
| 119 | + return true; |
| 120 | + } |
| 121 | + |
| 122 | + public static function addDBtable( $updater ) { |
| 123 | + self::runUpdates( $updater->getDB() ); |
| 124 | + } |
| 125 | + |
| 126 | + private static function runUpdates( $db ) { |
116 | 127 | if( $db->tableExists( 'titlekey' ) ) { |
117 | | - echo "...titlekey already exists.\n"; |
| 128 | + wfOut( "...titlekey table already exists.\n" ); |
118 | 129 | } else { |
119 | | - echo "...creating titlekey table...\n"; |
120 | | - $sourcefile = $wgDBtype == 'postgres' ? '/titlekey.pg.sql' : '/titlekey.sql'; |
| 130 | + wfOut( "Creating titlekey table..." ); |
| 131 | + $sourcefile = $db->getType() == 'postgres' ? '/titlekey.pg.sql' : '/titlekey.sql'; |
121 | 132 | $err = $db->sourceFile( dirname( __FILE__ ) . $sourcefile ); |
122 | 133 | if( $err !== true ) { |
123 | 134 | throw new MWException( $err ); |
124 | 135 | } |
125 | | - |
126 | | - echo "...populating titlekey table...\n"; |
| 136 | + |
| 137 | + wfOut( "ok.\nPopulating titlekey table...\n" ); |
127 | 138 | self::populateKeys(); |
128 | 139 | } |
129 | | - return true; |
130 | 140 | } |
131 | | - |
| 141 | + |
132 | 142 | /** |
133 | 143 | * (Re)populate the titlekeys table with all page titles, |
134 | 144 | * optionally starting from a given page id. |