ParserOutput: Ensure page title is updated after merging properties

Eventually we should merge the "title text" and "display title" in
ParserOutput (T293514) but for now mirror the logic in
ParserOutput::mergeHtmlMetadataFrom() and update the title text
from the source if it hasn't already been set in the destination.
This patch ensures that after page properties are merged during
metadata collection, the title text is suitably updated if the
'displaytitle' property is set.

This will let Parsoid pass displaytitle (metadata) tests in integrated
mode since Parsoid relies on merging metadata from multiple ParserOutput
objects (in the DataAccess object that is used to expand templates, etc.)

Once this patch is merged, Parsoid patches may start failing CI till
we submit a patch there to fix up the integrated test failures list
since some previously failing tests may now pass.

Bug: T293514
Bug: T294621
Change-Id: Ia673f1261ccd03caf455122b71cfb9769b02f22e
This commit is contained in:
Subramanya Sastry 2023-04-14 23:18:56 -05:00
parent 2b5d25ba71
commit 632481c382

View file

@ -2455,6 +2455,12 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
if ( $this->mCacheRevisionId !== null ) {
$metadata->setCacheRevisionId( $this->mCacheRevisionId );
}
// T293514: We should use the first *modified* title text, but
// we don't have the original to check.
$otherTitle = $metadata->getTitleText();
if ( $otherTitle === null || $otherTitle === '' ) {
$metadata->setTitleText( $this->getTitleText() );
}
}
}