return array( $sources, $pagerestrictions );
}
+ /**
+ * Accessor for mRestrictionsLoaded
+ *
+ * @return bool Whether or not the page's restrictions have already been
+ * loaded from the database
+ * @since 1.23
+ */
+ public function areRestrictionsLoaded() {
+ return $this->mRestrictionsLoaded;
+ }
+
/**
* Accessor/initialisation for mRestrictions
*
: array();
}
+ /**
+ * Accessor/initialisation for mRestrictions
+ *
+ * @return Array of Arrays of Strings the first level indexed by
+ * action, the second level containing the names of the groups
+ * allowed to perform each action
+ * @since 1.23
+ */
+ public function getAllRestrictions() {
+ if ( !$this->mRestrictionsLoaded ) {
+ $this->loadRestrictions();
+ }
+ return $this->mRestrictions;
+ }
+
/**
* Get the expiry time for the restriction against a given action
*
}
/**
- * Returns the requested protection level for the current page
+ * Returns the requested protection level for the current page. This
+ * is an expensive parser function and can't be called too many times
+ * per page, unless the protection levels for the given title have
+ * already been retrieved
*
* @param Parser $parser
* @param string $type
if ( !( $titleObject instanceof Title ) ) {
$titleObject = $parser->mTitle;
}
- $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
- # Title::getRestrictions returns an array, its possible it may have
- # multiple values in the future
- return implode( $restrictions, ',' );
+ if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
+ $restrictions = $titleObject->getRestrictions( strtolower( $type ) );
+ # Title::getRestrictions returns an array, its possible it may have
+ # multiple values in the future
+ return implode( $restrictions, ',' );
+ }
+ return '';
}
/**