*/
public static function getInvalidTitleDescription( IContextSource $context, $namespace, $title ) {
// First we check whether the namespace exists or not.
- if ( MWNamespace::exists( $namespace ) ) {
+ if ( MediaWikiServices::getInstance()->getNamespaceInfo()->exists( $namespace ) ) {
if ( $namespace == NS_MAIN ) {
$name = $context->msg( 'blanknamespace' )->text();
} else {
# Use manually specified thumbnail
$manual_title = Title::makeTitleSafe( NS_FILE, $frameParams['manualthumb'] );
if ( $manual_title ) {
- $manual_img = wfFindFile( $manual_title );
+ $manual_img = MediaWikiServices::getInstance()->getRepoGroup()
+ ->findFile( $manual_title );
if ( $manual_img ) {
$thumb = $manual_img->getUnscaledThumb( $handlerParams );
$manualthumb = true;
$label = $title->getPrefixedText();
}
$encLabel = htmlspecialchars( $label );
- $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
+ $file = MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title );
+ $currentExists = $time ? ( $file != false ) : false;
if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
&& !$currentExists
* @since 1.16.3
* @param LinkTarget $title
* @param string $html Pre-sanitized HTML
- * @param string $time MW timestamp of file creation time
+ * @param string|false $time MW timestamp of file creation time
* @return string HTML
*/
public static function makeMediaLinkObj( $title, $html = '', $time = false ) {
- $img = wfFindFile( $title, [ 'time' => $time ] );
+ $img = MediaWikiServices::getInstance()->getRepoGroup()->findFile(
+ $title, [ 'time' => $time ]
+ );
return self::makeMediaLinkFile( $title, $img, $html );
}
* @since 1.16.3. $altUserName was added in 1.19.
*/
public static function userLink( $userId, $userName, $altUserName = false ) {
- if ( $userName === '' ) {
- wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+ if ( $userName === '' || $userName === false || $userName === null ) {
+ wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
'that need to be fixed?' );
return wfMessage( 'empty-username' )->parse();
}
$useParentheses = true
) {
if ( $userText === '' ) {
- wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+ wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
'that need to be fixed?' );
return ' ' . wfMessage( 'empty-username' )->parse();
}
*/
public static function userTalkLink( $userId, $userText ) {
if ( $userText === '' ) {
- wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+ wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
'that need to be fixed?' );
return wfMessage( 'empty-username' )->parse();
}
*/
public static function blockLink( $userId, $userText ) {
if ( $userText === '' ) {
- wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+ wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
'that need to be fixed?' );
return wfMessage( 'empty-username' )->parse();
}
$sectionText = str_replace( '[[', '[[', $auto );
$section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
- if ( $local ) {
- $sectionTitle = new TitleValue( NS_MAIN, '', $section );
- } else {
- $sectionTitle = $title->createFragmentTarget( $section );
- }
- if ( $sectionTitle ) {
+ // Support: HHVM (T222857)
+ // The guessSectionNameFromStrippedText method returns a non-empty string
+ // that starts with "#". Before PHP 7 (and still on HHVM) substr() would
+ // return false if the start offset is the end of the string.
+ // On PHP 7+, it gracefully returns empty string instead.
+ if ( $section !== '' && $section !== false ) {
+ if ( $local ) {
+ $sectionTitle = new TitleValue( NS_MAIN, '', $section );
+ } else {
+ $sectionTitle = $title->createFragmentTarget( $section );
+ }
$auto = Linker::makeCommentLink(
- $sectionTitle, $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
- $wikiId, 'noclasses'
+ $sectionTitle,
+ $wgLang->getArrow() . $wgLang->getDirMark() . $sectionText,
+ $wikiId,
+ 'noclasses'
);
}
}
([^[]*) # 3. link trail (the text up until the next link)
/x',
function ( $match ) use ( $title, $local, $wikiId ) {
- $medians = '(?:' . preg_quote( MWNamespace::getCanonicalName( NS_MEDIA ), '/' ) . '|';
+ $services = MediaWikiServices::getInstance();
+
+ $medians = '(?:';
+ $medians .= preg_quote(
+ $services->getNamespaceInfo()->getCanonicalName( NS_MEDIA ), '/' );
+ $medians .= '|';
$medians .= preg_quote(
MediaWikiServices::getInstance()->getContentLanguage()->getNsText( NS_MEDIA ),
'/'
$wikiId,
$linkTarget->getNamespace() === 0
? $linkTarget->getDBkey()
- : MWNamespace::getCanonicalName( $linkTarget->getNamespace() ) . ':'
- . $linkTarget->getDBkey(),
+ : MediaWikiServices::getInstance()->getNamespaceInfo()->
+ getCanonicalName( $linkTarget->getNamespace() ) .
+ ':' . $linkTarget->getDBkey(),
$linkTarget->getFragment()
),
$text,
# Some namespaces don't allow subpages,
# so only perform processing if subpages are allowed
- if ( $contextTitle && MWNamespace::hasSubpages( $contextTitle->getNamespace() ) ) {
+ if (
+ $contextTitle && MediaWikiServices::getInstance()->getNamespaceInfo()->
+ hasSubpages( $contextTitle->getNamespace() )
+ ) {
$hash = strpos( $target, '#' );
if ( $hash !== false ) {
$suffix = substr( $target, $hash );