Daniel Kinzler has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/56384


Change subject: Make ChangeRow work with new ORMTable.
......................................................................

Make ChangeRow work with new ORMTable.

This is in preparation for core change I86368821.

Change-Id: I98a67ae7e5473528399954d2750ba82539826e9d
---
M lib/includes/ChangesTable.php
M lib/includes/changes/ChangeRow.php
M lib/includes/changes/DiffChange.php
M lib/includes/changes/EntityChange.php
4 files changed, 32 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/84/56384/1

diff --git a/lib/includes/ChangesTable.php b/lib/includes/ChangesTable.php
index 8c8aa58..54291cb 100644
--- a/lib/includes/ChangesTable.php
+++ b/lib/includes/ChangesTable.php
@@ -127,4 +127,26 @@
                return new $class( $this, $data, $loadDefaults );
        }
 
+       /**
+        * @see ORMTable::getWriteValues()
+        *
+        * @since 0.4
+        *
+        * @param \IORMRow $row
+        *
+        * @return array
+        */
+       protected function getWriteValues( \IORMRow $row ) {
+               $values = parent::getWriteValues( $row );
+
+               if ( $row instanceof ChangeRow ) {
+                       $infoField = $this->getPrefixedField( 'info' );
+
+                       if ( isset( $values[$infoField] ) ) {
+                               $values[$infoField] = $row->serializeInfo( 
$values[$infoField] );
+                       }
+               }
+
+               return $values;
+       }
 }
diff --git a/lib/includes/changes/ChangeRow.php 
b/lib/includes/changes/ChangeRow.php
index 3c243ef..58c05b2 100644
--- a/lib/includes/changes/ChangeRow.php
+++ b/lib/includes/changes/ChangeRow.php
@@ -166,6 +166,9 @@
        /**
         * @see ORMRow::getWriteValues()
         *
+        * @todo: remove this once core no longer uses ORMRow::getWriteValues().
+        *        Use ChangesTable::getWriteValues() instead.
+        *
         * @since 0.4
         *
         * @return array
@@ -190,9 +193,10 @@
         *
         * @param array $info
         *
+        * @throws \MWException
         * @return string
         */
-       protected function serializeInfo( array $info ) {
+       public function serializeInfo( array $info ) {
                if ( Settings::get( "changesAsJson" ) === true ) {
                        // Make sure we never serialize objects.
                        // This is a lot of overhead, so we only do it during 
testing.
@@ -227,7 +231,7 @@
         *
         * @return array the info array
         */
-       protected function unserializeInfo( $str ) {
+       public function unserializeInfo( $str ) {
                if ( $str[0] === '{' ) { // json
                        $info = json_decode( $str, true );
                } else {
diff --git a/lib/includes/changes/DiffChange.php 
b/lib/includes/changes/DiffChange.php
index c59266c..3a6d46f 100644
--- a/lib/includes/changes/DiffChange.php
+++ b/lib/includes/changes/DiffChange.php
@@ -121,7 +121,7 @@
         * @param array $info
         * @return string
         */
-       protected function serializeInfo( array $info ) {
+       public function serializeInfo( array $info ) {
                if ( isset( $info['diff'] ) && $info['diff'] instanceof 
\Diff\DiffOp ) {
                        if ( Settings::get( "changesAsJson" ) === true  ) {
                                /* @var \Diff\DiffOp $op */
@@ -142,7 +142,7 @@
         * @param string $str
         * @return array the info array
         */
-       protected function unserializeInfo( $str ) {
+       public function unserializeInfo( $str ) {
                static $factory = null;
 
                if ( $factory == null ) {
diff --git a/lib/includes/changes/EntityChange.php 
b/lib/includes/changes/EntityChange.php
index 8059173..c12acc9 100644
--- a/lib/includes/changes/EntityChange.php
+++ b/lib/includes/changes/EntityChange.php
@@ -405,6 +405,7 @@
 
                return $data;
        }
+
        /**
         * @see ChangeRow::serializeInfo()
         *
@@ -414,7 +415,7 @@
         * @param array $info
         * @return string
         */
-       protected function serializeInfo( array $info ) {
+       public function serializeInfo( array $info ) {
                if ( isset( $info['entity'] ) ) {
                        // never serialize full entity data in a change, it's 
huge.
                        unset( $info['entity'] );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I98a67ae7e5473528399954d2750ba82539826e9d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Daniel Kinzler <daniel.kinz...@wikimedia.de>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to