Anomie has uploaded a new change for review.
https://gerrit.wikimedia.org/r/183597
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/ApiQueryExtracts.php
M includes/Hooks.php
2 files changed, 38 insertions(+), 9 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts
refs/changes/97/183597/1
diff --git a/includes/ApiQueryExtracts.php b/includes/ApiQueryExtracts.php
index f80b675..7345f80 100644
--- a/includes/ApiQueryExtracts.php
+++ b/includes/ApiQueryExtracts.php
@@ -196,7 +196,11 @@
$api = new ApiMain( new FauxRequest( $request ) );
try {
$api->execute();
- $data = $api->getResultData();
+ if ( defined( 'ApiResult::META_CONTENT' ) ) {
+ $data = $api->getResult()->getResultData();
+ } else {
+ $data = $api->getResultData();
+ }
} catch ( UsageException $e ) {
if ( $e->getCodeString() === 'nosuchsection' ) {
// Looks like we tried to get the intro to a
page without
@@ -204,7 +208,11 @@
unset( $request['section'] );
$api = new ApiMain( new FauxRequest( $request )
);
$api->execute();
- $data = $api->getResultData();
+ if ( defined( 'ApiResult::META_CONTENT' ) ) {
+ $data =
$api->getResult()->getResultData();
+ } else {
+ $data = $api->getResultData();
+ }
} else {
// Some other unexpected error - lets just
report it to the user
// on the off chance that is the right thing.
@@ -212,7 +220,15 @@
}
}
wfProfileOut( __METHOD__ );
- return $data['parse']['text']['*'];
+
+ if ( defined( 'ApiResult::META_CONTENT' ) &&
+ isset( $data['parse']['text'][ApiResult::META_CONTENT] )
+ ) {
+ $contentKey =
$data['parse']['text'][ApiResult::META_CONTENT];
+ } else {
+ $contentKey = '*';
+ }
+ return $data['parse']['text'][$contentKey];
}
/**
diff --git a/includes/Hooks.php b/includes/Hooks.php
index 6ea5b98..66bcc05 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -30,13 +30,26 @@
) )
);
$api->execute();
- $data = $api->getResultData();
- foreach ( $pageIds as $id ) {
- if ( isset(
$data['query']['pages'][$id]['extract']['*'] ) ) {
- $results[$id]['extract'] =
$data['query']['pages'][$id]['extract']['*'];
- $results[$id]['extract trimmed'] = false;
+ if ( defined( 'ApiResult::META_CONTENT' ) ) {
+ $data = $api->getResult()->getResultData( array(
'query', 'pages' ) );
+ foreach ( $pageIds as $id ) {
+ $contentKey = isset(
$data[$id]['extract'][ApiResult::META_CONTENT] )
+ ?
$data[$id]['extract'][ApiResult::META_CONTENT]
+ : '*';
+ if ( isset( $data[$id]['extract'][$contentKey]
) ) {
+ $results[$id]['extract'] =
$data[$id]['extract'][$contentKey];
+ $results[$id]['extract trimmed'] =
false;
+ }
+ }
+ } else {
+ $data = $api->getResultData();
+ foreach ( $pageIds as $id ) {
+ if ( isset(
$data['query']['pages'][$id]['extract']['*'] ) ) {
+ $results[$id]['extract'] =
$data['query']['pages'][$id]['extract']['*'];
+ $results[$id]['extract trimmed'] =
false;
+ }
}
}
return true;
}
-}
\ No newline at end of file
+}
--
To view, visit https://gerrit.wikimedia.org/r/183597
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b37295e8862b188d1f3b0cd07f66ac34629678e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/TextExtracts
Gerrit-Branch: master
Gerrit-Owner: Anomie <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits