Do not try to derive descriptions if one has been specified already
Skip running the generator on interface messages and if a description has already been set. This resolves some annoyances ranging from performance (relevant if the algorithm becomes more expensive to run) to multiple description meta tags being spawned. This is part of my RemexHtml patch chain, which I've split up to avoid having a single commit alter the majority of the codebase. If it ends up being rejected, I can rebase this change to rid of dependencies on the rest of the chain. Depends-On: I97fd065c9554837747021ba9fff26005e33270f4 Change-Id: I585f2c0046571310aad67f3ba148c4f22aaae49f
This commit is contained in:
parent
b73fe26c29
commit
050086dd6e
|
@ -49,6 +49,25 @@ class Hooks implements
|
|||
* @return bool
|
||||
*/
|
||||
public function onParserAfterTidy( $parser, &$text ) {
|
||||
$parserOutput = $parser->getOutput();
|
||||
|
||||
// Avoid running the algorithm on interface messages which may waste time
|
||||
if ( $parser->getOptions()->getInterfaceMessage() ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Avoid running the algorithm multiple times if we already have determined the description. This may happen
|
||||
// on file pages.
|
||||
if ( method_exists( $parserOutput, 'getPageProperty' ) ) {
|
||||
// MW 1.38+
|
||||
$description = $parserOutput->getPageProperty( 'description' );
|
||||
} else {
|
||||
$description = $parserOutput->getProperty( 'description' );
|
||||
}
|
||||
if ( $description ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$desc = $this->descriptionProvider->derive( $text );
|
||||
|
||||
if ( $desc ) {
|
||||
|
|
Loading…
Reference in a new issue