r41084 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41083‎ | r41084 | r41085 >
Date:02:53, 21 September 2008
Author:simetrical
Status:old
Tags:
Comment:
Whitespace/braces
Modified paths:
  • /trunk/phase3/includes/Article.php (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Article.php
@@ -1957,24 +1957,22 @@
19581958 * Auto-generates a deletion reason
19591959 * @param bool &$hasHistory Whether the page has a history
19601960 */
1961 - public function generateReason(&$hasHistory)
1962 - {
 1961+ public function generateReason( &$hasHistory ) {
19631962 global $wgContLang;
1964 - $dbw = wfGetDB(DB_MASTER);
 1963+ $dbw = wfGetDB( DB_MASTER );
19651964 // Get the last revision
1966 - $rev = Revision::newFromTitle($this->mTitle);
1967 - if(is_null($rev))
 1965+ $rev = Revision::newFromTitle( $this->mTitle );
 1966+ if( is_null( $rev ) )
19681967 return false;
 1968+
19691969 // Get the article's contents
19701970 $contents = $rev->getText();
19711971 $blank = false;
19721972 // If the page is blank, use the text from the previous revision,
19731973 // which can only be blank if there's a move/import/protect dummy revision involved
1974 - if($contents == '')
1975 - {
 1974+ if( $contents == '' ) {
19761975 $prev = $rev->getPrevious();
1977 - if($prev)
1978 - {
 1976+ if( $prev ) {
19791977 $contents = $prev->getText();
19801978 $blank = true;
19811979 }
@@ -1983,44 +1981,46 @@
19841982 // Find out if there was only one contributor
19851983 // Only scan the last 20 revisions
19861984 $limit = 20;
1987 - $res = $dbw->select('revision', 'rev_user_text', array('rev_page' => $this->getID()), __METHOD__,
1988 - array('LIMIT' => $limit));
1989 - if($res === false)
 1985+ $res = $dbw->select( 'revision', 'rev_user_text',
 1986+ array( 'rev_page' => $this->getID() ), __METHOD__,
 1987+ array( 'LIMIT' => $limit )
 1988+ );
 1989+ if( $res === false )
19901990 // This page has no revisions, which is very weird
19911991 return false;
1992 - if($res->numRows() > 1)
 1992+ if( $res->numRows() > 1 )
19931993 $hasHistory = true;
19941994 else
19951995 $hasHistory = false;
1996 - $row = $dbw->fetchObject($res);
 1996+ $row = $dbw->fetchObject( $res );
19971997 $onlyAuthor = $row->rev_user_text;
19981998 // Try to find a second contributor
19991999 foreach( $res as $row ) {
2000 - if($row->rev_user_text != $onlyAuthor) {
 2000+ if( $row->rev_user_text != $onlyAuthor ) {
20012001 $onlyAuthor = false;
20022002 break;
20032003 }
20042004 }
2005 - $dbw->freeResult($res);
 2005+ $dbw->freeResult( $res );
20062006
20072007 // Generate the summary with a '$1' placeholder
2008 - if($blank) {
 2008+ if( $blank ) {
20092009 // The current revision is blank and the one before is also
20102010 // blank. It's just not our lucky day
2011 - $reason = wfMsgForContent('exbeforeblank', '$1');
 2011+ $reason = wfMsgForContent( 'exbeforeblank', '$1' );
20122012 } else {
2013 - if($onlyAuthor)
2014 - $reason = wfMsgForContent('excontentauthor', '$1', $onlyAuthor);
 2013+ if( $onlyAuthor )
 2014+ $reason = wfMsgForContent( 'excontentauthor', '$1', $onlyAuthor );
20152015 else
2016 - $reason = wfMsgForContent('excontent', '$1');
 2016+ $reason = wfMsgForContent( 'excontent', '$1' );
20172017 }
20182018
20192019 // Replace newlines with spaces to prevent uglyness
2020 - $contents = preg_replace("/[\n\r]/", ' ', $contents);
 2020+ $contents = preg_replace( "/[\n\r]/", ' ', $contents );
20212021 // Calculate the maximum amount of chars to get
20222022 // Max content length = max comment length - length of the comment (excl. $1) - '...'
2023 - $maxLength = 255 - (strlen($reason) - 2) - 3;
2024 - $contents = $wgContLang->truncate($contents, $maxLength, '...');
 2023+ $maxLength = 255 - (strlen( $reason ) - 2) - 3;
 2024+ $contents = $wgContLang->truncate( $contents, $maxLength, '...' );
20252025 // Remove possible unfinished links
20262026 $contents = preg_replace( '/\[\[([^\]]*)\]?$/', '$1', $contents );
20272027 // Now replace the '$1' placeholder
Index: trunk/phase3/includes/EditPage.php
@@ -841,7 +841,6 @@
842842 # If article is new, insert it.
843843 $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
844844 if ( 0 == $aid ) {
845 -
846845 // Late check for create permission, just in case *PARANOIA*
847846 if ( !$this->mTitle->userCan( 'create' ) ) {
848847 wfDebug( "$fname: no create permission\n" );
@@ -851,8 +850,8 @@
852851
853852 # Don't save a new article if it's blank.
854853 if ( '' == $this->textbox1 ) {
855 - wfProfileOut( $fname );
856 - return self::AS_BLANK_ARTICLE;
 854+ wfProfileOut( $fname );
 855+ return self::AS_BLANK_ARTICLE;
857856 }
858857
859858 // Run post-section-merge edit filter