/**
* 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'] ];
}
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 ];
}
$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 ) ) {
->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 );
* 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 ) ) {