* list=random now has rnredirect parameter, to get random redirects.
* Added APIAfterExecute, APIQueryAfterExecute and APIQueryGeneratorAfterExecute
hooks which allow for extending core modules in a cleaner way
+* action=protect checks for invalid protection types and levels
=== Languages updated in 1.14 ===
'nocreate-missing' => array('code' => 'missingtitle', 'info' => "The article you tried to edit doesn't exist"),
'nosuchrcid' => array('code' => 'nosuchrcid', 'info' => "There is no change with rcid ``\$1''"),
'cantpurge' => array('code' => 'cantpurge', 'info' => "Only users with the 'purge' right can purge pages via the API"),
+ 'protect-invalidaction' => array('code' => 'protect-invalidaction', 'info' => "Invalid protection type ``\$1''"),
+ 'protect-invalidlevel' => array('code' => 'protect-invalidlevel', 'info' => "Invalid protection level ``\$1''"),
// ApiEditPage messages
'noimageredirect-anon' => array('code' => 'noimageredirect-anon', 'info' => "Anonymous users can't create image redirects"),
}
public function execute() {
- global $wgUser;
+ global $wgUser, $wgRestrictionTypes, $wgRestrictionLevels;
$this->getMain()->requestWriteMode();
$params = $this->extractRequestParams();
}
$protections = array();
+ $expiryarray = array();
foreach($params['protections'] as $prot)
{
$p = explode('=', $prot);
$this->dieUsageMsg(array('create-titleexists'));
if(!$titleObj->exists() && $p[0] != 'create')
$this->dieUsageMsg(array('missingtitles-createonly'));
+ if(!in_array($p[0], $wgRestrictionTypes) && $p[0] != 'create')
+ $this->dieUsageMsg(array('protect-invalidaction', $p[0]));
+ if(!in_array($p[1], $wgRestrictionLevels) && $p[1] != 'all')
+ $this->dieUsageMsg(array('protect-invalidlevel', $p[1]));
+ $expiryarray[$p[0]] = $expiry;
}
if($titleObj->exists()) {
$articleObj = new Article($titleObj);
- $ok = $articleObj->updateRestrictions($protections, $params['reason'], $params['cascade'], $expiry);
+ $ok = $articleObj->updateRestrictions($protections, $params['reason'], $params['cascade'], $expiryarray);
} else
$ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiry);
if(!$ok)