*(bug 30976) Add maintenance script to remove preferences from $wgHiddenPrefs
authorTyA <tya.wiki@gmail.com>
Wed, 30 May 2012 03:49:17 +0000 (04:49 +0100)
committerReedy <reedy@wikimedia.org>
Wed, 4 Jul 2012 22:08:41 +0000 (23:08 +0100)
Change-Id: Ie74fab1edeac2c6b275c51e6af3a7924b3aac46b

maintenance/cleanupPreferences.php [new file with mode: 0755]

diff --git a/maintenance/cleanupPreferences.php b/maintenance/cleanupPreferences.php
new file mode 100755 (executable)
index 0000000..57a5369
--- /dev/null
@@ -0,0 +1,29 @@
+<?php\r
+/**\r
+ * Description: This script takes $wgHiddenPrefs and removes their preference from the DB. [[bugzilla:30976]]\r
+ * @author TyA <tya.wiki@gmail.com>\r
+ * @ingroup Maintenance\r
+ */\r
+\r
+require_once( dirname( __FILE__ ) . '/Maintenance.php' );\r
+\r
+class CleanupPreferences extends Maintenance {\r
+       public function execute() {\r
+               global $wgHiddenPrefs;\r
+\r
+               $dbw = wfGetDB( DB_MASTER );\r
+               $dbw->begin();\r
+               foreach( $wgHiddenPrefs as $item ) {\r
+                       $dbw->delete(\r
+                               'user_properties',\r
+                               array( 'up_property' => $item ),\r
+                               __METHOD__\r
+                       );\r
+               };\r
+               $dbw->commit();\r
+               $this->output( "Finished!\n" );\r
+       }\r
+}\r
+\r
+$maintClass = 'CleanupPreferences'; // Tells it to run the class\r
+require_once( RUN_MAINTENANCE_IF_MAIN );\r