merged master (2012-09-11)
[lhc/web/wiklou.git] / includes / WikiPage.php
index bde96cc..65ccc0b 100644 (file)
@@ -92,6 +92,7 @@ class WikiPage extends Page implements IDBAccessObject {
         * Create a WikiPage object of the appropriate class for the given title.
         *
         * @param $title Title
+        * @throws MWException
         * @return WikiPage object of the appropriate type
         */
        public static function factory( Title $title ) {
@@ -775,7 +776,7 @@ class WikiPage extends Page implements IDBAccessObject {
         * Determine whether a page would be suitable for being counted as an
         * article in the site_stats table based on the title & its content
         *
-        * @param $editInfo Object or false: object returned by prepareTextForEdit(),
+        * @param $editInfo Object|bool (false): object returned by prepareTextForEdit(),
         *        if false, the current database state will be used
         * @return Boolean
         */
@@ -1527,9 +1528,10 @@ class WikiPage extends Page implements IDBAccessObject {
         * edit-already-exists error will be returned. These two conditions are also possible with
         * auto-detection due to MediaWiki's performance-optimised locking strategy.
         *
-        * @param $baseRevId int the revision ID this edit was based off, if any
+        * @param bool|int $baseRevId int the revision ID this edit was based off, if any
         * @param $user User the user doing the edit
         *
+        * @throws MWException
         * @return Status object. Possible errors:
         *     edit-hook-aborted:       The ArticleSave hook aborted the edit but didn't set the fatal flag of $status
         *     edit-gone-missing:       In update mode, but the article didn't exist
@@ -1700,10 +1702,6 @@ class WikiPage extends Page implements IDBAccessObject {
                                'content_format' => $serialisation_format,
                        ) ); #XXX: pass content object?!
 
-                       # Bug 37225: use accessor to get the text as Revision may trim it.
-                       # After trimming, the text may be a duplicate of the current text.
-                       $content = $revision->getContent(); // sanity; EditPage should trim already
-
                        $changed = !$content->equals( $old_content );
 
                        if ( $changed ) {
@@ -2243,12 +2241,15 @@ class WikiPage extends Page implements IDBAccessObject {
                        if ( $restrictions != '' ) {
                                $protectDescription .= $wgContLang->getDirMark() . "[$action=$restrictions] (";
                                if ( $encodedExpiry[$action] != 'infinity' ) {
-                                       $protectDescription .= wfMsgForContent( 'protect-expiring',
+                                       $protectDescription .= wfMessage(
+                                               'protect-expiring',
                                                $wgContLang->timeanddate( $expiry[$action], false, false ) ,
                                                $wgContLang->date( $expiry[$action], false, false ) ,
-                                               $wgContLang->time( $expiry[$action], false, false ) );
+                                               $wgContLang->time( $expiry[$action], false, false )
+                                       )->inContentLanguage()->text();
                                } else {
-                                       $protectDescription .= wfMsgForContent( 'protect-expiry-indefinite' );
+                                       $protectDescription .= wfMessage( 'protect-expiry-indefinite' )
+                                               ->inContentLanguage()->text();
                                }
 
                                $protectDescription .= ') ';
@@ -2289,7 +2290,12 @@ class WikiPage extends Page implements IDBAccessObject {
                        }
 
                        # Prepare a null revision to be added to the history
-                       $editComment = $wgContLang->ucfirst( wfMsgForContent( $revCommentMsg, $this->mTitle->getPrefixedText() ) );
+                       $editComment = $wgContLang->ucfirst(
+                               wfMessage(
+                                       $revCommentMsg,
+                                       $this->mTitle->getPrefixedText()
+                               )->inContentLanguage()->text()
+                       );
                        if ( $reason ) {
                                $editComment .= ": $reason";
                        }
@@ -2297,7 +2303,9 @@ class WikiPage extends Page implements IDBAccessObject {
                                $editComment .= " ($protectDescription)";
                        }
                        if ( $cascade ) {
-                               $editComment .= ' [' . wfMsgForContent( 'protect-summary-cascade' ) . ']';
+                               // FIXME: Should use 'brackets' message.
+                               $editComment .= ' [' . wfMessage( 'protect-summary-cascade' )
+                                       ->inContentLanguage()->text() . ']';
                        }
 
                        # Insert a null revision
@@ -2364,6 +2372,7 @@ class WikiPage extends Page implements IDBAccessObject {
         * Take an array of page restrictions and flatten it to a string
         * suitable for insertion into the page_restrictions field.
         * @param $limit Array
+        * @throws MWException
         * @return String
         */
        protected static function flattenRestrictions( $limit ) {
@@ -2700,7 +2709,7 @@ class WikiPage extends Page implements IDBAccessObject {
                                array( /* WHERE */
                                        'rc_cur_id' => $current->getPage(),
                                        'rc_user_text' => $current->getUserText(),
-                                       "rc_timestamp > '{$s->rev_timestamp}'",
+                                       'rc_timestamp > ' . $dbw->addQuotes( $s->rev_timestamp ),
                                ), __METHOD__
                        );
                }
@@ -2709,9 +2718,9 @@ class WikiPage extends Page implements IDBAccessObject {
                $target = Revision::newFromId( $s->rev_id );
                if ( empty( $summary ) ) {
                        if ( $from == '' ) { // no public user name
-                               $summary = wfMsgForContent( 'revertpage-nouser' );
+                               $summary = wfMessage( 'revertpage-nouser' );
                        } else {
-                               $summary = wfMsgForContent( 'revertpage' );
+                               $summary = wfMessage( 'revertpage' );
                        }
                }
 
@@ -2721,7 +2730,14 @@ class WikiPage extends Page implements IDBAccessObject {
                        $wgContLang->timeanddate( wfTimestamp( TS_MW, $s->rev_timestamp ) ),
                        $current->getId(), $wgContLang->timeanddate( $current->getTimestamp() )
                );
-               $summary = wfMsgReplaceArgs( $summary, $args );
+               if( $summary instanceof Message ) {
+                       $summary = $summary->params( $args )->inContentLanguage()->text();
+               } else {
+                       $summary = wfMsgReplaceArgs( $summary, $args );
+               }
+
+               # Truncate for whole multibyte characters.
+               $summary = $wgContLang->truncate( $summary, 255 );
 
                # Save
                $flags = EDIT_UPDATE;
@@ -3147,6 +3163,7 @@ class WikiPage extends Page implements IDBAccessObject {
 
        /**
         * @deprecated since 1.18
+        * @param $oldid int
         * @return bool
         */
        public function useParserCache( $oldid ) {
@@ -3172,7 +3189,7 @@ class WikiPage extends Page implements IDBAccessObject {
                if ( !$content ) {
                        $updates = array();
                } else {
-                       $updates = $content->getDeletionUpdates( $this->mTitle );
+                       $updates = $content->getDeletionUpdates( $this );
                }
 
                wfRunHooks( 'WikiPageDeletionUpdates', array( $this, $content, &$updates ) );