X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=includes%2FSiteConfiguration.php;h=cab98a7c63003deae11699275fb953f1cda4a3b4;hp=af65e457a5cde2f83cd3e0bb6e883bed9887d26d;hb=4226fada45a83ad56e91ce7638d17d12fecec8ca;hpb=8821d3cb1f3e368bd61f116c75287de1ec1c481b diff --git a/includes/SiteConfiguration.php b/includes/SiteConfiguration.php index af65e457a5..cab98a7c63 100644 --- a/includes/SiteConfiguration.php +++ b/includes/SiteConfiguration.php @@ -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 ]; } @@ -561,7 +562,7 @@ class SiteConfiguration { ->execute(); $data = trim( $result->getStdout() ); - if ( $result->getExitCode() != 0 || !strlen( $data ) ) { + if ( $result->getExitCode() || $data === '' ) { throw new MWException( "Failed to run getConfiguration.php: {$result->getStdout()}" ); } $res = unserialize( $data ); @@ -581,14 +582,14 @@ class SiteConfiguration { * which is not fun * * @param array $array1 + * @param array ...$arrays * * @return array */ - static function arrayMerge( $array1/* ... */ ) { + static function arrayMerge( array $array1, ...$arrays ) { $out = $array1; - $argsCount = func_num_args(); - for ( $i = 1; $i < $argsCount; $i++ ) { - foreach ( func_get_arg( $i ) as $key => $value ) { + foreach ( $arrays as $array ) { + foreach ( $array as $key => $value ) { if ( isset( $out[$key] ) && is_array( $out[$key] ) && is_array( $value ) ) { $out[$key] = self::arrayMerge( $out[$key], $value ); } elseif ( !isset( $out[$key] ) || !$out[$key] && !is_numeric( $key ) ) {