* API: (bug 16613) action=protect doesn't say when &cascade is set but cascading...
authorRoan Kattouw <catrope@users.mediawiki.org>
Wed, 10 Dec 2008 22:39:41 +0000 (22:39 +0000)
committerRoan Kattouw <catrope@users.mediawiki.org>
Wed, 10 Dec 2008 22:39:41 +0000 (22:39 +0000)
* 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
includes/Article.php
includes/api/ApiProtect.php

index 8e4589e..ca5e830 100644 (file)
@@ -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 ===
 
index 07fb659..22e1514 100644 (file)
@@ -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 );
index ecd09eb..0163e5a 100644 (file)
@@ -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\''),
                );
        }