Prevent gadget preferences from being cleaned up

Bug: T188966
Change-Id: I5627f014827fdbf266eb7fdb00a446f81a0c3458
This commit is contained in:
Sam Wilson 2018-04-06 08:18:46 +08:00 committed by MaxSem
parent 441302fb5e
commit 97c5bd7732
2 changed files with 15 additions and 0 deletions

View file

@ -108,6 +108,9 @@
],
"wgQueryPages": [
"GadgetHooks::onwgQueryPages"
],
"DeleteUnknownPreferences": [
"GadgetHooks::onDeleteUnknownPreferences"
]
},
"config": {

View file

@ -20,6 +20,7 @@
*
* @file
*/
use Wikimedia\Rdbms\IDatabase;
use Wikimedia\WrappedString;
class GadgetHooks {
@ -327,4 +328,15 @@ class GadgetHooks {
$queryPages[] = [ 'SpecialGadgetUsage', 'GadgetUsage' ];
return true;
}
/**
* Prevent gadget preferences from being deleted.
* @link https://www.mediawiki.org/wiki/Manual:Hooks/DeleteUnknownPreferences
* @suppress PhanParamTooMany
* @param string[] &$where Array of where clause conditions to add to.
* @param IDatabase $db
*/
public static function onDeleteUnknownPreferences( &$where, IDatabase $db ) {
$where[] = 'up_property NOT' . $db->buildLike( 'gadget-', $db->anyString() );
}
}