Jump to content

Manual talk:Modeling pages

Add topic
From mediawiki.org
Latest comment: 22 days ago by DKinzler (WMF) in topic PageReferences cannot be interwiki links

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
[edit]

@Novem Linguae @DKinzler (WMF) Regarding Special:Diff/6873892 – I think the confusion stems from the fact that PageReference knows which wiki it belongs to (as a WikiAwareEntity), but it doesn't know what interwiki prefix can be used to link to that wiki. (In fact I don't know off the top of my head how you would look up that prefix, given a wiki ID from WikiAwareEntity… WikiMap lets you make external links to the other wiki, but not interwiki links.) Maybe the distinction could be clarified in the text. Matma Rex (talk) 08:29, 29 November 2024 (UTC)Reply

Yes indeed, the last section of the page discusses this issue in detail. DKinzler (WMF) (talk) 08:39, 29 November 2024 (UTC)Reply
...it's annyoing conceptually, and tricky to fix. An in practice, we don't really have a need for fixing it. So we never did... DKinzler (WMF) (talk) 08:40, 29 November 2024 (UTC)Reply