Merge "Followup I888c616e: one more string to localize."
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 31 Jan 2013 20:39:27 +0000 (20:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 31 Jan 2013 20:39:27 +0000 (20:39 +0000)
1  2 
includes/WikiPage.php

diff --combined includes/WikiPage.php
@@@ -229,8 -229,8 +229,8 @@@ class WikiPage extends Page implements 
         */
        protected function clearCacheFields() {
                $this->mCounter = null;
 -              $this->mRedirectTarget = null; # Title object if set
 -              $this->mLastRevision = null; # Latest revision
 +              $this->mRedirectTarget = null; // Title object if set
 +              $this->mLastRevision = null; // Latest revision
                $this->mTouched = '19700101000000';
                $this->mTimestamp = '';
                $this->mIsRedirect = false;
                        $data = $this->pageDataFromTitle( wfGetDB( DB_MASTER ), $this->mTitle );
                } elseif ( $from === self::READ_NORMAL ) {
                        $data = $this->pageDataFromTitle( wfGetDB( DB_SLAVE ), $this->mTitle );
 -                      # Use a "last rev inserted" timestamp key to dimish the issue of slave lag.
 -                      # Note that DB also stores the master position in the session and checks it.
 +                      // Use a "last rev inserted" timestamp key to dimish the issue of slave lag.
 +                      // Note that DB also stores the master position in the session and checks it.
                        $touched = $this->getCachedLastEditTime();
                        if ( $touched ) { // key set
                                if ( !$data || $touched > wfTimestamp( TS_MW, $data->page_touched ) ) {
  
                        $this->mTitle->loadFromRow( $data );
  
 -                      # Old-fashioned restrictions
 +                      // Old-fashioned restrictions
                        $this->mTitle->loadRestrictions( $data->page_restrictions );
  
                        $this->mCounter     = intval( $data->page_counter );
         */
        public function getContentModel() {
                if ( $this->exists() ) {
 -                      # look at the revision's actual content model
 +                      // look at the revision's actual content model
                        $rev = $this->getRevision();
  
                        if ( $rev !== null ) {
                        }
                }
  
 -              # use the default model for this page
 +              // use the default model for this page
                return $this->mTitle->getContentModel();
        }
  
         * @return String|false The text of the current revision
         * @deprecated as of 1.21, getContent() should be used instead.
         */
 -      public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { #@todo: deprecated, replace usage!
 +      public function getText( $audience = Revision::FOR_PUBLIC, User $user = null ) { // @todo: deprecated, replace usage!
                ContentHandler::deprecated( __METHOD__, '1.21' );
  
                $this->loadLastEdit();
                $hasLinks = null;
  
                if ( $wgArticleCountMethod === 'link' ) {
 -                      # nasty special case to avoid re-parsing to detect links
 +                      // nasty special case to avoid re-parsing to detect links
  
                        if ( $editInfo ) {
                                // ParserOutput::getLinks() is a 2D array of page links, so
                        return $this->mRedirectTarget;
                }
  
 -              # Query the redirect table
 +              // Query the redirect table
                $dbr = wfGetDB( DB_SLAVE );
                $row = $dbr->selectRow( 'redirect',
                        array( 'rd_namespace', 'rd_title', 'rd_fragment', 'rd_interwiki' ),
                                $row->rd_fragment, $row->rd_interwiki );
                }
  
 -              # This page doesn't have an entry in the redirect table
 +              // This page doesn't have an entry in the redirect table
                return $this->mRedirectTarget = $this->insertRedirect();
        }
  
         * @return UserArrayFromResult
         */
        public function getContributors() {
 -              # @todo FIXME: This is expensive; cache this info somewhere.
 +              // @todo FIXME: This is expensive; cache this info somewhere.
  
                $dbr = wfGetDB( DB_SLAVE );
  
                        return;
                }
  
 -              # Don't update page view counters on views from bot users (bug 14044)
 +              // Don't update page view counters on views from bot users (bug 14044)
                if ( !$wgDisableCounters && !$user->isAllowed( 'bot' ) && $this->mTitle->exists() ) {
                        DeferredUpdates::addUpdate( new ViewCountUpdate( $this->getId() ) );
                        DeferredUpdates::addUpdate( new SiteStatsUpdate( 1, 0, 0 ) );
                }
  
 -              # Update newtalk / watchlist notification status
 +              // Update newtalk / watchlist notification status
                $user->clearNotification( $this->mTitle );
        }
  
        public function doPurge() {
                global $wgUseSquid;
  
 -              if( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ){
 +              if( !wfRunHooks( 'ArticlePurge', array( &$this ) ) ) {
                        return false;
                }
  
                }
  
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 -                      //@todo: move this logic to MessageCache
 +                      // @todo: move this logic to MessageCache
  
                        if ( $this->mTitle->exists() ) {
                                // NOTE: use transclusion text for messages.
                        'page_title'        => $this->mTitle->getDBkey(),
                        'page_counter'      => 0,
                        'page_restrictions' => '',
 -                      'page_is_redirect'  => 0, # Will set this shortly...
 +                      'page_is_redirect'  => 0, // Will set this shortly...
                        'page_is_new'       => 1,
                        'page_random'       => wfRandom(),
                        'page_touched'      => $dbw->timestamp(),
 -                      'page_latest'       => 0, # Fill this in shortly...
 -                      'page_len'          => 0, # Fill this in shortly...
 +                      'page_latest'       => 0, // Fill this in shortly...
 +                      'page_len'          => 0, // Fill this in shortly...
                ), __METHOD__, 'IGNORE' );
  
                $affected = $dbw->affectedRows();
                $conditions = array( 'page_id' => $this->getId() );
  
                if ( !is_null( $lastRevision ) ) {
 -                      # An extra check against threads stepping on each other
 +                      // An extra check against threads stepping on each other
                        $conditions['page_latest'] = $lastRevision;
                }
  
                        $this->setCachedLastEditTime( $now );
                        $this->mLatest = $revision->getId();
                        $this->mIsRedirect = (bool)$rt;
 -                      # Update the LinkCache.
 +                      // Update the LinkCache.
                        LinkCache::singleton()->addGoodLinkObj( $this->getId(), $this->mTitle, $len, $this->mIsRedirect,
                                                                                                        $this->mLatest, $revision->getContentModel() );
                }
                        $prev = $row->rev_id;
                        $lastRevIsRedirect = (bool)$row->page_is_redirect;
                } else {
 -                      # No or missing previous revision; mark the page as new
 +                      // No or missing previous revision; mark the page as new
                        $prev = 0;
                        $lastRevIsRedirect = null;
                }
                        throw new MWException( "sections not supported for content model " . $this->getContentHandler()->getModelID() );
                }
  
 -              # could even make section title, but that's not required.
 +              // could even make section title, but that's not required.
                $sectionContent = ContentHandler::makeContent( $text, $this->getTitle() );
  
                $newContent = $this->replaceSectionContent( $section, $sectionContent, $sectionTitle, $edittime );
                                return null;
                        }
  
 -                      //FIXME: $oldContent might be null?
 +                      // FIXME: $oldContent might be null?
                        $newContent = $oldContent->replaceSection( $section, $sectionContent, $sectionTitle );
                }
  
                                                                   User $user = null, $serialisation_format = null ) {
                global $wgUser, $wgUseAutomaticEditSummaries, $wgUseRCPatrol, $wgUseNPPatrol;
  
 -              # Low-level sanity check
 +              // Low-level sanity check
                if ( $this->mTitle->getText() === '' ) {
                        throw new MWException( 'Something is trying to edit an article with an empty title' );
                }
  
                $flags = $this->checkFlags( $flags );
  
 -              # handle hook
 +              // handle hook
                $hook_args = array( &$this, &$user, &$content, &$summary,
                                                        $flags & EDIT_MINOR, null, null, &$flags, &$status );
  
                        return $status;
                }
  
 -              # Silently ignore EDIT_MINOR if not allowed
 +              // Silently ignore EDIT_MINOR if not allowed
                $isminor = ( $flags & EDIT_MINOR ) && $user->isAllowed( 'minoredit' );
                $bot = $flags & EDIT_FORCE_BOT;
  
  
                $handler = $content->getContentHandler();
  
 -              # Provide autosummaries if one is not provided and autosummaries are enabled.
 +              // Provide autosummaries if one is not provided and autosummaries are enabled.
                if ( $wgUseAutomaticEditSummaries && $flags & EDIT_AUTOSUMMARY && $summary == '' ) {
                        if ( !$old_content ) $old_content = null;
                        $summary = $handler->getAutosummary( $old_content, $content, $flags );
                $this->mTimestamp = $now;
  
                if ( $flags & EDIT_UPDATE ) {
 -                      # Update article, but only if changed.
 +                      // Update article, but only if changed.
                        $status->value['new'] = false;
  
                        if ( !$oldid ) {
 -                              # Article gone missing
 +                              // Article gone missing
                                wfDebug( __METHOD__ . ": EDIT_UPDATE specified but article doesn't exist\n" );
                                $status->fatal( 'edit-gone-missing' );
  
                                wfProfileOut( __METHOD__ );
                                return $status;
                        } elseif ( !$old_content ) {
 -                              # Sanity check for bug 37225
 +                              // Sanity check for bug 37225
                                wfProfileOut( __METHOD__ );
                                throw new MWException( "Could not find text for current revision {$oldid}." );
                        }
                                'timestamp'  => $now,
                                'content_model' => $content->getModel(),
                                'content_format' => $serialisation_format,
 -                      ) ); #XXX: pass content object?!
 +                      ) ); // XXX: pass content object?!
  
                        $changed = !$content->equals( $old_content );
  
  
                                $revisionId = $revision->insertOn( $dbw );
  
 -                              # Update page
 -                              #
 -                              # Note that we use $this->mLatest instead of fetching a value from the master DB
 -                              # during the course of this function. This makes sure that EditPage can detect
 -                              # edit conflicts reliably, either by $ok here, or by $article->getTimestamp()
 -                              # before this function is called. A previous function used a separate query, this
 -                              # creates a window where concurrent edits can cause an ignored edit conflict.
 +                              // Update page
 +                              //
 +                              // Note that we use $this->mLatest instead of fetching a value from the master DB
 +                              // during the course of this function. This makes sure that EditPage can detect
 +                              // edit conflicts reliably, either by $ok here, or by $article->getTimestamp()
 +                              // before this function is called. A previous function used a separate query, this
 +                              // creates a window where concurrent edits can cause an ignored edit conflict.
                                $ok = $this->updateRevisionOn( $dbw, $revision, $oldid, $oldIsRedirect );
  
                                if ( !$ok ) {
 -                                      # Belated edit conflict! Run away!!
 +                                      // Belated edit conflict! Run away!!
                                        $status->fatal( 'edit-conflict' );
  
                                        $dbw->rollback( __METHOD__ );
                                }
  
                                wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, $baseRevId, $user ) );
 -                              # Update recentchanges
 +                              // Update recentchanges
                                if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
 -                                      # Mark as patrolled if the user can do so
 +                                      // Mark as patrolled if the user can do so
                                        $patrolled = $wgUseRCPatrol && !count(
                                                $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
 -                                      # Add RC row to the DB
 +                                      // Add RC row to the DB
                                        $rc = RecentChange::notifyEdit( $now, $this->mTitle, $isminor, $user, $summary,
                                                $oldid, $this->getTimestamp(), $bot, '', $oldsize, $newsize,
                                                $revisionId, $patrolled
                                        );
  
 -                                      # Log auto-patrolled edits
 +                                      // Log auto-patrolled edits
                                        if ( $patrolled ) {
                                                PatrolLog::record( $rc, true, $user );
                                        }
                                $revision->setId( $this->getLatest() );
                        }
  
 -                      # Update links tables, site stats, etc.
 +                      // Update links tables, site stats, etc.
                        $this->doEditUpdates(
                                $revision,
                                $user,
                                $this->mTitle->invalidateCache();
                        }
                } else {
 -                      # Create new article
 +                      // Create new article
                        $status->value['new'] = true;
  
                        $dbw->begin( __METHOD__ );
  
                        $status->merge( $prepStatus );
  
 -                      # Add the page record; stake our claim on this title!
 -                      # This will return false if the article already exists
 +                      // Add the page record; stake our claim on this title!
 +                      // This will return false if the article already exists
                        $newid = $this->insertOn( $dbw );
  
                        if ( $newid === false ) {
                                return $status;
                        }
  
 -                      # Save the revision text...
 +                      // Save the revision text...
                        $revision = new Revision( array(
                                'page'       => $newid,
                                'title'      => $this->getTitle(), // for determining the default content model
                        ) );
                        $revisionId = $revision->insertOn( $dbw );
  
 -                      # Bug 37225: use accessor to get the text as Revision may trim it
 +                      // Bug 37225: use accessor to get the text as Revision may trim it
                        $content = $revision->getContent(); // sanity; get normalized version
  
                        if ( $content ) {
                                $newsize = $content->getSize();
                        }
  
 -                      # Update the page record with revision data
 +                      // Update the page record with revision data
                        $this->updateRevisionOn( $dbw, $revision, 0 );
  
                        wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $revision, false, $user ) );
  
 -                      # Update recentchanges
 +                      // Update recentchanges
                        if ( !( $flags & EDIT_SUPPRESS_RC ) ) {
 -                              # Mark as patrolled if the user can do so
 +                              // Mark as patrolled if the user can do so
                                $patrolled = ( $wgUseRCPatrol || $wgUseNPPatrol ) && !count(
                                        $this->mTitle->getUserPermissionsErrors( 'autopatrol', $user ) );
 -                              # Add RC row to the DB
 +                              // Add RC row to the DB
                                $rc = RecentChange::notifyNew( $now, $this->mTitle, $isminor, $user, $summary, $bot,
                                        '', $newsize, $revisionId, $patrolled );
  
 -                              # Log auto-patrolled edits
 +                              // Log auto-patrolled edits
                                if ( $patrolled ) {
                                        PatrolLog::record( $rc, true, $user );
                                }
                        $user->incEditCount();
                        $dbw->commit( __METHOD__ );
  
 -                      # Update links, etc.
 +                      // Update links, etc.
                        $this->doEditUpdates( $revision, $user, array( 'created' => true ) );
  
                        $hook_args = array( &$this, &$user, $content, $summary,
                        wfRunHooks( 'PageContentInsertComplete', $hook_args );
                }
  
 -              # Do updates right now unless deferral was requested
 +              // Do updates right now unless deferral was requested
                if ( !( $flags & EDIT_DEFER_UPDATES ) ) {
                        DeferredUpdates::doUpdates();
                }
                ContentHandler::runLegacyHooks( 'ArticleSaveComplete', $hook_args );
                wfRunHooks( 'PageContentSaveComplete', $hook_args );
  
 -              # Promote user to any groups they meet the criteria for
 +              // Promote user to any groups they meet the criteria for
                $user->addAutopromoteOnceGroups( 'onEdit' );
  
                wfProfileOut( __METHOD__ );
        public function prepareTextForEdit( $text, $revid = null, User $user = null ) {
                ContentHandler::deprecated( __METHOD__, '1.21' );
                $content = ContentHandler::makeContent( $text, $this->getTitle() );
 -              return $this->prepareContentForEdit( $content, $revid , $user );
 +              return $this->prepareContentForEdit( $content, $revid, $user );
        }
  
        /**
                        && $this->mPreparedEdit->newContent->equals( $content )
                        && $this->mPreparedEdit->revid == $revid
                        && $this->mPreparedEdit->format == $serialization_format
 -                      #XXX: also check $user here?
 +                      // XXX: also check $user here?
                ) {
                        // Already prepared
                        return $this->mPreparedEdit;
                $edit->newContent = $content;
                $edit->oldContent = $this->getContent( Revision::RAW );
  
 -              #NOTE: B/C for hooks! don't use these fields!
 +              // NOTE: B/C for hooks! don't use these fields!
                $edit->newText = $edit->newContent ? ContentHandler::getContentText( $edit->newContent ) : '';
                $edit->oldText = $edit->oldContent ? ContentHandler::getContentText( $edit->oldContent ) : '';
                $edit->pst = $edit->pstContent ? $edit->pstContent->serialize( $serialization_format ) : '';
                $options += array( 'changed' => true, 'created' => false, 'oldcountable' => null );
                $content = $revision->getContent();
  
 -              # Parse the text
 -              # Be careful not to double-PST: $text is usually already PST-ed once
 +              // Parse the text
 +              // Be careful not to double-PST: $text is usually already PST-ed once
                if ( !$this->mPreparedEdit || $this->mPreparedEdit->output->getFlag( 'vary-revision' ) ) {
                        wfDebug( __METHOD__ . ": No prepared edit or vary-revision is set...\n" );
                        $editInfo = $this->prepareContentForEdit( $content, $revision->getId(), $user );
                        $editInfo = $this->mPreparedEdit;
                }
  
 -              # Save it to the parser cache
 +              // Save it to the parser cache
                if ( $wgEnableParserCache ) {
                        $parserCache = ParserCache::singleton();
                        $parserCache->save( $editInfo->output, $this, $editInfo->popts );
                }
  
 -              # Update the links tables and other secondary data
 +              // Update the links tables and other secondary data
                if ( $content ) {
                        $updates = $content->getSecondaryDataUpdates( $this->getTitle(), null, true, $editInfo->output );
                        DataUpdate::runUpdates( $updates );
                                $cutoff = $dbw->timestamp( time() - $wgRCMaxAge );
                                $dbw->delete(
                                        'recentchanges',
 -                                      array( "rc_timestamp < '$cutoff'" ),
 +                                      array( 'rc_timestamp < ' . $dbw->addQuotes( $cutoff ) ),
                                        __METHOD__
                                );
                        }
  
                DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
                DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content->getTextForSearchIndex() ) );
 -              #@TODO: let the search engine decide what to do with the content object
 +              // @TODO: let the search engine decide what to do with the content object
  
 -              # If this is another user's talk page, update newtalk.
 -              # Don't do this if $options['changed'] = false (null-edits) nor if
 -              # it's a minor edit and the user doesn't want notifications for those.
 +              // If this is another user's talk page, update newtalk.
 +              // Don't do this if $options['changed'] = false (null-edits) nor if
 +              // it's a minor edit and the user doesn't want notifications for those.
                if ( $options['changed']
                        && $this->mTitle->getNamespace() == NS_USER_TALK
                        && $shortTitle != $user->getTitleKey()
                }
  
                if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 -                      #XXX: could skip pseudo-messages like js/css here, based on content model.
 +                      // XXX: could skip pseudo-messages like js/css here, based on content model.
                        $msgtext = $content ? $content->getWikitextForTransclusion() : null;
                        if ( $msgtext === false || $msgtext === null ) $msgtext = '';
  
                ContentHandler::deprecated( __METHOD__, "1.21" );
  
                $content = ContentHandler::makeContent( $text, $this->getTitle() );
 -              return $this->doQuickEditContent( $content, $user, $comment , $minor );
 +              return $this->doQuickEditContent( $content, $user, $comment, $minor );
        }
  
        /**
                        'length'     => $content->getSize(),
                        'comment'    => $comment,
                        'minor_edit' => $minor ? 1 : 0,
 -              ) ); #XXX: set the content object?
 +              ) ); // XXX: set the content object?
                $revision->insertOn( $dbw );
                $this->updateRevisionOn( $dbw, $revision );
  
                // Take this opportunity to purge out expired restrictions
                Title::purgeExpiredRestrictions();
  
 -              # @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
 -              # we expect a single selection, but the schema allows otherwise.
 +              // @todo FIXME: Same limitations as described in ProtectionForm.php (line 37);
 +              // we expect a single selection, but the schema allows otherwise.
                $isProtected = false;
                $protect = false;
                $changed = false;
                                $protect = true;
                        }
  
 -                      # Get current restrictions on $action
 +                      // Get current restrictions on $action
                        $current = implode( '', $this->mTitle->getRestrictions( $action ) );
                        if ( $current != '' ) {
                                $isProtected = true;
                        if ( $limit[$action] != $current ) {
                                $changed = true;
                        } elseif ( $limit[$action] != '' ) {
 -                              # Only check expiry change if the action is actually being
 -                              # protected, since expiry does nothing on an not-protected
 -                              # action.
 +                              // Only check expiry change if the action is actually being
 +                              // protected, since expiry does nothing on an not-protected
 +                              // action.
                                if ( $this->mTitle->getRestrictionExpiry( $action ) != $expiry[$action] ) {
                                        $changed = true;
                                }
                        $changed = true;
                }
  
 -              # If nothing's changed, do nothing
 +              // If nothing's changed, do nothing
                if ( !$changed ) {
                        return Status::newGood();
                }
  
 -              if ( !$protect ) { # No protection at all means unprotection
 +              if ( !$protect ) { // No protection at all means unprotection
                        $revCommentMsg = 'unprotectedarticle';
                        $logAction = 'unprotect';
                } elseif ( $isProtected ) {
  
                $encodedExpiry = array();
                $protectDescription = '';
 +              # Some bots may parse IRC lines, which are generated from log entries which contain plain
 +              # protect description text. Keep them in old format to avoid breaking compatibility.
 +              # TODO: Fix protection log to store structured description and format it on-the-fly.
 +              $protectDescriptionLog = '';
                foreach ( $limit as $action => $restrictions ) {
                        $encodedExpiry[$action] = $dbw->encodeExpiry( $expiry[$action] );
                        if ( $restrictions != '' ) {
 +                              $protectDescriptionLog .= $wgContLang->getDirMark() . "[$action=$restrictions] (";
                                # $action is one of $wgRestrictionTypes = array( 'create', 'edit', 'move', 'upload' ).
                                # All possible message keys are listed here for easier grepping:
                                # * restriction-create
                                if ( $encodedExpiry[$action] != 'infinity' ) {
                                        $expiryText = wfMessage(
                                                'protect-expiring',
 -                                              $wgContLang->timeanddate( $expiry[$action], false, false ) ,
 -                                              $wgContLang->date( $expiry[$action], false, false ) ,
 +                                              $wgContLang->timeanddate( $expiry[$action], false, false ),
 +                                              $wgContLang->date( $expiry[$action], false, false ),
                                                $wgContLang->time( $expiry[$action], false, false )
                                        )->inContentLanguage()->text();
                                } else {
                                $protectDescription .= wfMessage( 'protect-summary-desc' )
                                        ->params( $actionText, $restrictionsText, $expiryText )
                                        ->inContentLanguage()->text();
 +                              $protectDescriptionLog .= $expiryText . ') ';
                        }
                }
 +              $protectDescriptionLog = trim( $protectDescriptionLog );
  
 -              if ( $id ) { # Protection of existing page
 +              if ( $id ) { // Protection of existing page
                        if ( !wfRunHooks( 'ArticleProtect', array( &$this, &$user, $limit, $reason ) ) ) {
                                return Status::newGood();
                        }
  
 -                      # Only restrictions with the 'protect' right can cascade...
 -                      # Otherwise, people who cannot normally protect can "protect" pages via transclusion
 +                      // Only restrictions with the 'protect' right can cascade...
 +                      // Otherwise, people who cannot normally protect can "protect" pages via transclusion
                        $editrestriction = isset( $limit['edit'] ) ? array( $limit['edit'] ) : $this->mTitle->getRestrictions( 'edit' );
  
 -                      # The schema allows multiple restrictions
 +                      // The schema allows multiple restrictions
                        if ( !in_array( 'protect', $editrestriction ) && !in_array( 'sysop', $editrestriction ) ) {
                                $cascade = false;
                        }
  
 -                      # Update restrictions table
 +                      // Update restrictions table
                        foreach ( $limit as $action => $restrictions ) {
                                if ( $restrictions != '' ) {
                                        $dbw->replace( 'page_restrictions', array( array( 'pr_page', 'pr_type' ) ),
                                }
                        }
  
 -                      # Prepare a null revision to be added to the history
 +                      // Prepare a null revision to be added to the history
                        $editComment = $wgContLang->ucfirst(
                                wfMessage(
                                        $revCommentMsg,
                                )->inContentLanguage()->text()
                        );
                        if ( $reason ) {
-                               $editComment .= ": $reason";
+                               $editComment .= wfMessage( 'colon-separator' )->inContentLanguage()->text() . $reason;
                        }
                        if ( $protectDescription ) {
                                $editComment .= wfMessage( 'word-separator' )->inContentLanguage()->text();
                                )->inContentLanguage()->text();
                        }
  
 -                      # Insert a null revision
 +                      // Insert a null revision
                        $nullRevision = Revision::newNullRevision( $dbw, $id, $editComment, true );
                        $nullRevId = $nullRevision->insertOn( $dbw );
  
                        $latest = $this->getLatest();
 -                      # Update page record
 +                      // Update page record
                        $dbw->update( 'page',
                                array( /* SET */
                                        'page_touched' => $dbw->timestamp(),
  
                        wfRunHooks( 'NewRevisionFromEditComplete', array( $this, $nullRevision, $latest, $user ) );
                        wfRunHooks( 'ArticleProtectComplete', array( &$this, &$user, $limit, $reason ) );
 -              } else { # Protection of non-existing page (also known as "title protection")
 -                      # Cascade protection is meaningless in this case
 +              } else { // Protection of non-existing page (also known as "title protection")
 +                      // Cascade protection is meaningless in this case
                        $cascade = false;
  
                        if ( $limit['create'] != '' ) {
                if ( $logAction == 'unprotect' ) {
                        $logParams = array();
                } else {
 -                      $logParams = array( $protectDescription, $cascade ? 'cascade' : '' );
 +                      $logParams = array( $protectDescriptionLog, $cascade ? 'cascade' : '' );
                }
  
 -              # Update the protection log
 +              // Update the protection log
                $log = new LogPage( 'protect' );
                $log->addEntry( $logAction, $this->mTitle, trim( $reason ), $logParams, $user );
  
                        ), __METHOD__
                );
  
 -              # Now that it's safely backed up, delete it
 +              // Now that it's safely backed up, delete it
                $dbw->delete( 'page', array( 'page_id' => $id ), __METHOD__ );
                $ok = ( $dbw->affectedRows() > 0 ); // getArticleID() uses slave, could be laggy
  
  
                $this->doDeleteUpdates( $id, $content );
  
 -              # Log the deletion, if the page was suppressed, log it at Oversight instead
 +              // Log the deletion, if the page was suppressed, log it at Oversight instead
                $logtype = $suppress ? 'suppress' : 'delete';
  
                $logEntry = new ManualLogEntry( $logtype, 'delete' );
         *        This may be needed because $this->getContent() may already return null when the page proper was deleted.
         */
        public function doDeleteUpdates( $id, Content $content = null ) {
 -              # update site status
 +              // update site status
                DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, - (int)$this->isCountable(), -1 ) );
  
 -              # remove secondary indexes, etc
 +              // remove secondary indexes, etc
                $updates = $this->getDeletionUpdates( $content );
                DataUpdate::runUpdates( $updates );
  
 -              # Clear caches
 +              // Clear caches
                WikiPage::onArticleDelete( $this->mTitle );
  
 -              # Reset this object
 +              // Reset this object
                $this->clear();
  
 -              # Clear the cached article id so the interface doesn't act like we exist
 +              // Clear the cached article id so the interface doesn't act like we exist
                $this->mTitle->resetArticleID( 0 );
        }
  
        ) {
                $resultDetails = null;
  
 -              # Check permissions
 +              // Check permissions
                $editErrors = $this->mTitle->getUserPermissionsErrors( 'edit', $user );
                $rollbackErrors = $this->mTitle->getUserPermissionsErrors( 'rollback', $user );
                $errors = array_merge( $editErrors, wfArrayDiff2( $rollbackErrors, $editErrors ) );
                        $errors[] = array( 'actionthrottledtext' );
                }
  
 -              # If there were errors, bail out now
 +              // If there were errors, bail out now
                if ( !empty( $errors ) ) {
                        return $errors;
                }
                        return array( array( 'readonlytext' ) );
                }
  
 -              # Get the last editor
 +              // Get the last editor
                $current = $this->getRevision();
                if ( is_null( $current ) ) {
 -                      # Something wrong... no page?
 +                      // Something wrong... no page?
                        return array( array( 'notanarticle' ) );
                }
  
                $from = str_replace( '_', ' ', $fromP );
 -              # User name given should match up with the top revision.
 -              # If the user was deleted then $from should be empty.
 +              // User name given should match up with the top revision.
 +              // If the user was deleted then $from should be empty.
                if ( $from != $current->getUserText() ) {
                        $resultDetails = array( 'current' => $current );
                        return array( array( 'alreadyrolled',
                        ) );
                }
  
 -              # Get the last edit not by this guy...
 -              # Note: these may not be public values
 +              // Get the last edit not by this guy...
 +              // Note: these may not be public values
                $user = intval( $current->getRawUser() );
                $user_text = $dbw->addQuotes( $current->getRawUserText() );
                $s = $dbw->selectRow( 'revision',
                                'ORDER BY' => 'rev_timestamp DESC' )
                        );
                if ( $s === false ) {
 -                      # No one else ever edited this page
 +                      // No one else ever edited this page
                        return array( array( 'cantrollback' ) );
                } elseif ( $s->rev_deleted & Revision::DELETED_TEXT || $s->rev_deleted & Revision::DELETED_USER ) {
 -                      # Only admins can see this text
 +                      // Only admins can see this text
                        return array( array( 'notvisiblerev' ) );
                }
  
                $set = array();
                if ( $bot && $guser->isAllowed( 'markbotedits' ) ) {
 -                      # Mark all reverted edits as bot
 +                      // Mark all reverted edits as bot
                        $set['rc_bot'] = 1;
                }
  
                if ( $wgUseRCPatrol ) {
 -                      # Mark all reverted edits as patrolled
 +                      // Mark all reverted edits as patrolled
                        $set['rc_patrolled'] = 1;
                }
  
                        );
                }
  
 -              # Generate the edit summary if necessary
 +              // Generate the edit summary if necessary
                $target = Revision::newFromId( $s->rev_id );
                if ( empty( $summary ) ) {
                        if ( $from == '' ) { // no public user name
                        }
                }
  
 -              # Allow the custom summary to use the same args as the default message
 +              // Allow the custom summary to use the same args as the default message
                $args = array(
                        $target->getUserText(), $from, $s->rev_id,
                        $wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ),
                        $summary = wfMsgReplaceArgs( $summary, $args );
                }
  
 -              # Truncate for whole multibyte characters.
 +              // Trim spaces on user supplied text
 +              $summary = trim( $summary );
 +
 +              // Truncate for whole multibyte characters.
                $summary = $wgContLang->truncate( $summary, 255 );
  
 -              # Save
 +              // Save
                $flags = EDIT_UPDATE;
  
                if ( $guser->isAllowed( 'minoredit' ) ) {
                        $flags |= EDIT_FORCE_BOT;
                }
  
 -              # Actually store the edit
 +              // Actually store the edit
                $status = $this->doEditContent( $target->getContent(), $summary, $flags, $target->getId(), $guser );
  
                if ( !$status->isOK() ) {
         * @param $title Title object
         */
        public static function onArticleCreate( $title ) {
 -              # Update existence markers on article/talk tabs...
 +              // Update existence markers on article/talk tabs...
                if ( $title->isTalkPage() ) {
                        $other = $title->getSubjectPage();
                } else {
         * @param $title Title
         */
        public static function onArticleDelete( $title ) {
 -              # Update existence markers on article/talk tabs...
 +              // Update existence markers on article/talk tabs...
                if ( $title->isTalkPage() ) {
                        $other = $title->getSubjectPage();
                } else {
                $title->touchLinks();
                $title->purgeSquid();
  
 -              # File cache
 +              // File cache
                HTMLFileCache::clearFileCache( $title );
  
 -              # Messages
 +              // Messages
                if ( $title->getNamespace() == NS_MEDIAWIKI ) {
                        MessageCache::singleton()->replace( $title->getDBkey(), false );
                }
  
 -              # Images
 +              // Images
                if ( $title->getNamespace() == NS_FILE ) {
                        $update = new HTMLCacheUpdate( $title, 'imagelinks' );
                        $update->doUpdate();
                }
  
 -              # User talk pages
 +              // User talk pages
                if ( $title->getNamespace() == NS_USER_TALK ) {
                        $user = User::newFromName( $title->getText(), false );
                        if ( $user ) {
                        }
                }
  
 -              # Image redirects
 +              // Image redirects
                RepoGroup::singleton()->getLocalRepo()->invalidateImageRedirect( $title );
        }
  
                // Invalidate caches of articles which include this page
                DeferredUpdates::addHTMLCacheUpdate( $title, 'templatelinks' );
  
 -
                // Invalidate the caches of all pages which redirect here
                DeferredUpdates::addHTMLCacheUpdate( $title, 'redirect' );
  
 -              # Purge squid for this page only
 +              // Purge squid for this page only
                $title->purgeSquid();
  
 -              # Clear file cache for this page only
 +              // Clear file cache for this page only
                HTMLFileCache::clearFileCache( $title );
        }
  
        * @deprecated since 1.21, use ContentHandler::getAutosummary() instead
        */
        public static function getAutosummary( $oldtext, $newtext, $flags ) {
 -              # NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
 +              // NOTE: stub for backwards-compatibility. assumes the given text is wikitext. will break horribly if it isn't.
  
                ContentHandler::deprecated( __METHOD__, '1.21' );
  
                $ns = $this->mTitle->getNamespace();
                $dbw = wfGetDB( DB_MASTER );
  
 -              # First make sure the rows exist.  If one of the "deleted" ones didn't
 -              # exist, we might legitimately not create it, but it's simpler to just
 -              # create it and then give it a negative value, since the value is bogus
 -              # anyway.
 -              #
 -              # Sometimes I wish we had INSERT ... ON DUPLICATE KEY UPDATE.
 +              // First make sure the rows exist.  If one of the "deleted" ones didn't
 +              // exist, we might legitimately not create it, but it's simpler to just
 +              // create it and then give it a negative value, since the value is bogus
 +              // anyway.
 +              //
 +              // Sometimes I wish we had INSERT ... ON DUPLICATE KEY UPDATE.
                $insertCats = array_merge( $added, $deleted );
                if ( !$insertCats ) {
 -                      # Okay, nothing to do
 +                      // Okay, nothing to do
                        return;
                }
  
                // that cascaded protections apply as soon as the changes
                // are visible.
  
 -              # Get templates from templatelinks
 +              // Get templates from templatelinks
                $id = $this->mTitle->getArticleID();
  
                $tlTemplates = array();
                        $tlTemplates["{$row->tl_namespace}:{$row->tl_title}"] = true;
                }
  
 -              # Get templates from parser output.
 +              // Get templates from parser output.
                $poTemplates = array();
                foreach ( $parserOutput->getTemplates() as $ns => $templates ) {
                        foreach ( $templates as $dbk => $id ) {
                        }
                }
  
 -              # Get the diff
 +              // Get the diff
                $templates_diff = array_diff_key( $poTemplates, $tlTemplates );
  
                if ( count( $templates_diff ) > 0 ) {
 -                      # Whee, link updates time.
 -                      # Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
 +                      // Whee, link updates time.
 +                      // Note: we are only interested in links here. We don't need to get other DataUpdate items from the parser output.
                        $u = new LinksUpdate( $this->mTitle, $parserOutput, false );
                        $u->doUpdate();
                }
@@@ -3315,7 -3306,7 +3315,7 @@@ class PoolWorkArticleView extends PoolC
         * @param $content Content|String: content to parse or null to load it; may also be given as a wikitext string, for BC
         */
        function __construct( Page $page, ParserOptions $parserOptions, $revid, $useParserCache, $content = null ) {
 -              if ( is_string($content) ) { #BC: old style call
 +              if ( is_string($content) ) { // BC: old style call
                        $modelId = $page->getRevision()->getContentModel();
                        $format = $page->getRevision()->getContentFormat();
                        $content = ContentHandler::makeContent( $content, $page->getTitle(), $modelId, $format );
                if ( $this->content !== null ) {
                        $content = $this->content;
                } elseif ( $isCurrent ) {
 -                      #XXX: why use RAW audience here, and PUBLIC (default) below?
 +                      // XXX: why use RAW audience here, and PUBLIC (default) below?
                        $content = $this->page->getContent( Revision::RAW );
                } else {
                        $rev = Revision::newFromTitle( $this->page->getTitle(), $this->revid );
                        if ( $rev === null ) {
                                $content = null;
                        } else {
 -                              #XXX: why use PUBLIC audience here (default), and RAW above?
 +                              // XXX: why use PUBLIC audience here (default), and RAW above?
                                $content = $rev->getContent();
                        }
                }
                $this->parserOutput = $content->getParserOutput( $this->page->getTitle(), $this->revid, $this->parserOptions );
                $time += microtime( true );
  
 -              # Timing hack
 +              // Timing hack
                if ( $time > 3 ) {
                        wfDebugLog( 'slow-parse', sprintf( "%-5.2f %s", $time,
                                $this->page->getTitle()->getPrefixedDBkey() ) );
                return false;
        }
  }
 -