mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-27 17:51:09 +00:00
Merge "Make use of named MainConfigNames::… constants"
This commit is contained in:
commit
4bcee681fc
|
@ -548,7 +548,7 @@ class CommentParser {
|
|||
|
||||
if ( $namespaceId === NS_USER || $namespaceId === NS_USER_TALK ) {
|
||||
$username = $mainText;
|
||||
if ( strpos( $username, '/' ) !== false ) {
|
||||
if ( str_contains( $username, '/' ) ) {
|
||||
return null;
|
||||
}
|
||||
if ( $namespaceId === NS_USER ) {
|
||||
|
|
|
@ -6,6 +6,7 @@ use Config;
|
|||
use LogicException;
|
||||
use MediaWiki\Extension\DiscussionTools\ThreadItem\ContentCommentItem;
|
||||
use MediaWiki\Extension\DiscussionTools\ThreadItem\ContentThreadItem;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use Title;
|
||||
use Wikimedia\Assert\Assert;
|
||||
use Wikimedia\Parsoid\DOM\Comment;
|
||||
|
@ -480,16 +481,17 @@ class CommentUtils {
|
|||
}
|
||||
|
||||
// TODO: Set the correct base in the document?
|
||||
if ( strpos( $url, './' ) === 0 ) {
|
||||
$url = 'https://local' . str_replace( '$1', substr( $url, 2 ), $config->get( 'ArticlePath' ) );
|
||||
} elseif ( strpos( $url, '://' ) === false ) {
|
||||
if ( str_starts_with( $url, './' ) ) {
|
||||
$url = substr( $url, 2 );
|
||||
$url = 'https://local' . str_replace( '$1', $url, $config->get( MainConfigNames::ArticlePath ) );
|
||||
} elseif ( !str_contains( $url, '://' ) ) {
|
||||
$url = 'https://local' . $url;
|
||||
}
|
||||
|
||||
$articlePathRegexp = '/' . str_replace(
|
||||
preg_quote( '$1', '/' ),
|
||||
'([^?]*)',
|
||||
preg_quote( $config->get( 'ArticlePath' ), '/' )
|
||||
preg_quote( $config->get( MainConfigNames::ArticlePath ), '/' )
|
||||
) . '/';
|
||||
$matches = null;
|
||||
if ( preg_match( $articlePathRegexp, $url, $matches ) ) {
|
||||
|
|
|
@ -571,7 +571,7 @@ class HookUtils {
|
|||
$namespaceInfo = $services->getNamespaceInfo();
|
||||
Assert::precondition( $namespaceInfo->isTalk( $talkPage->getNamespace() ), "Page is a talk page" );
|
||||
|
||||
if ( $talkPage->getNamespace() === NS_USER_TALK && strpos( $talkPage->getText(), '/' ) === false ) {
|
||||
if ( $talkPage->getNamespace() === NS_USER_TALK && !str_contains( $talkPage->getText(), '/' ) ) {
|
||||
if ( $services->getUserNameUtils()->isIP( $talkPage->getText() ) ) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ class PageHooks implements
|
|||
|
||||
// Preload jquery.makeCollapsible for LedeSectionDialog.
|
||||
// Using the same approach as in Skin::getDefaultModules in MediaWiki core.
|
||||
if ( strpos( $output->getHTML(), 'mw-collapsible' ) !== false ) {
|
||||
if ( str_contains( $output->getHTML(), 'mw-collapsible' ) ) {
|
||||
$output->addModules( 'jquery.makeCollapsible' );
|
||||
$output->addModuleStyles( 'jquery.makeCollapsible.styles' );
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use DateTimeZone;
|
|||
use ILanguageConverter;
|
||||
use Language;
|
||||
use MediaWiki\Languages\LanguageConverterFactory;
|
||||
use MediaWiki\MainConfigNames;
|
||||
use MediaWiki\SpecialPage\SpecialPageFactory;
|
||||
|
||||
class LanguageData {
|
||||
|
@ -58,7 +59,7 @@ class LanguageData {
|
|||
foreach ( $langConv->getVariants() as $variant ) {
|
||||
$data['digits'][$variant] = [];
|
||||
foreach ( str_split( '0123456789' ) as $digit ) {
|
||||
if ( $config->get( 'TranslateNumerals' ) ) {
|
||||
if ( $config->get( MainConfigNames::TranslateNumerals ) ) {
|
||||
$localDigit = $lang->formatNumNoSeparators( $digit );
|
||||
} else {
|
||||
$localDigit = $digit;
|
||||
|
@ -69,7 +70,7 @@ class LanguageData {
|
|||
}
|
||||
|
||||
// ApiQuerySiteinfo
|
||||
$data['localTimezone'] = $config->get( 'Localtimezone' );
|
||||
$data['localTimezone'] = $config->get( MainConfigNames::Localtimezone );
|
||||
|
||||
// special page names compared against Title::getText, which contains space
|
||||
// But aliases are stored with underscores (db key) in the alias files
|
||||
|
@ -78,7 +79,7 @@ class LanguageData {
|
|||
$data['specialNewSectionName'] = str_replace( '_', ' ', $this->specialPageFactory
|
||||
->getLocalNameFor( 'NewSection' ) );
|
||||
|
||||
$localTimezone = $config->get( 'Localtimezone' );
|
||||
$localTimezone = $config->get( MainConfigNames::Localtimezone );
|
||||
// Return all timezone abbreviations for the local timezone (there will often be two, for
|
||||
// non-DST and DST timestamps, and sometimes more due to historical data, but that's okay).
|
||||
// Avoid DateTimeZone::listAbbreviations(), it returns some half-baked list that is different
|
||||
|
|
|
@ -15,9 +15,7 @@ abstract class IntegrationTestCase extends MediaWikiIntegrationTestCase {
|
|||
* @param array $data
|
||||
*/
|
||||
protected function setupEnv( array $config, array $data ): void {
|
||||
$this->setMwGlobals( $config );
|
||||
$this->setMwGlobals( [
|
||||
'wgArticlePath' => $config['wgArticlePath'],
|
||||
'wgNamespaceAliases' => $config['wgNamespaceIds'],
|
||||
'wgMetaNamespace' => strtr( $config['wgFormattedNamespaces'][NS_PROJECT], ' ', '_' ),
|
||||
'wgMetaNamespaceTalk' => strtr( $config['wgFormattedNamespaces'][NS_PROJECT_TALK], ' ', '_' ),
|
||||
|
@ -26,7 +24,7 @@ abstract class IntegrationTestCase extends MediaWikiIntegrationTestCase {
|
|||
// Data used for the tests assumes there are no variants for English.
|
||||
// Language variants are tested using other languages.
|
||||
'wgUsePigLatinVariant' => false,
|
||||
] );
|
||||
] + $config );
|
||||
$this->setUserLang( $config['wgContentLanguage'] );
|
||||
$this->setContentLang( $config['wgContentLanguage'] );
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ trait TestUtils {
|
|||
$quotedNewInnerHtml = strtr( $newInnerHtml, [ '\\' => '\\\\', '$' => '\\$' ] );
|
||||
|
||||
if ( strtolower( $container->tagName ) === 'body' ) {
|
||||
if ( strpos( $html, '<body' ) !== false ) {
|
||||
if ( str_contains( $html, '<body' ) ) {
|
||||
$html = preg_replace(
|
||||
'`(<body[^>]*>)(.*)(</body>)`s',
|
||||
'$1' . $quotedNewInnerHtml . '$3',
|
||||
|
|
|
@ -23,9 +23,7 @@ class ApiDiscussionToolsPageInfoTest extends ApiTestCase {
|
|||
* @param array $data
|
||||
*/
|
||||
protected function setupEnv( array $config, array $data ): void {
|
||||
$this->setMwGlobals( $config );
|
||||
$this->setMwGlobals( [
|
||||
'wgArticlePath' => $config['wgArticlePath'],
|
||||
'wgNamespaceAliases' => $config['wgNamespaceIds'],
|
||||
'wgMetaNamespace' => strtr( $config['wgFormattedNamespaces'][NS_PROJECT], ' ', '_' ),
|
||||
'wgMetaNamespaceTalk' => strtr( $config['wgFormattedNamespaces'][NS_PROJECT_TALK], ' ', '_' ),
|
||||
|
@ -34,7 +32,7 @@ class ApiDiscussionToolsPageInfoTest extends ApiTestCase {
|
|||
// Data used for the tests assumes there are no variants for English.
|
||||
// Language variants are tested using other languages.
|
||||
'wgUsePigLatinVariant' => false,
|
||||
] );
|
||||
] + $config );
|
||||
$this->setUserLang( $config['wgContentLanguage'] );
|
||||
$this->setContentLang( $config['wgContentLanguage'] );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue