Hitchwiki / hitchwiki

The Hitchhiker's Guide to Hitchhiking the World
https://hitchwiki.org
32 stars 9 forks source link

Fix configuring SpoofUser when running `vagrant up` first time #110

Closed simison closed 7 years ago

simison commented 7 years ago
==> default: Point Mediawiki configuration to Hitchwiki configuration file...
==> default: Pre-populate the antispoof (MW extension) table with your wiki's existing usernames...
==> default: Creating username spoofs...
==> default: ...1
==> default: [fe4b0c04bf0dec40595455c7] [no req]   DBQueryError from line 1054 of /var/www/public/wiki/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
==> default: Query: REPLACE INTO `hitchwiki_en`.`spoofuser` (su_name,su_normalized,su_legal,su_error) VALUES ('Abuse filter','v2:ABUSEFILTER','1',NULL),('Hitchwiki','v2:HITCHWIKI','1',NULL)
==> default: Function: SpoofUser::batchRecord
==> default: Error: 1146 Table 'hitchwiki_en.spoofuser' doesn't exist (localhost)
==> default: 
==> default: Backtrace:
==> default: #0 /var/www/public/wiki/includes/libs/rdbms/database/Database.php(912): Database->reportQueryError(string, integer, string, string, boolean)
==> default: #1 /var/www/public/wiki/includes/libs/rdbms/database/Database.php(2148): Database->query(string, string)
==> default: #2 /var/www/public/wiki/includes/libs/rdbms/database/DatabaseMysqlBase.php(486): Database->nativeReplace(string, array, string)
==> default: #3 /var/www/public/wiki/extensions/AntiSpoof/SpoofUser.php(130): DatabaseMysqlBase->replace(string, array, array, string)
==> default: #4 /var/www/public/wiki/extensions/AntiSpoof/maintenance/BatchAntiSpoofClass.php(18): SpoofUser::batchRecord(DatabaseMysqli, array)
==> default: #5 /var/www/public/wiki/extensions/AntiSpoof/maintenance/BatchAntiSpoofClass.php(74): BatchAntiSpoof->batchRecord(array)
==> default: #6 /var/www/public/wiki/maintenance/doMaintenance.php(111): BatchAntiSpoof->execute()
==> default: #7 /var/www/public/wiki/extensions/AntiSpoof/maintenance/batchAntiSpoof.php(5): require_once(string)
==> default: #8 {main}
simison commented 7 years ago

Removed from the Bootstrap script for now. https://github.com/Hitchwiki/hitchwiki/commit/8eeadb6bdbf52faafc1033d9ce25c5e81dde910d#diff-99962ec8289d3e550e77dcf2ef63f71cL110

We don't really need it at bootstrap phase because there aren't any users yet...

simison commented 7 years ago

Apparently we need to run this on install after all, otherwise I'm getting this when signin up:

[29db9cb3aa171c89704c46da] /en/index.php?title=Special:CreateAccount&returnto=Special:HWMap DBQueryError from line 1054 of /var/www/public/wiki/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Query: SELECT su_name FROM `hitchwiki_en`.`spoofuser`,`hitchwiki_en`.`user` WHERE su_normalized = 'v2:TESTING' AND (su_name = user_name) LIMIT 5 
Function: SpoofUser::getConflicts
Error: 1146 Table 'hitchwiki_en.spoofuser' doesn't exist (localhost)
Backtrace:

