Page MenuHomePhabricator

[GeoData] extension.json config is not loaded by install.php --with-extensions
Closed, ResolvedPublic

Description

When using the CLI installer and have it automatically load extensions, GeoData\Hooks::onLoadExtensionSchemaUpdates fails:

$ php maintenance/install.php --dbname geodata --dbpath /tmp/bla --dbtype sqlite --pass secret --with-extensions GeoDataWiki Wikiadmin
Creating main page with default content
done
Creating tables for enabled extensions
[0620ee5a8b1657d11548a3c8] [no req]   MWException from line 38 of extensions/GeoData/includes/Hooks.php: Unrecognized backend ''
Backtrace:
#0 includes/Hooks.php(177): GeoData\Hooks::onLoadExtensionSchemaUpdates(SqliteUpdater)
#1 includes/Hooks.php(205): Hooks::callHook(string, array, array, NULL)
#2 includes/installer/DatabaseUpdater.php(127): Hooks::run(string, array)
#3 includes/installer/DatabaseUpdater.php(192): DatabaseUpdater->__construct(Wikimedia\Rdbms\DatabaseSqlite, boolean, NULL)
#4 includes/installer/DatabaseInstaller.php(312): DatabaseUpdater::newForDB(Wikimedia\Rdbms\DatabaseSqlite)
#5 includes/installer/Installer.php(1563): DatabaseInstaller->createExtensionTables(SqliteInstaller)
#6 includes/installer/CliInstaller.php(138): Installer->performInstallation(array, array)
#7 maintenance/install.php(125): CliInstaller->execute()
#8 maintenance/doMaintenance.php(94): CommandLineInstaller->execute()
#9 maintenance/install.php(175): require_once(string)
#10 {main}

The extension hook:

public static function onLoadExtensionSchemaUpdates( DatabaseUpdater $updater ) {
    global $wgGeoDataBackend;

    if ( $wgGeoDataBackend != 'db' && $wgGeoDataBackend != 'elastic' ) {
        throw new MWException( "Unrecognized backend '$wgGeoDataBackend'" );
    }

$wgGeoDataBackend has a default in extension.json:

{
    "config": {
        "GeoDataBackend": {
            "value": "db"
        },
}

So I guess when LoadExtensionSchemaUpdates fires, the extension registry has not loaded the extension configuration settings.

Event Timeline

hashar triaged this task as Medium priority.May 4 2018, 11:07 AM
hashar created this task.

Change 430887 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/core@master] installer: load extension when including them

https://gerrit.wikimedia.org/r/430887

Change 430888 had a related patch set uploaded (by Hashar; owner: Hashar):
[mediawiki/extensions/GeoData@master] (DO NOT SUBMIT) test install.php --with-extensions

https://gerrit.wikimedia.org/r/430888

I -2'd the patch because it's probably going to break a lot of things when parser hooks start being triggered. I would recommend GeoData always create the database tables. At the stage of the installer it would have been impossible for anyone to change the backend yet. And if they do immediately switch to the elastic backend, there's no harm in keeping the database tables around even though they're empty.

Change 430887 abandoned by Hashar:
installer: load extension when including them

Reason:
Thanks!!! :)

https://gerrit.wikimedia.org/r/430887

My patch looked seducing on the paper and even managed to fix that specific use case. Apparently only GeoData is affected, so yeah I will craft a patch following your guidance. Thank you!

The issue here is not that it needs to decide whether to create tables, it's about knowing which tables to create. I'm fairly confident that Antoine's solution is the correct one (even if it needs some tweaking). The immediate problem can be fixed with assuming that no configuration means 'db' or something.

@MaxSem would you mind crafting such a patch? I know nothing about GeoData and my MediaWiki is really rusted :(

Change 431013 had a related patch set uploaded (by MaxSem; owner: MaxSem):
[mediawiki/extensions/GeoData@master] Fix table creation via installer

https://gerrit.wikimedia.org/r/431013

Change 431013 merged by jenkins-bot:
[mediawiki/extensions/GeoData@master] Fix table creation via installer

https://gerrit.wikimedia.org/r/431013

Change 433292 had a related patch set uploaded (by Legoktm; owner: MaxSem):
[mediawiki/extensions/GeoData@REL1_31] Fix table creation via installer

https://gerrit.wikimedia.org/r/433292

Change 433292 merged by jenkins-bot:
[mediawiki/extensions/GeoData@REL1_31] Fix table creation via installer

https://gerrit.wikimedia.org/r/433292

hashar assigned this task to MaxSem.

@MaxSem / @Legoktm the Jenkins job / Quibble is now able to run the MediaWiki installer. It still fails later on in the build that is probably nt related to this. I might need to later on add backports for 1.27 and 1.29 but essentially this task is solved.

THANK YOU!

Change 430888 abandoned by Hashar:
(DO NOT SUBMIT) test install.php --with-extensions

https://gerrit.wikimedia.org/r/430888

Vvjjkkii renamed this task from [GeoData] extension.json config is not loaded by install.php --with-extensions to gmdaaaaaaa.Jul 1 2018, 1:11 AM
Vvjjkkii reopened this task as Open.
Vvjjkkii removed MaxSem as the assignee of this task.
Vvjjkkii raised the priority of this task from Medium to High.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed subscribers: gerritbot, Aklapper.
CommunityTechBot renamed this task from gmdaaaaaaa to [GeoData] extension.json config is not loaded by install.php --with-extensions.Jul 2 2018, 2:03 PM
CommunityTechBot closed this task as Resolved.
CommunityTechBot assigned this task to MaxSem.
CommunityTechBot lowered the priority of this task from High to Medium.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added subscribers: gerritbot, Aklapper.