Add comment to ParserOutput::setIndexPolicy()

Change-Id: I01d03aa6204a13a92bb8bc00364c822c27aa60b9
This commit is contained in:
Lucas Werkmeister 2024-10-18 16:38:03 +02:00 committed by Lucas Werkmeister (WMDE)
parent 746a0751d8
commit ace0e6fc81

View file

@ -971,6 +971,19 @@ class ParserOutput extends CacheTime implements ContentMetadataCollector {
return $oldValue;
}
/**
* Update the index policy of the robots meta tag.
*
* Note that calling this method does not guarantee
* that {@link self::getIndexPolicy()} will return the given policy
* if different calls set the index policy to 'index' and 'noindex',
* then 'noindex' always wins (T16899), even if the 'index' call happened later.
* If this is not what you want,
* you can reset {@link ParserOutputFlags::NO_INDEX_POLICY} with {@link self::setOutputFlag()}.
*
* @param string $policy 'index' or 'noindex'.
* @return string The previous policy.
*/
public function setIndexPolicy( $policy ): string {
$old = $this->getIndexPolicy();
if ( $policy === 'noindex' ) {