Thiemo Mättig (WMDE) has uploaded a new change for review.
https://gerrit.wikimedia.org/r/248851
Change subject: Use mExtensionData instead of undeclared class property
......................................................................
Use mExtensionData instead of undeclared class property
Change-Id: I155e37fda412cd467da7b34c52b34661c7c20224
---
M PageImages.body.php
M tests/phpunit/PageImagesTest.php
2 files changed, 14 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageImages
refs/changes/51/248851/1
diff --git a/PageImages.body.php b/PageImages.body.php
index 3ec8264..cfe7f19 100644
--- a/PageImages.body.php
+++ b/PageImages.body.php
@@ -89,10 +89,6 @@
}
}
- $out = $parser->getOutput();
- if ( !isset( $out->pageImages ) ) {
- $out->pageImages = array();
- }
if ( is_array( $handlerParams ) ) {
$myParams = $handlerParams;
self::calcWidth( $myParams, $file );
@@ -103,7 +99,11 @@
$myParams['filename'] = $file->getTitle()->getDBkey();
$myParams['fullwidth'] = $file->getWidth();
$myParams['fullheight'] = $file->getHeight();
- $out->pageImages[] = $myParams;
+
+ $out = $parser->getOutput();
+ $pageImages = $out->getExtensionData( 'pageImages' ) ?: array();
+ $pageImages[] = $myParams;
+ $out->setExtensionData( 'pageImages', $pageImages );
}
/**
@@ -144,11 +144,11 @@
* @return bool
*/
public static function onLinksUpdate( LinksUpdate $linksUpdate ) {
- if ( !isset( $linksUpdate->getParserOutput()->pageImages ) ) {
+ $images = $linksUpdate->getParserOutput()->getExtensionData(
'pageImages' );
+ if ( $images === null ) {
return true;
}
- $images = $linksUpdate->getParserOutput()->pageImages;
$scores = array();
$counter = 0;
foreach ( $images as $image ) {
diff --git a/tests/phpunit/PageImagesTest.php b/tests/phpunit/PageImagesTest.php
index 46e074b..84f1303 100644
--- a/tests/phpunit/PageImagesTest.php
+++ b/tests/phpunit/PageImagesTest.php
@@ -4,7 +4,7 @@
use MediaWikiTestCase;
use PageImages;
-use stdClass;
+use ParserOutput;
use Title;
/**
@@ -35,10 +35,12 @@
}
public function testOnLinksUpdate() {
- $parserOutput = new stdClass();
- $parserOutput->pageImages = array(
- array( 'filename' => 'A.jpg', 'fullwidth' => 100,
'fullheight' => 50 ),
- );
+ $parserOutput = new ParserOutput();
+ $parserOutput->setExtensionData( 'pageImages', array(
+ 'filename' => 'A.jpg',
+ 'fullwidth' => 100,
+ 'fullheight' => 50,
+ ) );
$linksUpdate = $this->getMockBuilder( 'LinksUpdate' )
->disableOriginalConstructor()
--
To view, visit https://gerrit.wikimedia.org/r/248851
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I155e37fda412cd467da7b34c52b34661c7c20224
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageImages
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits