Last modified: 2011-05-21 18:19:11 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T31074, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 29074 - DB table prefix problem when specifying DB in wfGetDB
DB table prefix problem when specifying DB in wfGetDB
Status: RESOLVED INVALID
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
1.20.x
All All
: Unprioritized normal (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-05-21 14:23 UTC by Jeroen De Dauw
Modified: 2011-05-21 18:19 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Jeroen De Dauw 2011-05-21 14:23:05 UTC
I just had a go at installing Central Notice on my local wiki and discovered it fails pretty hard when you are using DB table prefixes. I've done some debugging an one particular issue seems to be in wfGetDB. I'm getting this error:

The last attempted database query was: SELECT tmp_name FROM `cn_templates` WHERE tmp_name = '2011EditorSurvey' LIMIT 1 from within function "DatabaseBase::selectRow". Database returned error "1146: Table 'mw_trunk.cn_templates' doesn't exist (localhost)".

Which is coming from this code:

$dbr = wfGetDB( DB_SLAVE,  array(), $wgCentralDBname );
$row = $dbr->selectRow( 'cn_templates', 'tmp_name',  array( 'tmp_name' => $eTemplateName ) );

The wrong thing in the query is that it's selecting from mw_trunk.cn_templates, while I have the prefix "mw_", so it should be mw_trunk.mw_cn_templates. Apparently the $wgDBprefix does not get added when specifying the db in wfGetDB. Commenting out this argument in the above code results in a correct query (and no error).

No sure what the idea here is, and I'm not familiar with the DB code, so I'm reporting this instead of trying to fix it myself :)
Comment 1 Alexandre Emsenhuber [IAlex] 2011-05-21 18:19:11 UTC
$wgDBprefix is the prefix of the local database, so it is not used when using a foreign database, you need to pass it in the third parameter of wfGetDB() by separing it from the database name with a dash, so in you case you should set $wgCentralDBname to 'mw_trunk-mw_'.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links