EBernhardson (WMF) has submitted this change and it was merged.

Change subject: Decompress revision text
......................................................................


Decompress revision text

Revision text gzip-saved (via Revision::compressRevisionText()) was not being
decompressed (resulting in garbled output)

Meanwhile, I don't really see why find() needs its own code; it does exactly
what findMulti() does, so no need to duplicate that code.

Depends on https://gerrit.wikimedia.org/r/#/c/78079/, which introduces
Revision::decompressRevisionText()

Conflicts:
        includes/Data/ObjectManager.php
        includes/Data/RevisionStorage.php

Change-Id: I82a5f68dde312fbb5cb6ce60fe46234a23f7a3b0
---
M includes/Data/ObjectManager.php
M includes/Data/RevisionStorage.php
2 files changed, 20 insertions(+), 18 deletions(-)

Approvals:
  EBernhardson (WMF): Verified; Looks good to me, approved



diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index da107fd..3446cbe 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -29,11 +29,11 @@
 interface ObjectStorage extends \IteratorAggregate {
        function find( array $attributes, array $options = array() );
        /**
-        * The BagOStuff interface returns with keys matching the key, 
unfortunatly
-        * we deal with composite keys which makes that awkward. Instead all
-        * findMulti implementations return their data with the same array 
indexes
-        * as the query in $queries. The order the requested queries are 
returned in
-        * is arbitrary.
+        * The BagOStuff interface returns with keys matching the key, 
unfortunately
+        * we deal with composite keys which makes that awkward. Instead all 
findMulti
+        * implementations must return their result as if it was array_map( 
array( $obj, 'find' ), $queries ).
+        * This is necessary so result sets stay ordered
+        *
         *
         * @param array $queries list of queries to perform
         * @param array $options Options to use for all queries
diff --git a/includes/Data/RevisionStorage.php 
b/includes/Data/RevisionStorage.php
index 47f2a01..4fc53e1 100644
--- a/includes/Data/RevisionStorage.php
+++ b/includes/Data/RevisionStorage.php
@@ -28,19 +28,13 @@
        }
 
        // Find one by specific attributes
+       // @todo: this method can probably be generalized in parent class?
        public function find( array $attributes, array $options = array() ) {
-               $res = $this->findInternal( $attributes, $options );
-               if ( $res === false ) {
-                       return false;
+               $multi = $this->findMulti( array( $attributes ), $options );
+               if ( $multi ) {
+                       return reset( $multi );
                }
-               if ( $this->externalStore ) {
-                       $res = Merger::merge(
-                               $res,
-                               'text_content',
-                               array( 'ExternalStore', 'batchFetchByURLs' )
-                       );
-               }
-               return $res;
+               return null;
        }
 
        protected function findInternal( array $attributes, array $options = 
array() ) {
@@ -73,15 +67,23 @@
                        $res = $this->findMultiInternal( $queries, $options );
                }
                if ( $this->externalStore ) {
-                       return Merger::mergeMulti(
+                       $res = Merger::mergeMulti(
                                $res,
                                'text_content',
                                array( 'ExternalStore', 'batchFetchFromURLs' )
                        );
                }
+
+               // decompress content
+               foreach ( $res as &$record ) {
+                       foreach ( $record as $id => &$row ) {
+                               $flags = explode( ',', $row['text_flags'] );
+                               $row['text_content'] = 
\Revision::decompressRevisionText( $row['text_content'], $flags );
+                       }
+               }
+
                return $res;
        }
-
 
        protected function fallbackFindMulti( array $queries, array $options ) {
                $result = array();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I82a5f68dde312fbb5cb6ce60fe46234a23f7a3b0
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Matthias Mullie <[email protected]>
Gerrit-Reviewer: EBernhardson (WMF) <[email protected]>

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

Reply via email to