mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageImages
synced 2024-11-15 12:00:40 +00:00
Use mExtensionData instead of undeclared class property
Change-Id: I155e37fda412cd467da7b34c52b34661c7c20224
This commit is contained in:
parent
23cf541f1b
commit
1f1c72bb2c
|
@ -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 ) {
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue