X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2FcleanupPreferences.php;h=b24d72ddda2516c507d6332ef2b1088bb288fabf;hb=a5ea73070652d807afb780a5bd9c6614b5e5a872;hp=a21bc73704f2034792f8ce0cb5c443717570937e;hpb=12ff4dec05ff8bb1a1910bf6745155b93e1912b5;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/cleanupPreferences.php b/maintenance/cleanupPreferences.php index a21bc73704..b24d72ddda 100644 --- a/maintenance/cleanupPreferences.php +++ b/maintenance/cleanupPreferences.php @@ -39,7 +39,7 @@ class CleanupPreferences extends Maintenance { $this->addOption( 'dry-run', 'Print debug info instead of actually deleting' ); $this->addOption( 'hidden', 'Drop hidden preferences ($wgHiddenPrefs)' ); $this->addOption( 'unknown', - 'Drop unknown preferences (not in $wgDefaultUserOptions or a gadget or userjs)' ); + 'Drop unknown preferences (not in $wgDefaultUserOptions or prefixed with "userjs-")' ); // TODO: actually implement this // $this->addOption( 'bogus', 'Drop preferences that have invalid/unaccepted values' ); } @@ -84,18 +84,15 @@ class CleanupPreferences extends Maintenance { } } - // Remove unknown preferences. Special-case gadget- and userjs- as we can't - // control those names. + // Remove unknown preferences. Special-case 'userjs-' as we can't control those names. if ( $unknown ) { - $this->deleteByWhere( - $dbw, - 'Dropping unknown preferences', - [ - 'up_property NOT' . $dbw->buildLike( 'gadget-', $dbw->anyString() ), - 'up_property NOT' . $dbw->buildLike( 'userjs-', $dbw->anyString() ), - 'up_property NOT IN (' . $dbw->makeList( array_keys( $wgDefaultUserOptions ) ) . ')', - ] - ); + $where = [ + 'up_property NOT' . $dbw->buildLike( 'userjs-', $dbw->anyString() ), + 'up_property NOT IN (' . $dbw->makeList( array_keys( $wgDefaultUserOptions ) ) . ')', + ]; + // Allow extensions to add to the where clause to prevent deletion of their own prefs. + Hooks::run( 'DeleteUnknownPreferences', [ &$where, $dbw ] ); + $this->deleteByWhere( $dbw, 'Dropping unknown preferences', $where ); } // Something something phase 3