Use mExtensionData instead of undeclared class property

Change-Id: I155e37fda412cd467da7b34c52b34661c7c20224
This commit is contained in:
Thiemo Mättig 2015-10-26 12:05:47 +01:00
parent 23cf541f1b
commit 1f1c72bb2c
2 changed files with 11 additions and 11 deletions

View file

@ -89,10 +89,6 @@ class PageImages {
}
}
$out = $parser->getOutput();
if ( !isset( $out->pageImages ) ) {
$out->pageImages = array();
}
if ( is_array( $handlerParams ) ) {
$myParams = $handlerParams;
self::calcWidth( $myParams, $file );
@ -103,7 +99,11 @@ class PageImages {
$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 @@ class PageImages {
* @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 ) {

View file

@ -4,7 +4,7 @@ namespace PageImages\Tests;
use MediaWikiTestCase;
use PageImages;
use stdClass;
use ParserOutput;
use Title;
/**
@ -35,10 +35,10 @@ class PageImagesTest extends MediaWikiTestCase {
}
public function testOnLinksUpdate() {
$parserOutput = new stdClass();
$parserOutput->pageImages = array(
$parserOutput = new ParserOutput();
$parserOutput->setExtensionData( 'pageImages', array(
array( 'filename' => 'A.jpg', 'fullwidth' => 100, 'fullheight' => 50 ),
);
) );
$linksUpdate = $this->getMockBuilder( 'LinksUpdate' )
->disableOriginalConstructor()