+ $didWork = false;
+ $hidden = $this->hasOption( 'hidden' );
+ $unknown = $this->hasOption( 'unknown' );
+ $bogus = $this->hasOption( 'bogus' );
+
+ if ( !$hidden && !$unknown && !$bogus ) {
+ $this->output( "Did not select one of --hidden, --unknown or --bogus, exiting\n" );
+ return;
+ }
+
+ // Remove hidden prefs. Iterate over them to avoid the IN on a large table
+ if ( $hidden ) {
+ if ( !$wgHiddenPrefs ) {
+ $this->output( "No hidden preferences, skipping\n" );
+ }
+ foreach ( $wgHiddenPrefs as $hiddenPref ) {
+ $this->deleteByWhere(
+ $dbw,
+ 'Dropping hidden preferences',
+ [ 'up_property' => $hiddenPref ]
+ );
+ }
+ }
+
+ // Remove unknown preferences. Special-case gadget- and 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 ) ) . ')',
+ ]
+ );
+ }
+
+ // Something something phase 3
+ if ( $bogus ) {
+ }
+ }
+
+ /**
+ *
+ */
+ private function deleteByWhere( $dbw, $startMessage, $where ) {
+ $this->output( $startMessage . "...\n" );
+ $total = 0;
+ while ( true ) {
+ $res = $dbw->select(