Page MenuHomePhabricator

Install seems to try to GRANT when not necessary
Closed, ResolvedPublic

Description

Author: pioto

Description:
I've tried testing out installing MediaWiki 1.17.0beta1 in an environment where the database has been created, using a user that already exists with privileges to use the database, but not to grant use to anyone else. I've entered the same username & password for both the "Install" database user and the regular database user (as in, I selected the "use the same user" radio button). However, my install ends up failing with this error:

Granting permission to user "testuser" failed: A database query syntax error has occurred. The last attempted database query was: "GRANT ALL PRIVILEGES ON testuser_mediawiki.* TO 'testuser'@'db.example.com'" from within function "MysqlInstaller::setupUser". Database returned error "1044: Access denied for user 'testuser'@'%' to database 'testuser_mediawiki' (db.example.com)" Backtrace:

0 /www/testuser/mediawiki-test/includes/db/Database.php(751): DatabaseBase->reportQueryError('Access denied f...', 1044, 'GRANT ALL PRIVI...', 'MysqlInstaller:...', false)
1 /www/testuser/mediawiki-test/includes/installer/MysqlInstaller.php(503): DatabaseBase->query('GRANT ALL PRIVI...', 'MysqlInstaller:...')
2 [internal function]: MysqlInstaller->setupUser(Object(MysqlInstaller))
3 /www/testuser/mediawiki-test/includes/installer/Installer.php(1293): call_user_func(Array, Object(MysqlInstaller))
4 /www/testuser/mediawiki-test/includes/installer/WebInstallerPage.php(1084): Installer->performInstallation(Array, Array)
5 /www/testuser/mediawiki-test/includes/installer/WebInstaller.php(246): WebInstaller_Install->execute()
6 /www/testuser/mediawiki-test/mw-config/index.php(46): WebInstaller->execute(Array)
7 /www/testuser/mediawiki-test/mw-config/index.php(14): wfInstallerMain()
8 {main}

So, even though it is seeming to use the user that I entered, it seems to want to try to grant privileges to use the database that it's already connected to to itself, which seems silly.

I tried tracing through the code in /includes/installer/MysqlInstaller.php's canCreateAccounts(), but I can't see why it would think this user would be able to create an account.

I think that I might see the problem:

452 } else {
453 $grantableNames[] = $this->buildFullUserName( $dbUser, $server );
454 $tryToCreate = false;
455 }

So, that means that it will try to grant privileges to itself, in this case, at least as far as I can tell. Maybe the code should specifically check to see if the $this->getVar('_InstallUser') equals $this->getVar('wgDBuser') and just return early from setupUser()


Version: 1.17.x
Severity: normal

Details

Reference
bz28917

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 11:27 PM
bzimport set Reference to bz28917.
bzimport added a subscriber: Unknown Object (MLST).

I already do check for that case and return early. The first few lines of setupAccounts() are:

$dbUser = $this->getVar( 'wgDBuser' );
if( $dbUser == $this->getVar( '_InstallUser' ) ) {
return Status::newGood();
}

Grrr, my mistake, it never got merged to 1.17 from trunk.

See r87512, that should fix it.

pioto wrote:

(In reply to comment #3)

See r87512, that should fix it.

Thanks, I'll give that a try.

marking this resolved for now, reopen if the diff doesn't fix it