Addshore has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/392199 )

Change subject: DNM [MCR] fixes made in various Revision* files to pass tests
......................................................................

DNM [MCR] fixes made in various Revision* files to pass tests

DO NOT MERGE!!!

This is simply to provide easy access to the things
changed in order to make tests pass.

Change-Id: If6065c740b5ee2fbfe6f5f9997fca7bd0a3dd905
---
M includes/Storage/RevisionArchiveRecord.php
M includes/Storage/RevisionRecord.php
M includes/Storage/RevisionStore.php
M includes/Storage/RevisionStoreRecord.php
4 files changed, 14 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/99/392199/1

diff --git a/includes/Storage/RevisionArchiveRecord.php 
b/includes/Storage/RevisionArchiveRecord.php
index 0c3864b..c3bcace 100644
--- a/includes/Storage/RevisionArchiveRecord.php
+++ b/includes/Storage/RevisionArchiveRecord.php
@@ -73,7 +73,8 @@
                // with the same title. Archive rows for that title will then 
have the wrong page id.
                $this->mPageId = isset( $row->ar_page_id ) ? intval( 
$row->ar_page_id ) : $title->getArticleID();
 
-               $this->mParentId = isset( $row->ar_parent_id ) ? intval( 
$row->ar_parent_id ) : null;
+               $this->mParentId = isset( $row->ar_parent_id ) && 
$row->ar_parent_id != 0
+                       ? intval( $row->ar_parent_id ) : null;
                $this->mId = isset( $row->ar_rev_id ) ? intval( $row->ar_rev_id 
) : null;
                $this->mComment = $comment;
                $this->mUser = $user;
diff --git a/includes/Storage/RevisionRecord.php 
b/includes/Storage/RevisionRecord.php
index 58522ce..d244d9a 100644
--- a/includes/Storage/RevisionRecord.php
+++ b/includes/Storage/RevisionRecord.php
@@ -74,7 +74,7 @@
        protected $mSize;
        /** @var string|null */
        protected $mSha1;
-       /** @var int */
+       /** @var int|null */
        protected $mParentId;
        /** @var CommentStoreComment|null */
        protected $mComment;
diff --git a/includes/Storage/RevisionStore.php 
b/includes/Storage/RevisionStore.php
index aa6d30f..2cbb3a2 100644
--- a/includes/Storage/RevisionStore.php
+++ b/includes/Storage/RevisionStore.php
@@ -224,7 +224,7 @@
        private function failOnNull( $value, $name ) {
                if ( $value === null ) {
                        throw new IncompleteRevisionException(
-                               "$name must not be null!"
+                               "$name must not be " . var_export( null, true ) 
. "!"
                        );
                }
 
@@ -236,7 +236,7 @@
         * @param string $name
         *
         * @throw IncompleteRevisionException if $value is null
-        * @return mixed $value, if $value is not null
+        * @return mixed $value, if $value is not empty
         */
        private function failOnEmpty( $value, $name ) {
                if ( $value === null || $value === 0 || $value === '' ) {
@@ -323,6 +323,7 @@
                $blobAddress = 'tt:' . $textId;
 
                $comment = $this->failOnNull( $rev->getComment(), 'comment' );
+               $user = $this->failOnNull( $rev->getUser(), 'user' );
                $timestamp = $this->failOnEmpty( $rev->getTimestamp(), 
'timestamp field' );
 
                # Record the edit in revisions
@@ -331,8 +332,8 @@
                        'rev_parent_id'  => $parentId,
                        'rev_text_id'    => $textId,
                        'rev_minor_edit' => $rev->isMinor() ? 1 : 0,
-                       'rev_user'       => $this->failOnNull( 
$rev->getUser()->getId(), 'user field' ),
-                       'rev_user_text'  => $this->failOnEmpty( 
$rev->getUser()->getName(), 'user_text field' ),
+                       'rev_user'       => $rev->getUser()->getId(),
+                       'rev_user_text'  => $rev->getUser()->getName(),
                        'rev_timestamp'  => $dbw->timestamp( $timestamp ),
                        'rev_deleted'    => $rev->getVisibility(),
                        'rev_len'        => $size,
@@ -988,8 +989,8 @@
         * @return UserIdentityValue
         */
        private function getUserIdentityFromRowObject( $row, $prefix = 'rev_' ) 
{
-               $idField = "{$prefix}_user";
-               $nameField = "{$prefix}_user_text";
+               $idField = "{$prefix}user";
+               $nameField = "{$prefix}user_text";
 
                $userId = intval( $row->$idField );
 
@@ -1160,6 +1161,7 @@
                }
 
                $mainSlot = $this->emulateMainSlot_1_29( $fields, $queryFlags, 
$title );
+
 
                $revision = new MutableRevisionRecord( $title, $this->wikiId );
                $this->initializeMutableRevisionFromArray( $revision, $fields );
@@ -1730,7 +1732,7 @@
                        __METHOD__
                );
                if ( $row ) {
-                       return $row->revCount;
+                       return (int)$row->revCount;
                }
                return 0;
        }
diff --git a/includes/Storage/RevisionStoreRecord.php 
b/includes/Storage/RevisionStoreRecord.php
index 0386ab8..04a687e 100644
--- a/includes/Storage/RevisionStoreRecord.php
+++ b/includes/Storage/RevisionStoreRecord.php
@@ -75,8 +75,8 @@
                $this->mTimestamp = $timestamp;
                $this->mDeleted = intval( $row->rev_deleted );
 
-               if ( !isset( $row->rev_parent_id ) ) {
-                       $this->mParentId = 0;
+               if ( !isset( $row->rev_parent_id ) || $row->rev_parent_id == 0 
) {
+                       $this->mParentId = null;
                } else {
                        $this->mParentId = intval( $row->rev_parent_id );
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/392199
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If6065c740b5ee2fbfe6f5f9997fca7bd0a3dd905
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to