r54128 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54127‎ | r54128 | r54129 >
Date:22:57, 31 July 2009
Author:aaron
Status:ok
Tags:
Comment:
* Don't add title protect log if nothing was done (bug 20026)
* Spacing cleanup
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1426,7 +1426,8 @@
14271427
14281428 $expiry_description = '';
14291429 if ( $encodedExpiry != 'infinity' ) {
1430 - $expiry_description = ' (' . wfMsgForContent( 'protect-expiring', $wgContLang->timeanddate( $expiry ) , $wgContLang->date( $expiry ) , $wgContLang->time( $expiry ) ).')';
 1430+ $expiry_description = ' (' . wfMsgForContent( 'protect-expiring',$wgContLang->timeanddate( $expiry ),
 1431+ $wgContLang->date( $expiry ) , $wgContLang->time( $expiry ) ).')';
14311432 }
14321433 else {
14331434 $expiry_description .= ' (' . wfMsgForContent( 'protect-expiry-indefinite' ).')';
@@ -1435,23 +1436,30 @@
14361437 # Update protection table
14371438 if ($create_perm != '' ) {
14381439 $dbw->replace( 'protected_titles', array(array('pt_namespace', 'pt_title')),
1439 - array( 'pt_namespace' => $namespace, 'pt_title' => $title
1440 - , 'pt_create_perm' => $create_perm
1441 - , 'pt_timestamp' => Block::encodeExpiry(wfTimestampNow(), $dbw)
1442 - , 'pt_expiry' => $encodedExpiry
1443 - , 'pt_user' => $wgUser->getId(), 'pt_reason' => $reason ), __METHOD__ );
 1440+ array(
 1441+ 'pt_namespace' => $namespace,
 1442+ 'pt_title' => $title,
 1443+ 'pt_create_perm' => $create_perm,
 1444+ 'pt_timestamp' => Block::encodeExpiry(wfTimestampNow(), $dbw),
 1445+ 'pt_expiry' => $encodedExpiry,
 1446+ 'pt_user' => $wgUser->getId(),
 1447+ 'pt_reason' => $reason,
 1448+ ), __METHOD__
 1449+ );
14441450 } else {
14451451 $dbw->delete( 'protected_titles', array( 'pt_namespace' => $namespace,
14461452 'pt_title' => $title ), __METHOD__ );
14471453 }
14481454 # Update the protection log
1449 - $log = new LogPage( 'protect' );
 1455+ if( $dbw->affectedRows() ) {
 1456+ $log = new LogPage( 'protect' );
14501457
1451 - if( $create_perm ) {
1452 - $params = array("[create=$create_perm] $expiry_description",'');
1453 - $log->addEntry( ( isset( $this->mRestrictions['create'] ) && $this->mRestrictions['create'] ) ? 'modify' : 'protect', $this, trim( $reason ), $params );
1454 - } else {
1455 - $log->addEntry( 'unprotect', $this, $reason );
 1458+ if( $create_perm ) {
 1459+ $params = array("[create=$create_perm] $expiry_description",'');
 1460+ $log->addEntry( ( isset( $this->mRestrictions['create'] ) && $this->mRestrictions['create'] ) ? 'modify' : 'protect', $this, trim( $reason ), $params );
 1461+ } else {
 1462+ $log->addEntry( 'unprotect', $this, $reason );
 1463+ }
14561464 }
14571465
14581466 return true;

Status & tagging log