Last modified: 2010-05-15 16:03:48 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 13878 - Article class should use Article->getDB consistently
Article class should use Article->getDB consistently
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
Depends on:
Blocks: code_quality
  Show dependency treegraph
Reported: 2008-04-29 17:31 UTC by Christian Neubauer
Modified: 2010-05-15 16:03 UTC (History)
2 users (show)

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


Description Christian Neubauer 2008-04-29 17:31:22 UTC
The Article class has a function called getDB which returns wfGetDB( DB_MASTER ).  Its called 3 times or so in the code, but there are still alot of places where its not used and wfGetDB is called directly.  The class should be consistent one way or the other in using this function.
Comment 1 Brion Vibber 2008-04-29 18:24:00 UTC
This method originally chose _either_ a master or slave, depending on whether things were going to be written to or not. This ended up being kind of weird and unreliable; data pulled from slaves was relatively likely to end up out-of-date shortly after an edit due to replication lag, which then polluted caches and generally caused trouble.

This was thus hacked to always hit the master for better reliability, and the hack ended up in core.

Since revision and text data are now in separate tables, these days we pull most of _that_ from slaves while getting the latest article metadata (name, cache invalidation timestamp, and latest revision number) from the master, always up to date, with relatively little load to the master as it's a simple row load.

Article::getDB() should itself be phased out, as it no longer serves any purpose in selecting a database connection.
Comment 2 Huji 2008-04-29 18:25:20 UTC
On line 74 we have:

$dbr = wfGetDB(DB_SLAVE);

Currently, getDB member function doesn't accept a parameter and only connects to DB_MASTER. We can't use it for above line, unless we either accept to connect to DB_MASTER instead of DB_SLAVE (!) or change getDB to accept parameters (and then what is the difference between using it and using wfGetDB?!)

So, I agree with what brion said (and caused a mid-air collision while I was sending this!)
Comment 3 Chad H. 2008-06-16 14:19:38 UTC
Last of Article::getDB() phased out in r36334. The method has been deprecated, but retains the old functionality, just in case someone out there is using it in an extension.

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