#0 /var/www/public/wiki/includes/libs/rdbms/database/Database.php(912): Database->reportQueryError(string, integer, string, string, boolean)
#1 /var/www/public/wiki/includes/libs/rdbms/database/Database.php(1254): Database->query(string, string)
#2 /var/www/public/wiki/extensions/AntiSpoof/SpoofUser.php(79): Database->select(array, array, array, string, array)
#3 /var/www/public/wiki/extensions/AntiSpoof/AntiSpoofPreAuthenticationProvider.php(52): SpoofUser->getConflicts()
#4 /var/www/public/wiki/extensions/AntiSpoof/AntiSpoofPreAuthenticationProvider.php(42): AntiSpoofPreAuthenticationProvider->testUserInternal(User, boolean, MediaWiki\Logger\LegacyLogger)
#5 /var/www/public/wiki/includes/auth/AuthManager.php(1267): AntiSpoofPreAuthenticationProvider->testForAccountCreation(User, User, array)
#6 /var/www/public/wiki/includes/auth/AuthManager.php(1129): MediaWiki\Auth\AuthManager->continueAccountCreation(array)
#7 /var/www/public/wiki/includes/specialpage/AuthManagerSpecialPage.php(360): MediaWiki\Auth\AuthManager->beginAccountCreation(User, array, string)
#8 /var/www/public/wiki/includes/specialpage/AuthManagerSpecialPage.php(484): AuthManagerSpecialPage->performAuthenticationStep(string, array)
#9 [internal function]: AuthManagerSpecialPage->handleFormSubmit(array, VFormHTMLForm)
#10 /var/www/public/wiki/includes/htmlform/HTMLForm.php(656): call_user_func(array, array, VFormHTMLForm)
#11 /var/www/public/wiki/includes/specialpage/AuthManagerSpecialPage.php(418): HTMLForm->trySubmit()
#12 /var/www/public/wiki/includes/specialpage/LoginSignupSpecialPage.php(305): AuthManagerSpecialPage->trySubmit()
#13 /var/www/public/wiki/includes/specialpage/SpecialPage.php(522): LoginSignupSpecialPage->execute(NULL)
#14 /var/www/public/wiki/includes/specialpage/SpecialPageFactory.php(576): SpecialPage->run(NULL)
#15 /var/www/public/wiki/includes/MediaWiki.php(283): SpecialPageFactory::executePath(Title, RequestContext)
#16 /var/www/public/wiki/includes/MediaWiki.php(851): MediaWiki->performRequest()
#17 /var/www/public/wiki/includes/MediaWiki.php(512): MediaWiki->main()
#18 /var/www/public/wiki/index.php(43): MediaWiki->run()
#19 {main}
simison commented 7 years ago

When running:

cd /var/www/public/wiki
php extensions/AntiSpoof/maintenance/batchAntiSpoof.php

I get error:

Creating username spoofs...
...1
[3b72d154c4e79f93363c2032] [no req]   DBQueryError from line 1054 of /var/www/public/wiki/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Query: REPLACE INTO `hitchwiki_en`.`spoofuser` (su_name,su_normalized,su_legal,su_error) VALUES ('Abuse filter','v2:ABUSEFILTER','1',NULL),('Hitchbot','v2:HITCHBOT','1',NULL),('Hitchwiki','v2:HITCHWIKI','1',NULL),('Maintenance script','v2:MAINTENANCESCRIPT','1',NULL)
Function: SpoofUser::batchRecord
Error: 1146 Table 'hitchwiki_en.spoofuser' doesn't exist (localhost)

Backtrace:
#0 /var/www/public/wiki/includes/libs/rdbms/database/Database.php(912): Database->reportQueryError(string, integer, string, string, boolean)
#1 /var/www/public/wiki/includes/libs/rdbms/database/Database.php(2148): Database->query(string, string)
#2 /var/www/public/wiki/includes/libs/rdbms/database/DatabaseMysqlBase.php(486): Database->nativeReplace(string, array, string)
#3 /var/www/public/wiki/extensions/AntiSpoof/SpoofUser.php(130): DatabaseMysqlBase->replace(string, array, array, string)
#4 /var/www/public/wiki/extensions/AntiSpoof/maintenance/BatchAntiSpoofClass.php(18): SpoofUser::batchRecord(DatabaseMysqli, array)
#5 /var/www/public/wiki/extensions/AntiSpoof/maintenance/BatchAntiSpoofClass.php(74): BatchAntiSpoof->batchRecord(array)
#6 /var/www/public/wiki/maintenance/doMaintenance.php(111): BatchAntiSpoof->execute()
#7 /var/www/public/wiki/extensions/AntiSpoof/maintenance/batchAntiSpoof.php(5): require_once(string)
#8 {main}

So then I try:

cd /var/www/public/wiki
php maintenance/update.php

...in results it has a line:

...skipping update to shared table spoofuser.

...so re-running the batchAntiSpoof.php I'm still getting the error.

Updater skips spoofuser probably because of this in our config:

$wgSharedTables[] = 'spoofuser';
simison commented 7 years ago

https://www.mediawiki.org/wiki/Manual:$wgSharedTables#Upgrading

As of Mediawiki 1.21, $wgSharedTables must be temporarily cleared during upgrade. Otherwise, the shared tables are not touched at all (neither tables with $wgSharedPrefix, nor those with $wgDBprefix), which may lead to failed upgrade.