r65477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65476‎ | r65477 | r65478 >
Date:19:36, 23 April 2010
Author:mah
Status:ok
Tags:
Comment:
Don't rely on the extract and its side-effects when we can be explicit.
Also, we can do a simple boolean test rather than use is_array.
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1435,14 +1435,12 @@
14361436
14371437 if( $action == 'create' ) {
14381438 $title_protection = $this->getTitleProtection();
1439 - if( is_array($title_protection) ) {
1440 - extract($title_protection); // is this extract() really needed?
1441 -
1442 - if( $pt_create_perm == 'sysop' ) {
1443 - $pt_create_perm = 'protect'; // B/C
 1439+ if( $title_protection ) {
 1440+ if( $title_protection['pt_create_perm'] == 'sysop' ) {
 1441+ $title_protection['pt_create_perm'] = 'protect'; // B/C
14441442 }
1445 - if( $pt_create_perm == '' || !$user->isAllowed($pt_create_perm) ) {
1446 - $errors[] = array( 'titleprotected', User::whoIs($pt_user), $pt_reason );
 1443+ if( $title_protection['pt_create_perm'] == '' || !$user->isAllowed($title_proection['pt_create_perm']) ) {
 1444+ $errors[] = array( 'titleprotected', User::whoIs($title_protection['pt_user']), $title_protection['pt_reason'] );
14471445 }
14481446 }
14491447 } elseif( $action == 'move' ) {
@@ -2081,16 +2079,14 @@
20822080 } else {
20832081 $title_protection = $this->getTitleProtection();
20842082
2085 - if (is_array($title_protection)) {
2086 - extract($title_protection);
2087 -
 2083+ if ($title_protection) {
20882084 $now = wfTimestampNow();
2089 - $expiry = Block::decodeExpiry($pt_expiry);
 2085+ $expiry = Block::decodeExpiry($title_protection['pt_expiry']);
20902086
20912087 if (!$expiry || $expiry > $now) {
20922088 // Apply the restrictions
20932089 $this->mRestrictionsExpiry['create'] = $expiry;
2094 - $this->mRestrictions['create'] = explode(',', trim($pt_create_perm) );
 2090+ $this->mRestrictions['create'] = explode(',', trim($title_protection['pt_create_perm']) );
20952091 } else { // Get rid of the old restrictions
20962092 Title::purgeExpiredRestrictions();
20972093 }

Status & tagging log