Reuse the WikiPage object to save a db query
authorBrian Wolff <bawolff+wn@gmail.com>
Fri, 4 Jan 2013 09:11:13 +0000 (05:11 -0400)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 4 Jan 2013 13:05:09 +0000 (13:05 +0000)
commit9e5802ef66c8a3aef2d7f63eb63c0cd5058f73e8
tree6b084aa79966605b99eda8d30a3fcd05d6cc77cb
parentd3c07ddb6fd0b6ee71afbf2aad788c1308f7fa3d
Reuse the WikiPage object to save a db query

Early in the request we call Action::getActionName to get the action
name for HTMLFileCache to see if the current action is cached.
This causes data to be loaded from the WikiPage object
stored in the main request context. However, later when
we're initializing the Article object, we overwrite that
WikiPage object with the one used by the Article object.
Later on the WikiPage object has to be re-loaded, and
hence the exact same db request is run twice in one request,
which seems wasteful.

Instead, initialize the Article object using the WikiPage
object from the context, in order to save the already
loaded data.

Change-Id: I292f0d70feb505fae5fa955fd735d85ad3b22fea
includes/Wiki.php