* @author Roan Kattouw
*/
+use Wikimedia\Rdbms\Database;
+use Wikimedia\Rdbms\IDatabase;
+
/**
* Abstraction for ResourceLoader modules which pull from wiki pages
*
protected function getContent( $titleText ) {
$title = Title::newFromText( $titleText );
if ( !$title ) {
- return null;
+ return null; // Bad title
}
// If the page is a redirect, follow the redirect.
$content = $this->getContentObj( $title );
$title = $content ? $content->getUltimateRedirectTarget() : null;
if ( !$title ) {
- return null;
+ return null; // Dead redirect
}
}
} elseif ( $handler->isSupportedFormat( CONTENT_FORMAT_JAVASCRIPT ) ) {
$format = CONTENT_FORMAT_JAVASCRIPT;
} else {
- return null;
+ return null; // Bad content model
}
$content = $this->getContentObj( $title );
if ( !$content ) {
- return null;
+ return null; // No content found
}
return $content->serialize( $format );
/**
* @param ResourceLoaderContext $context
- * @return string
+ * @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
$scripts = '';
if ( $module instanceof self ) {
$mDB = $module->getDB();
// Subclasses may disable getDB and implement getTitleInfo differently
- if ( $mDB && $mDB->getWikiID() === $db->getWikiID() ) {
+ if ( $mDB && $mDB->getDomainID() === $db->getDomainID() ) {
$wikiModules[] = $module;
$allPages += $module->getPages( $context );
}
$cache = ObjectCache::getMainWANInstance();
$allInfo = $cache->getWithSetCallback(
- $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getWikiID(), $hash ),
+ $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getDomainID(), $hash ),
$cache::TTL_HOUR,
function ( $curVal, &$ttl, array &$setOpts ) use ( $func, $pageNames, $db, $fname ) {
$setOpts += Database::getCacheSetOptions( $db );
return call_user_func( $func, $db, $pageNames, $fname );
},
- [ 'checkKeys' => [ $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getWikiID() ) ] ]
+ [
+ 'checkKeys' => [
+ $cache->makeGlobalKey( 'resourceloader', 'titleinfo', $db->getDomainID() ) ]
+ ]
);
foreach ( $wikiModules as $wikiModule ) {