From ada841ab2d3e511c461c0b309e84b075e159003f Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 10 Dec 2008 22:39:41 +0000 Subject: [PATCH] * API: (bug 16613) action=protect doesn't say when &cascade is set but cascading protection wasn't allowed * Changed Article::updateRestrictions()'s $cascade parameter to a reference which is set to false if cascading protection isn't allowed * Used this in ApiProtect * Expand help message for &cascade a bit --- RELEASE-NOTES | 2 ++ includes/Article.php | 10 ++++++---- includes/api/ApiProtect.php | 8 +++++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8e4589e08d..ca5e83090b 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -494,6 +494,8 @@ The following extensions are migrated into MediaWiki 1.14: * (bug 16548) list=search threw errors with an invalid error code * (bug 16515) Added pst and onlypst parameters to action=parse * (bug 16541) Added block expiry timestamp to list=logevents output +* (bug 16613) action=protect doesn't tell when &cascade was set but cascading + protection wasn't allowed === Languages updated in 1.14 === diff --git a/includes/Article.php b/includes/Article.php index 07fb6593c2..22e1514ef5 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -1831,11 +1831,11 @@ class Article { * * @param $limit Array: set of restriction keys * @param $reason String - * @param $cascade Integer + * @param &$cascade Integer. Set to false if cascading protection isn't allowed. * @param $expiry Array: per restriction type expiration * @return bool true on success */ - public function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) { + public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) { global $wgUser, $wgRestrictionTypes, $wgContLang; $id = $this->mTitle->getArticleID(); @@ -1856,8 +1856,10 @@ class Article { $updated = Article::flattenRestrictions( $limit ); $changed = false; foreach( $wgRestrictionTypes as $action ) { - $current[$action] = implode( '', $this->mTitle->getRestrictions( $action ) ); - $changed = ($changed || ($this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) ); + if( isset( $expiry[$action] ) ) { + $current[$action] = implode( '', $this->mTitle->getRestrictions( $action ) ); + $changed = ($changed || ($this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) ); + } } $current = Article::flattenRestrictions( $current ); diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php index ecd09ebbd5..0163e5ab6a 100644 --- a/includes/api/ApiProtect.php +++ b/includes/api/ApiProtect.php @@ -105,9 +105,10 @@ class ApiProtect extends ApiBase { wfTimestamp(TS_ISO_8601, $expiryarray[$p[0]]))); } + $cascade = $params['cascade']; if($titleObj->exists()) { $articleObj = new Article($titleObj); - $ok = $articleObj->updateRestrictions($protections, $params['reason'], $params['cascade'], $expiryarray); + $ok = $articleObj->updateRestrictions($protections, $params['reason'], $cascade, $expiryarray); } else $ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiryarray['create']); if(!$ok) @@ -115,7 +116,7 @@ class ApiProtect extends ApiBase { // Just throw an unknown error in this case, as it's very likely to be a race condition $this->dieUsageMsg(array()); $res = array('title' => $titleObj->getPrefixedText(), 'reason' => $params['reason']); - if($params['cascade']) + if($cascade) $res['cascade'] = ''; $res['protections'] = $resultProtections; $this->getResult()->setIndexedTagName($res['protections'], 'protection'); @@ -149,7 +150,8 @@ class ApiProtect extends ApiBase { 'expiry' => array('Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.', 'Use \'infinite\', \'indefinite\' or \'never\', for a neverexpiring protection.'), 'reason' => 'Reason for (un)protecting (optional)', - 'cascade' => 'Enable cascading protection (i.e. protect pages included in this page)' + 'cascade' => array('Enable cascading protection (i.e. protect pages included in this page)', + 'Ignored if not all protection levels are \'sysop\' or \'protect\''), ); } -- 2.20.1