Anomie has uploaded a new change for review.

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

Change subject: Update ApiResult handling for mediawiki/core change I7b37295e
......................................................................

Update ApiResult handling for mediawiki/core change I7b37295e

Change I7b37295e for mediawiki/core deprecates several methods, and more
importantly changes the format of the data returned from
ApiResult::getData(). This change should handle these differences in a
backwards-compatible manner.

Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678e
---
M includes/Import/LiquidThreadsApi/Objects.php
M includes/Import/LiquidThreadsApi/Source.php
M maintenance/convertToText.php
3 files changed, 35 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/82/183582/1

diff --git a/includes/Import/LiquidThreadsApi/Objects.php 
b/includes/Import/LiquidThreadsApi/Objects.php
index cef3426..ee13033 100644
--- a/includes/Import/LiquidThreadsApi/Objects.php
+++ b/includes/Import/LiquidThreadsApi/Objects.php
@@ -82,8 +82,16 @@
         */
        public function getText() {
                $pageData = $this->importSource->getPageData( 
$this->apiResponse['rootid'] );
+               $revision = $pageData['revisions'][0];
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $contentKey = isset( $revision[ApiResult::META_CONTENT] 
)
+                               ? $revision[ApiResult::META_CONTENT]
+                               : '*';
+               } else {
+                       $contentKey = '*';
+               }
 
-               return $pageData['revisions'][0]['*'];
+               return $revision[$contentKey];
        }
 
        public function getTitle() {
@@ -220,7 +228,15 @@
         * @return string
         */
        public function getText() {
-               return $this->apiResponse['*'];
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $contentKey = isset( 
$this->apiResponse[ApiResult::META_CONTENT] )
+                               ? $this->apiResponse[ApiResult::META_CONTENT]
+                               : '*';
+               } else {
+                       $contentKey = '*';
+               }
+
+               return $this->apiResponse[$contentKey];
        }
 
        public function getTimestamp() {
diff --git a/includes/Import/LiquidThreadsApi/Source.php 
b/includes/Import/LiquidThreadsApi/Source.php
index b98cee7..bd46b7e 100644
--- a/includes/Import/LiquidThreadsApi/Source.php
+++ b/includes/Import/LiquidThreadsApi/Source.php
@@ -315,7 +315,11 @@
 
                        $api = new ApiMain( $context );
                        $api->execute();
-                       return $api->getResult()->getData();
+                       if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                               return ApiResult::removeMetadata( 
$api->getResult()->getResultData() );
+                       } else {
+                               return $api->getResult()->getData();
+                       }
                } catch ( UsageException $exception ) {
                        // Mimic the behaviour when called remotely
                        return array( 'error' => $exception->getMessageArray() 
);
diff --git a/maintenance/convertToText.php b/maintenance/convertToText.php
index 32f6159..d4f1c7a 100644
--- a/maintenance/convertToText.php
+++ b/maintenance/convertToText.php
@@ -90,13 +90,19 @@
                $api = new ApiMain( $request );
                $api->execute();
 
-               $apiResponse = $api->getResult()->getData();
-
-               if ( ! isset( $apiResponse['flow'] ) ) {
-                       throw new MWException( "API response has no Flow data" 
);
+               if ( defined( 'ApiResult::META_CONTENT' ) ) {
+                       $flowData = $api->getResult()->getResultData( array( 
'flow', $submodule, 'result' ) );
+                       if ( $flowData === null ) {
+                               throw new MWException( "API response has no 
Flow data" );
+                       }
+                       $flowData = ApiResult::removeMetadata( $flowData );
+               } else {
+                       $apiResponse = $api->getResult()->getData();
+                       if ( ! isset( $apiResponse['flow'] ) ) {
+                               throw new MWException( "API response has no 
Flow data" );
+                       }
+                       $flowData = $apiResponse['flow'][$submodule]['result'];
                }
-
-               $flowData = $apiResponse['flow'][$submodule]['result'];
 
                if( $requiredBlock !== false && ! isset( 
$flowData[$requiredBlock] ) ) {
                        throw new MWException( "No $requiredBlock block in API 
response" );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>

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

Reply via email to