r44426 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r44425‎ | r44426 | r44427 >
Date:22:39, 10 December 2008
Author:catrope
Status:deferred
Tags:
Comment:
* 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
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/api/ApiProtect.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1831,11 +1831,11 @@
18321832 *
18331833 * @param $limit Array: set of restriction keys
18341834 * @param $reason String
1835 - * @param $cascade Integer
 1835+ * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
18361836 * @param $expiry Array: per restriction type expiration
18371837 * @return bool true on success
18381838 */
1839 - public function updateRestrictions( $limit = array(), $reason = '', $cascade = 0, $expiry = array() ) {
 1839+ public function updateRestrictions( $limit = array(), $reason = '', &$cascade = 0, $expiry = array() ) {
18401840 global $wgUser, $wgRestrictionTypes, $wgContLang;
18411841
18421842 $id = $this->mTitle->getArticleID();
@@ -1856,8 +1856,10 @@
18571857 $updated = Article::flattenRestrictions( $limit );
18581858 $changed = false;
18591859 foreach( $wgRestrictionTypes as $action ) {
1860 - $current[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
1861 - $changed = ($changed || ($this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) );
 1860+ if( isset( $expiry[$action] ) ) {
 1861+ $current[$action] = implode( '', $this->mTitle->getRestrictions( $action ) );
 1862+ $changed = ($changed || ($this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) );
 1863+ }
18621864 }
18631865
18641866 $current = Article::flattenRestrictions( $current );
Index: trunk/phase3/includes/api/ApiProtect.php
@@ -105,9 +105,10 @@
106106 wfTimestamp(TS_ISO_8601, $expiryarray[$p[0]])));
107107 }
108108
 109+ $cascade = $params['cascade'];
109110 if($titleObj->exists()) {
110111 $articleObj = new Article($titleObj);
111 - $ok = $articleObj->updateRestrictions($protections, $params['reason'], $params['cascade'], $expiryarray);
 112+ $ok = $articleObj->updateRestrictions($protections, $params['reason'], $cascade, $expiryarray);
112113 } else
113114 $ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiryarray['create']);
114115 if(!$ok)
@@ -115,7 +116,7 @@
116117 // Just throw an unknown error in this case, as it's very likely to be a race condition
117118 $this->dieUsageMsg(array());
118119 $res = array('title' => $titleObj->getPrefixedText(), 'reason' => $params['reason']);
119 - if($params['cascade'])
 120+ if($cascade)
120121 $res['cascade'] = '';
121122 $res['protections'] = $resultProtections;
122123 $this->getResult()->setIndexedTagName($res['protections'], 'protection');
@@ -149,7 +150,8 @@
150151 'expiry' => array('Expiry timestamps. If only one timestamp is set, it\'ll be used for all protections.',
151152 'Use \'infinite\', \'indefinite\' or \'never\', for a neverexpiring protection.'),
152153 'reason' => 'Reason for (un)protecting (optional)',
153 - 'cascade' => 'Enable cascading protection (i.e. protect pages included in this page)'
 154+ 'cascade' => array('Enable cascading protection (i.e. protect pages included in this page)',
 155+ 'Ignored if not all protection levels are \'sysop\' or \'protect\''),
154156 );
155157 }
156158
Index: trunk/phase3/RELEASE-NOTES
@@ -494,6 +494,8 @@
495495 * (bug 16548) list=search threw errors with an invalid error code
496496 * (bug 16515) Added pst and onlypst parameters to action=parse
497497 * (bug 16541) Added block expiry timestamp to list=logevents output
 498+* (bug 16613) action=protect doesn't tell when &cascade was set but cascading
 499+ protection wasn't allowed
498500
499501 === Languages updated in 1.14 ===
500502

Status & tagging log