return ( $sources > 0 );
}
+ /**
+ * Determines whether cascading protection sources have already been loaded from
+ * the database.
+ *
+ * @param bool $getPages True to check if the pages are loaded, or false to check
+ * if the status is loaded.
+ * @return bool Whether or not the specified information has been loaded
+ * @since 1.23
+ */
+ public function areCascadeProtectionSourcesLoaded( $getPages = true ) {
+ return $getPages ? isset( $this->mCascadeSources ) : isset( $this->mHasCascadingRestrictions );
+ }
+
/**
* Cascading protection: Get the source of any cascading restrictions on this page.
*
/**
* Returns the sources of any cascading protection acting on a specified page.
* Pages will not return their own title unless they transclude themselves.
- * This is an expensive parser function and can't be called too many times per page.
+ * This is an expensive parser function and can't be called too many times per page,
+ * unless cascading protection sources for the page have already been loaded.
*
* @param Parser $parser
* @param string $title
if ( !( $titleObject instanceof Title ) ) {
$titleObject = $parser->mTitle;
}
- $names = array();
- if ( $parser->incrementExpensiveFunctionCount() ) {
+ if ( $titleObject->areCascadeProtectionSourcesLoaded()
+ || $parser->incrementExpensiveFunctionCount()
+ ) {
+ $names = array();
$sources = $titleObject->getCascadeProtectionSources();
foreach ( $sources[0] as $sourceTitle ) {
$names[] = $sourceTitle->getPrefixedText();
}
+ return implode( $names, '|' );
}
-
- return implode( $names, '|' );
+ return '';
}
}