Skip to content

Commit

Permalink
Merge "Replace uses of ParserOutput::setPageProperty()"
Browse files Browse the repository at this point in the history
  • Loading branch information
jenkins-bot authored and Gerrit Code Review committed Sep 6, 2024
2 parents 821c66e + ee10917 commit 0e119fe
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function testMoveConnectedItemFeatureFlag_inActive() {

private function primeParserOutput( ParserOutput $parserOutput, array $pageProps, array $extensionData, array $extensionDataAppend ) {
foreach ( $pageProps as $name => $value ) {
$parserOutput->setPageProperty( $name, $value );
$parserOutput->setUnsortedPageProperty( $name, $value );
}

foreach ( $extensionData as $key => $value ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,11 @@ public function testUpdateUnconnectedPageProperty(
$parserOutput = new ParserOutput();
$parserOutputProvider = new ScopedParserOutputProvider( $parserOutput );
foreach ( $priorPageProps as $key => $value ) {
$parserOutput->setPageProperty( $key, $value );
if ( is_numeric( $value ) ) {
$parserOutput->setNumericPageProperty( $key, $value );
} else {
$parserOutput->setUnsortedPageProperty( $key, $value );
}
}

$content = $this->createMock( Content::class );
Expand Down
8 changes: 7 additions & 1 deletion repo/includes/Content/EntityHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,13 @@ private function applyEntityPageProperties( EntityContent $content, ParserOutput

$properties = $content->getEntityPageProperties();
foreach ( $properties as $name => $value ) {
$parserOutput->setPageProperty( $name, $value );
if ( is_numeric( $value ) ) {
$parserOutput->setNumericPageProperty( $name, $value );
} elseif ( is_bool( $value ) ) {
$parserOutput->setNumericPageProperty( $name, (int)$value );
} else {
$parserOutput->setUnsortedPageProperty( $name, $value );
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion repo/includes/ParserOutput/PageImagesDataUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function updateParserOutput( ParserOutput $parserOutput ) {
$parserOutput->unsetPageProperty( $this->pagePropName );
} else {
$fileName = str_replace( ' ', '_', $this->bestFileName );
$parserOutput->setPageProperty( $this->pagePropName, $fileName );
$parserOutput->setUnsortedPageProperty( $this->pagePropName, $fileName );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ private function getKartographerParserOutput() {
$parserOutput = new ParserOutput();
$parserOutput->addModules( [ 'kartographer-rl-module1', 'javascript-stuffs' ] );
$parserOutput->setExtensionData( 'kartographer', [ [ 'whatever' ] ] );
$parserOutput->setPageProperty( 'kartographer_links', 34 );
$parserOutput->setPageProperty( 'kartographer_frames', 42 );
$parserOutput->setNumericPageProperty( 'kartographer_links', 34 );
$parserOutput->setNumericPageProperty( 'kartographer_frames', 42 );
$parserOutput->setJsConfigVar( 'wgKartographerMapServer', 'https://maps.wikimedia.org' );

return $parserOutput;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ public function testUpdateParserOutput(

if ( $expected !== null ) {
$parserOutput->expects( $this->once() )
->method( 'setPageProperty' )
->method( 'setUnsortedPageProperty' )
->with( 'page_image', $expected );
} else {
$parserOutput->expects( $this->never() )
->method( 'setPageProperty' );
->method( 'setUnsortedPageProperty' );
}

$instance = $this->newInstance( $propertyIds );
Expand Down

0 comments on commit 0e119fe

Please sign in to comment.