I've reverted a number of recent commits to the Title class which added several more pre-cached fields to it, as I really don't think we want that sort of data in Title objects to begin with. A Title object is meant to represent a... well, a page title :) and as such should be roughly equivalent to passing the string-form title around, but without having to parse and de-parse the items all the time.
Since ancient times we've had a couple things like an article ID being saved into local state, which is frequently useful to optimize lookups but has its own problems (it has to be explicitly cleared or reset from time to time). These really belong more in a 'Page' object than a 'Title' however.
These days we've got a WikiPage class which has been further split from Article as well; it seems to me that these sorts of things might belong better there than in Title. Thoughts?
-- brion
On Tue, 03 Jan 2012 13:50:11 -0800, Brion Vibber brion@pobox.com wrote:
I've reverted a number of recent commits to the Title class which added several more pre-cached fields to it, as I really don't think we want that sort of data in Title objects to begin with. A Title object is meant to represent a... well, a page title :) and as such should be roughly equivalent to passing the string-form title around, but without having to parse and de-parse the items all the time.
Since ancient times we've had a couple things like an article ID being saved into local state, which is frequently useful to optimize lookups but has its own problems (it has to be explicitly cleared or reset from time to time). These really belong more in a 'Page' object than a 'Title' however.
These days we've got a WikiPage class which has been further split from Article as well; it seems to me that these sorts of things might belong better there than in Title. Thoughts?
-- brion
Sure. Though I don't like the way we're currently passing around a WikiPage instance as a completely separate entity from the Title when the WikiPage isn't supposed to have any state of it's own that would make it reasonable to have any more than one WikiPage instance per title. ((We have constructors being created with formats like ( Page $page, IContextSource $context = null ) where a WikiPage instance is being passed despite the fact that the context should already contain enough information))
We may want to remedy that first either by adding a getWikiPage to IContextSource or by making a WikiPage method that will return a singleton-per-title.
Le 3 janv. 2012 à 22:50, Brion Vibber a écrit :
I've reverted a number of recent commits to the Title class which added several more pre-cached fields to it, as I really don't think we want that sort of data in Title objects to begin with. A Title object is meant to represent a... well, a page title :) and as such should be roughly equivalent to passing the string-form title around, but without having to parse and de-parse the items all the time.
Since ancient times we've had a couple things like an article ID being saved into local state, which is frequently useful to optimize lookups but has its own problems (it has to be explicitly cleared or reset from time to time). These really belong more in a 'Page' object than a 'Title' however.
These days we've got a WikiPage class which has been further split from Article as well; it seems to me that these sorts of things might belong better there than in Title. Thoughts?
-- brion
I added those fields to the Title class to avoid some DB queries and avoid code duplication. The problem is that currently the WikiPage instance created in Wiki.php is not stored in the context object (you can grep for "WikiPage::factory" to see how many times that method is called). This means that every time another instance of that class is created there will be a new database query. I think we need to store the WikiPage object in RequestContext to be able to share that object and thus avoiding those database queries.
Alexandre Emsenhuber (ialex)
On Wed, Jan 4, 2012 at 12:10 AM, IAlex ialex.wiki@gmail.com wrote:
I added those fields to the Title class to avoid some DB queries and avoid code duplication.
*nod* they're just not generally applicable to many circumstances, and really are page-data not title-data to begin with.
The problem is that currently the WikiPage instance created in Wiki.php is not stored in the context object (you can grep for "WikiPage::factory" to see how many times that method is called). This means that every time another instance of that class is created there will be a new database query. I think we need to store the WikiPage object in RequestContext to be able to share that object and thus avoiding those database queries.
That sounds like it would be reasonable; any objections?
-- brion
I'd agree with reducing the state within Title and narrowing down it's purpose to title sanitization/validation and such.
-- View this message in context: http://wikimedia.7.n6.nabble.com/Title-objects-as-value-objects-split-with-W... Sent from the Wikipedia Developers mailing list archive at Nabble.com.
wikitech-l@lists.wikimedia.org