Index: trunk/extensions/AbuseFilter/install.php |
— | — | @@ -1,33 +0,0 @@ |
2 | | -<?php |
3 | | -/** |
4 | | - * Makes the required changes for the AbuseFilter extension |
5 | | - */ |
6 | | - |
7 | | -require_once ( getenv( 'MW_INSTALL_PATH' ) !== false |
8 | | - ? getenv( 'MW_INSTALL_PATH' ) . "/maintenance/commandLine.inc" |
9 | | - : dirname( __FILE__ ) . '/../../maintenance/commandLine.inc' ); |
10 | | - |
11 | | -$sqlfile = '/abusefilter.tables.sql'; |
12 | | -if ( $wgDBtype == 'postgres' ) |
13 | | - $sqlfile = '/abusefilter.tables.pg.sql'; |
14 | | - |
15 | | -wfGetDB( DB_MASTER )->sourceFile( dirname( __FILE__ ) . $sqlfile ); |
16 | | - |
17 | | -// Create the Abuse Filter user. |
18 | | -$user = User::newFromName( wfMsgForContent( 'abusefilter-blocker' ) ); |
19 | | - |
20 | | -if ( !$user->getId() ) { |
21 | | - $user->addToDatabase(); |
22 | | - $user->saveSettings(); |
23 | | - # Increment site_stats.ss_users |
24 | | - $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
25 | | - $ssu->doUpdate(); |
26 | | -} else { |
27 | | - // Sorry dude, we need this account. |
28 | | - $user->setPassword( null ); |
29 | | - $user->setEmail( null ); |
30 | | - $user->saveSettings(); |
31 | | -} |
32 | | - |
33 | | -# Promote user so it doesn't look too crazy. |
34 | | -$user->addGroup( 'sysop' ); |
Index: trunk/extensions/AbuseFilter/AbuseFilter.php |
— | — | @@ -168,4 +168,5 @@ |
169 | 169 | $wgAbuseFilterBlockDuration = 'indefinite'; |
170 | 170 | |
171 | 171 | // Callback functions for custom actions |
172 | | -$wgAbuseFilterCustomActionsHandlers = array(); |
\ No newline at end of file |
| 172 | +$wgAbuseFilterCustomActionsHandlers = array(); |
| 173 | + |
Index: trunk/extensions/AbuseFilter/AbuseFilter.hooks.php |
— | — | @@ -183,82 +183,64 @@ |
184 | 184 | } |
185 | 185 | |
186 | 186 | /** |
187 | | - * @static |
188 | 187 | * @param $updater DatabaseUpdater |
189 | 188 | * @return bool |
190 | 189 | */ |
191 | 190 | public static function onLoadExtensionSchemaUpdates( $updater = null ) { |
192 | 191 | $dir = dirname( __FILE__ ); |
193 | 192 | |
194 | | - if ( $updater === null ) { |
195 | | - global $wgExtNewTables, $wgExtNewFields, $wgExtPGNewFields, $wgExtPGAlteredFields, $wgExtNewIndexes, $wgDBtype; |
196 | | - // DB updates |
197 | | - if ( $wgDBtype == 'mysql' || $wgDBtype == 'sqlite' ) { |
198 | | - if ( $wgDBtype == 'mysql' ) { |
199 | | - $wgExtNewTables[] = array( 'abuse_filter', "$dir/abusefilter.tables.sql" ); |
200 | | - } else { |
201 | | - $wgExtNewTables[] = array( 'abuse_filter', "$dir/abusefilter.tables.sqlite.sql" ); |
202 | | - } |
203 | | - $wgExtNewTables[] = array( 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.sql" ); |
204 | | - $wgExtNewFields[] = array( 'abuse_filter_history', 'afh_changed_fields', "$dir/db_patches/patch-afh_changed_fields.sql" ); |
205 | | - $wgExtNewFields[] = array( 'abuse_filter', 'af_deleted', "$dir/db_patches/patch-af_deleted.sql" ); |
206 | | - $wgExtNewFields[] = array( 'abuse_filter', 'af_actions', "$dir/db_patches/patch-af_actions.sql" ); |
207 | | - $wgExtNewFields[] = array( 'abuse_filter', 'af_global', "$dir/db_patches/patch-global_filters.sql" ); |
208 | | - if ( $wgDBtype == 'mysql' ) { |
209 | | - $wgExtNewIndexes[] = array( 'abuse_filter_log', 'filter_timestamp', "$dir/db_patches/patch-fix-indexes.sql" ); |
210 | | - } else { |
211 | | - $wgExtNewIndexes[] = array( 'abuse_filter_log', 'afl_filter_timestamp', "$dir/db_patches/patch-fix-indexes.sqlite.sql" ); |
212 | | - } |
213 | | - } elseif ( $wgDBtype == 'postgres' ) { |
214 | | - $wgExtNewTables = array_merge( $wgExtNewTables, |
215 | | - array( |
216 | | - array( 'abuse_filter', "$dir/abusefilter.tables.pg.sql" ), |
217 | | - array( 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.pg.sql" ), |
218 | | - ) ); |
219 | | - $wgExtPGNewFields[] = array( 'abuse_filter', 'af_actions', "TEXT NOT NULL DEFAULT ''" ); |
220 | | - $wgExtPGNewFields[] = array( 'abuse_filter', 'af_deleted', 'SMALLINT NOT NULL DEFAULT 0' ); |
221 | | - $wgExtPGNewFields[] = array( 'abuse_filter', 'af_global', 'SMALLINT NOT NULL DEFAULT 0' ); |
222 | | - |
223 | | - $wgExtPGNewFields[] = array( 'abuse_filter_log', 'afl_wiki', 'TEXT' ); |
224 | | - $wgExtPGNewFields[] = array( 'abuse_filter_log', 'afl_deleted', 'SMALLINT' ); |
225 | | - $wgExtPGAlteredFields[] = array( 'abuse_filter_log', 'afl_filter', 'TEXT' ); |
226 | | - |
227 | | - $wgExtNewIndexes[] = array( 'abuse_filter_log', 'abuse_filter_log_ip', "(afl_ip)" ); |
| 193 | + if ( $updater->getDB()->getType() == 'mysql' || $updater->getDB()->getType() == 'sqlite' ) { |
| 194 | + if ( $updater->getDB()->getType() == 'mysql' ) { |
| 195 | + $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', "$dir/abusefilter.tables.sql", true ) ); |
| 196 | + $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.sql", true ) ); |
228 | 197 | } else { |
229 | | - throw new MWException("No known Schema updates."); |
| 198 | + $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', "$dir/abusefilter.tables.sqlite.sql", true ) ); |
| 199 | + $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.sqlite.sql", true ) ); |
230 | 200 | } |
| 201 | + $updater->addExtensionUpdate( array( 'addField', 'abuse_filter_history', 'afh_changed_fields', "$dir/db_patches/patch-afh_changed_fields.sql", true ) ); |
| 202 | + $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_deleted', "$dir/db_patches/patch-af_deleted.sql", true ) ); |
| 203 | + $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_actions', "$dir/db_patches/patch-af_actions.sql", true ) ); |
| 204 | + $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_global', "$dir/db_patches/patch-global_filters.sql", true ) ); |
| 205 | + if ( $updater->getDB()->getType() == 'mysql' ) { |
| 206 | + $updater->addExtensionUpdate( array( 'addIndex', 'abuse_filter_log', 'filter_timestamp', "$dir/db_patches/patch-fix-indexes.sql", true ) ); |
| 207 | + } else { |
| 208 | + $updater->addExtensionUpdate( array( 'addIndex', 'abuse_filter_log', 'afl_filter_timestamp', "$dir/db_patches/patch-fix-indexes.sqlite.sql", true ) ); |
| 209 | + } |
| 210 | + } elseif ( $updater->getDB()->getType() == 'postgres' ) { |
| 211 | + $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', "$dir/abusefilter.tables.pg.sql", true ) ); |
| 212 | + $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.pg.sql", true ) ); |
| 213 | + $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter', 'af_actions', "TEXT NOT NULL DEFAULT ''" ) ); |
| 214 | + $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter', 'af_deleted', 'SMALLINT NOT NULL DEFAULT 0' ) ); |
| 215 | + $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter', 'af_global', 'SMALLINT NOT NULL DEFAULT 0' ) ); |
| 216 | + $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter_log', 'afl_wiki', 'TEXT' ) ); |
| 217 | + $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter_log', 'afl_deleted', 'SMALLINT' ) ); |
| 218 | + $updater->addExtensionUpdate( array( 'changeField', 'abuse_filter_log', 'afl_filter', 'TEXT' ) ); |
| 219 | + $updater->addExtensionUpdate( array( 'addPgExtIndex', 'abuse_filter_log', 'abuse_filter_log_ip', "(afl_ip)" ) ); |
231 | 220 | } else { |
232 | | - if ( $updater->getDB()->getType() == 'mysql' || $updater->getDB()->getType() == 'sqlite' ) { |
233 | | - if ( $updater->getDB()->getType() == 'mysql' ) { |
234 | | - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', "$dir/abusefilter.tables.sql", true ) ); |
235 | | - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.sql", true ) ); |
236 | | - } else { |
237 | | - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', "$dir/abusefilter.tables.sqlite.sql", true ) ); |
238 | | - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.sqlite.sql", true ) ); |
239 | | - } |
240 | | - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter_history', 'afh_changed_fields', "$dir/db_patches/patch-afh_changed_fields.sql", true ) ); |
241 | | - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_deleted', "$dir/db_patches/patch-af_deleted.sql", true ) ); |
242 | | - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_actions', "$dir/db_patches/patch-af_actions.sql", true ) ); |
243 | | - $updater->addExtensionUpdate( array( 'addField', 'abuse_filter', 'af_global', "$dir/db_patches/patch-global_filters.sql", true ) ); |
244 | | - if ( $updater->getDB()->getType() == 'mysql' ) { |
245 | | - $updater->addExtensionUpdate( array( 'addIndex', 'abuse_filter_log', 'filter_timestamp', "$dir/db_patches/patch-fix-indexes.sql", true ) ); |
246 | | - } else { |
247 | | - $updater->addExtensionUpdate( array( 'addIndex', 'abuse_filter_log', 'afl_filter_timestamp', "$dir/db_patches/patch-fix-indexes.sqlite.sql", true ) ); |
248 | | - } |
249 | | - } elseif ( $updater->getDB()->getType() == 'postgres' ) { |
250 | | - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter', "$dir/abusefilter.tables.pg.sql", true ) ); |
251 | | - $updater->addExtensionUpdate( array( 'addTable', 'abuse_filter_history', "$dir/db_patches/patch-abuse_filter_history.pg.sql", true ) ); |
252 | | - $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter', 'af_actions', "TEXT NOT NULL DEFAULT ''" ) ); |
253 | | - $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter', 'af_deleted', 'SMALLINT NOT NULL DEFAULT 0' ) ); |
254 | | - $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter', 'af_global', 'SMALLINT NOT NULL DEFAULT 0' ) ); |
255 | | - $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter_log', 'afl_wiki', 'TEXT' ) ); |
256 | | - $updater->addExtensionUpdate( array( 'addPgField', 'abuse_filter_log', 'afl_deleted', 'SMALLINT' ) ); |
257 | | - $updater->addExtensionUpdate( array( 'changeField', 'abuse_filter_log', 'afl_filter', 'TEXT' ) ); |
258 | | - $updater->addExtensionUpdate( array( 'addPgExtIndex', 'abuse_filter_log', 'abuse_filter_log_ip', "(afl_ip)" ) ); |
| 221 | + throw new MWException("No known Schema updates."); |
| 222 | + } |
| 223 | + |
| 224 | + // Create the Abuse Filter user. |
| 225 | + $user = User::newFromName( wfMsgForContent( 'abusefilter-blocker' ) ); |
| 226 | + |
| 227 | + if ( !$updater->updateRowExists( 'create abusefilter-blocker-user' ) ) { |
| 228 | + if ( !$user->getId() ) { |
| 229 | + $user->addToDatabase(); |
| 230 | + $user->saveSettings(); |
| 231 | + # Increment site_stats.ss_users |
| 232 | + $ssu = new SiteStatsUpdate( 0, 0, 0, 0, 1 ); |
| 233 | + $ssu->doUpdate(); |
259 | 234 | } else { |
260 | | - throw new MWException("No known Schema updates."); |
| 235 | + // Sorry dude, we need this account. |
| 236 | + $user->setPassword( null ); |
| 237 | + $user->setEmail( null ); |
| 238 | + $user->saveSettings(); |
261 | 239 | } |
| 240 | + $updater->insertUpdateRow( 'create abusefilter-blocker-user' ); |
| 241 | + # Promote user so it doesn't look too crazy. |
| 242 | + $user->addGroup( 'sysop' ); |
262 | 243 | } |
| 244 | + |
263 | 245 | return true; |
264 | 246 | } |
265 | 247 | |