Jump to content

Manual talk:Modeling pages

Add topic
From mediawiki.org
Latest comment: 3 months ago by DKinzler (WMF) in topic What to use instead of Title?

Overview table

[edit]

@DKinzler (WMF) Is it necessary to separate title text and DB key in the overview table? You can easily convert one to the other by switching underscores and spaces, after all.

I worry that the table is just too large to make sense of.

I've also considered other ways to simplify it, by removing some less often used items. We could avoid including revision ID / PageRecord / WikiPage in the table, and just leave their explanations in the text. Matma Rex (talk) 17:23, 10 July 2023 (UTC)Reply

You can convert between title text and DB key, but you shouldn't... that relationship should be encapsulated in MediaWikiTitleCodec. The point is really that only LinkTarget has this concept, the others don't - they represent a thing in the database.
The table is a bit much, but then, it's a good overview. I like it. DKinzler (WMF) (talk) 17:50, 10 July 2023 (UTC)Reply
I don’t think the table is too large. The colored ticks/crosses make it easy to understand it at a glance. Having many rows and columns highlights the fine differences in a visual way (e.g. PageRecord has no footnote in the Wiki ID column → it handles the wiki ID as one would expect). —Tacsipacsi (talk) 18:29, 27 July 2023 (UTC)Reply

What to use instead of Title?

[edit]

Asking "does a page exist" is easy with tried and true Title class:


$title = Title::newFromText( 'Obscure page', NS_MAIN );
echo $title->exists();


This article says this is a legacy model and discouraged. But how to get a PageIdentity without the use of Title?
Oreolek (talk) 07:49, 3 August 2024 (UTC)Reply

Using the PageStore class. The direct translation of your code would be:
$pageStore = MediaWikiServices::getInstance()->getPageStore();
$pageIdentity = $pageStore->getPageByText( 'Obscure page', NS_MAIN );
echo $pageIdentity->exists();
Matma Rex (talk) 15:03, 3 August 2024 (UTC)Reply
I added a section describing the relevant service objects. DKinzler (WMF) (talk) 15:04, 5 August 2024 (UTC)Reply