X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FSiteConfiguration.php;h=7af80dcfd6e3746042c537c19f5a1b87e42a0f69;hp=6bd179a9daa2a60e3d8235f5a61f09f0791c4feb;hb=51945dbca3594;hpb=8eb6cf585c5fb3d7dd5f014bac27518959512b98 diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index 6bd179a9da..7af80dcfd6 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -180,7 +180,7 @@ class SiteConfiguration { * Retrieves a configuration setting for a given wiki. * @param string $settingName ID of the setting name to retrieve * @param string $wiki Wiki ID of the wiki in question. - * @param string $suffix The suffix of the wiki in question. + * @param string|null $suffix The suffix of the wiki in question. * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. * @return mixed The value of the setting requested. @@ -294,7 +294,7 @@ class SiteConfiguration { /** * Gets all settings for a wiki * @param string $wiki Wiki ID of the wiki in question. - * @param string $suffix The suffix of the wiki in question. + * @param string|null $suffix The suffix of the wiki in question. * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. * @return array Array of settings requested. @@ -325,7 +325,7 @@ class SiteConfiguration { * Retrieves a configuration setting for a given wiki, forced to a boolean. * @param string $setting ID of the setting name to retrieve * @param string $wiki Wiki ID of the wiki in question. - * @param string $suffix The suffix of the wiki in question. + * @param string|null $suffix The suffix of the wiki in question. * @param array $wikiTags The tags assigned to the wiki. * @return bool The value of the setting requested. */ @@ -364,7 +364,7 @@ class SiteConfiguration { * Retrieves the value of a given setting, and places it in its corresponding global variable. * @param string $setting ID of the setting name to retrieve * @param string $wiki Wiki ID of the wiki in question. - * @param string $suffix The suffix of the wiki in question. + * @param string|null $suffix The suffix of the wiki in question. * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. */ @@ -399,7 +399,7 @@ class SiteConfiguration { /** * Retrieves the values of all settings, and places them in their corresponding global variables. * @param string $wiki Wiki ID of the wiki in question. - * @param string $suffix The suffix of the wiki in question. + * @param string|null $suffix The suffix of the wiki in question. * @param array $params List of parameters. $.'key' is replaced by $value in all returned data. * @param array $wikiTags The tags assigned to the wiki. */ @@ -432,7 +432,7 @@ class SiteConfiguration { return $default; } - $ret = call_user_func_array( $this->siteParamsCallback, [ $this, $wiki ] ); + $ret = ( $this->siteParamsCallback )( $this, $wiki ); # Validate the returned value if ( !is_array( $ret ) ) { return $default; @@ -483,13 +483,13 @@ class SiteConfiguration { /** * Work out the site and language name from a database name - * @param string $db + * @param string $wiki Wiki ID * * @return array */ - public function siteFromDB( $db ) { + public function siteFromDB( $wiki ) { // Allow override - $def = $this->getWikiParams( $db ); + $def = $this->getWikiParams( $wiki ); if ( !is_null( $def['suffix'] ) && !is_null( $def['lang'] ) ) { return [ $def['suffix'], $def['lang'] ]; } @@ -499,15 +499,16 @@ class SiteConfiguration { foreach ( $this->suffixes as $altSite => $suffix ) { if ( $suffix === '' ) { $site = ''; - $lang = $db; + $lang = $wiki; break; - } elseif ( substr( $db, -strlen( $suffix ) ) == $suffix ) { + } elseif ( substr( $wiki, -strlen( $suffix ) ) == $suffix ) { $site = is_numeric( $altSite ) ? $suffix : $altSite; - $lang = substr( $db, 0, strlen( $db ) - strlen( $suffix ) ); + $lang = substr( $wiki, 0, strlen( $wiki ) - strlen( $suffix ) ); break; } } $lang = str_replace( '_', '-', $lang ); + return [ $site, $lang ]; } @@ -527,7 +528,7 @@ class SiteConfiguration { $multi = is_array( $settings ); $settings = (array)$settings; - if ( $wiki === wfWikiID() ) { // $wiki is this wiki + if ( WikiMap::isCurrentWikiId( $wiki ) ) { // $wiki is this wiki $res = []; foreach ( $settings as $name ) { if ( !preg_match( '/^wg[A-Z]/', $name ) ) { @@ -606,7 +607,7 @@ class SiteConfiguration { public function loadFullData() { if ( $this->fullLoadCallback && !$this->fullLoadDone ) { - call_user_func( $this->fullLoadCallback, $this ); + ( $this->fullLoadCallback )( $this ); $this->fullLoadDone = true; } }