Merge "Introduce ContentGetParserOutput hook"
[lhc/web/wiklou.git] / includes / WikiPage.php
index 8e15ac9..d53acd0 100644 (file)
@@ -2173,19 +2173,17 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( !$options['changed'] ) {
                        $good = 0;
-                       $total = 0;
                } elseif ( $options['created'] ) {
                        $good = (int)$this->isCountable( $editInfo );
-                       $total = 1;
                } elseif ( $options['oldcountable'] !== null ) {
                        $good = (int)$this->isCountable( $editInfo ) - (int)$options['oldcountable'];
-                       $total = 0;
                } else {
                        $good = 0;
-                       $total = 0;
                }
+               $edits = $options['changed'] ? 1 : 0;
+               $total = $options['created'] ? 1 : 0;
 
-               DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, 1, $good, $total ) );
+               DeferredUpdates::addUpdate( new SiteStatsUpdate( 0, $edits, $good, $total ) );
                DeferredUpdates::addUpdate( new SearchUpdate( $id, $title, $content ) );
 
                // If this is another user's talk page, update newtalk.
@@ -2226,7 +2224,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                if ( $options['created'] ) {
                        self::onArticleCreate( $this->mTitle );
-               } else {
+               } elseif ( $options['changed'] ) { // bug 50785
                        self::onArticleEdit( $this->mTitle );
                }
 
@@ -2274,6 +2272,8 @@ class WikiPage implements Page, IDBAccessObject {
                $revision = new Revision( array(
                        'title'      => $this->getTitle(), // for determining the default content model
                        'page'       => $this->getId(),
+                       'user_text'  => $user->getName(),
+                       'user'       => $user->getId(),
                        'text'       => $serialized,
                        'length'     => $content->getSize(),
                        'comment'    => $comment,
@@ -2407,7 +2407,7 @@ class WikiPage implements Page, IDBAccessObject {
 
                        // insert null revision to identify the page protection change as edit summary
                        $latest = $this->getLatest();
-                       $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason );
+                       $nullRevision = $this->insertProtectNullRevision( $revCommentMsg, $limit, $expiry, $cascade, $reason, $user );
                        if ( $nullRevision === null ) {
                                return Status::newFatal( 'no-null-revision', $this->mTitle->getPrefixedText() );
                        }
@@ -2506,9 +2506,10 @@ class WikiPage implements Page, IDBAccessObject {
         * @param array $expiry Per restriction type expiration
         * @param int $cascade Set to false if cascading protection isn't allowed.
         * @param string $reason
+        * @param User|null $user
         * @return Revision|null Null on error
         */
-       public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason ) {
+       public function insertProtectNullRevision( $revCommentMsg, array $limit, array $expiry, $cascade, $reason, $user = null ) {
                global $wgContLang;
                $dbw = wfGetDB( DB_MASTER );
 
@@ -2534,7 +2535,7 @@ class WikiPage implements Page, IDBAccessObject {
                        )->inContentLanguage()->text();
                }
 
-               $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true );
+               $nullRev = Revision::newNullRevision( $dbw, $this->getId(), $editComment, true, $user );
                if ( $nullRev ) {
                        $nullRev->insertOn( $dbw );