Last modified: 2010-05-15 16:03:48 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 T15878, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 13878 - Article class should use Article->getDB consistently
Article class should use Article->getDB consistently
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.13.x
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
http://svn.wikimedia.org/viewvc/media...
:
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: ---


Attachments

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.


Navigation
Links