Aude has uploaded a new change for review.

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

Change subject: Don't set page_image property when there is no 'best' image
......................................................................

Don't set page_image property when there is no 'best' image

Bug: T116889
Change-Id: Ica9d011dcc46c65c554eb12ba293df18e01f3dde
---
M repo/includes/ParserOutput/PageImagesDataUpdate.php
M repo/tests/phpunit/includes/ParserOutput/PageImagesDataUpdateTest.php
2 files changed, 13 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/55/249355/1

diff --git a/repo/includes/ParserOutput/PageImagesDataUpdate.php 
b/repo/includes/ParserOutput/PageImagesDataUpdate.php
index 8302c1b..14782cd 100644
--- a/repo/includes/ParserOutput/PageImagesDataUpdate.php
+++ b/repo/includes/ParserOutput/PageImagesDataUpdate.php
@@ -177,8 +177,10 @@
         * @param ParserOutput $parserOutput
         */
        public function updateParserOutput( ParserOutput $parserOutput ) {
-               // This property name is the only "soft dependency" on the 
PageImages extension.
-               $parserOutput->setProperty( 'page_image', $this->bestFileName );
+               if ( $this->bestFileName !== null ) {
+                       // This property name is the only "soft dependency" on 
the PageImages extension.
+                       $parserOutput->setProperty( 'page_image', 
$this->bestFileName );
+               }
        }
 
 }
diff --git 
a/repo/tests/phpunit/includes/ParserOutput/PageImagesDataUpdateTest.php 
b/repo/tests/phpunit/includes/ParserOutput/PageImagesDataUpdateTest.php
index 2289778..8d4f030 100644
--- a/repo/tests/phpunit/includes/ParserOutput/PageImagesDataUpdateTest.php
+++ b/repo/tests/phpunit/includes/ParserOutput/PageImagesDataUpdateTest.php
@@ -81,9 +81,15 @@
                $parserOutput = $this->getMockBuilder( 'ParserOutput' )
                        ->disableOriginalConstructor()
                        ->getMock();
-               $parserOutput->expects( $this->once() )
-                       ->method( 'setProperty' )
-                       ->with( 'page_image', $expected );
+
+               if ( $expected !== null ) {
+                       $parserOutput->expects( $this->once() )
+                               ->method( 'setProperty' )
+                               ->with( 'page_image', $expected );
+               } else {
+                       $parserOutput->expects( $this->never() )
+                               ->method( 'setProperty' );
+               }
 
                $instance = $this->newInstance( $propertyIds );
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ica9d011dcc46c65c554eb12ba293df18e01f3dde
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to