* and does not rely on global state or the database.
*/
class Title implements LinkTarget {
- /** @var HashBagOStuff */
+ /** @var MapCacheLRU */
static private $titleCache = null;
/**
public static function newFromTextThrow( $text, $defaultNamespace = NS_MAIN ) {
if ( is_object( $text ) ) {
throw new MWException( '$text must be a string, given an object' );
+ } elseif ( $text === null ) {
+ // Legacy code relies on MalformedTitleException being thrown in this case
+ // (happens when URL with no title in it is parsed). TODO fix
+ throw new MalformedTitleException( 'title-invalid-empty' );
}
$titleCache = self::getTitleCache();
}
/**
- * @return HashBagOStuff
+ * @return MapCacheLRU
*/
private static function getTitleCache() {
if ( self::$titleCache == null ) {
- self::$titleCache = new HashBagOStuff( [ 'maxKeys' => self::CACHE_MAX ] );
+ self::$titleCache = new MapCacheLRU( self::CACHE_MAX );
}
return self::$titleCache;
}