Re: Get a configuration variable at runtime

יגאל חיטרון <[email protected]>
Newsgroups gmane.science.linguistics.wikipedia.technical
Message-ID <CAC1z5tC=R3XkTOuEMVmZHs71iBe0fXZXzMst6BK9iLNQQCswcw@mail.gmail.com>
The answer to both of you. The extension GlobalWatchlist needs to know for
every wikisite in a wikifarm, if it's LTR or RTL. This is because the
Special Page shows many sections, each from different wiki, on this wiki's
language. So, we need a function, that gets 'en.wikipedia.org' as a
parameter and returns 'ltr'. For now, there is a hardcoded list of rtl
language codes there, as regex, which for my sake is worse that using API,
just IMHO. It was always a bad solution, but when I implemented it years
ago, we didn't know other choice. Now I'm aware of the SiteMatrix
extension, which evaluates this mapping on runtime, and I can use the API
call to retrieve the relevant information. I looked a lot for a way to
avoid it. I think I found a way to get a direction from the language code,
but I still can't get the language code from the URL. I can guess it from '
en.wikipedia.org', but not from 'commons.wikimedia.org', and not from '
abcdefgh.catalyst.wmcloud.org'. So, as for now, I don't see another way
except for the API call.
Igal
https://phabricator.wikimedia.org/T412505


בתאריך יום ה׳, 18 בדצמ׳ 2025, 00:30, מאת John ‏<[email protected]>:

> One of the rules I’ve always used when proving support is don’t tell me
> how you want to do something. Tell me the goal, and we can get a solution.
> The method you are trying to use may or may not be optimal.
>
>
> On Wed, Dec 17, 2025 at 5:13 PM Brian Wolff <[email protected]> wrote:
>
>> Generally speaking, calling the action api externally is strongly
>> discouraged. Typically there is a backend function that is prefered instead.
>>
>> Whether that is actually true in your case depends on what you are doing.
>> Whether or not your case would be an acceptable exception to the general
>> rule would depend on the specifics of what you are doing and if there
>> really is no other reasonable option.
>>
>> --
>> Brian/bawolff
>>
>>
>> On Wednesday, 17 December 2025, יגאל חיטרון <[email protected]>
>> wrote:
>>
>>> Well, I started to think, after reading a lot of documentation and a lot
>>> of gerrit code, that my previous knowledge was wrong, and I have no choice
>>> but calling API from inside Mediawiki php, despite the words in Mediawiki
>>> developers guide "If you use an API call in Mediawiki php code, you're
>>> doing something wrong." Looks like I have no other choice. If nobody here
>>> says I can't do this, I'll start to write. Thank you.
>>> Igal
>>>
>>>
>>>
>>> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>> Virus-free.www.avg.com
>>> <http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
>>> <#m_-1276708365409787417_m_6372061225327250602_m_1407805277756859967_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>
>>> ‫בתאריך יום ד׳, 17 בדצמ׳ 2025 ב-19:21 מאת יגאל חיטרון <‪
>>> [email protected]‬‏>:‬
>>>
>>>> Thanks, but I'm not so sure. I already saw this line. The API returns
>>>> something with more than 10000 lines.
>>>> https://www.mediawiki.org/w/api.php?action=sitematrix&format=json&smsiteprop=url%7Cdbname%7Ccode%7Csitename%7Clang&formatversion=2.
>>>> I wanted just to call the API from PHP, until read in developers guide "If
>>>> you call API you're doing something wrong".
>>>> Igal
>>>>
>>>> בתאריך יום ד׳, 17 בדצמ׳ 2025, 19:16, מאת Brian Wolff ‏<
>>>> [email protected]>:
>>>>
>>>>> It should be defined at
>>>>> https://gerrit.wikimedia.org/g/operations/mediawiki-config/+/df0f99e231a682f63f82e4b4a00ecce52bd22ed9/wmf-config/CommonSettings.php#1324
>>>>> . As far as i can tell its not set dynamiclly so should have the same value
>>>>> at all wikimedia wikis.
>>>>>
>>>>> --
>>>>> Bawolff
>>>>>
>>>>> On Wednesday, 17 December 2025, יגאל חיטרון <[email protected]>
>>>>> wrote:
>>>>>
>>>>>> I've made a Gerrit change for a Phabricator task that uses the
>>>>>> $wgSiteMatrixSites variable, which is created at runtime. How can I view
>>>>>> its value on Meta?
>>>>>>
>>>>>> The issue is that this variable seems to have a different structure
>>>>>> on each site, depending on the available data. I’ve written traversal code
>>>>>> designed to handle any possible structure, but I can’t confirm if it works
>>>>>> correctly for Meta.
>>>>>>
>>>>>> If I could get the Meta value—or even just the first few pages—it
>>>>>> would be very helpful.
>>>>>>
>>>>>> Thank you in advance.
>>>>>> Igal (User:Ikhitron)
>>>>>>
>>>>> _______________________________________________
>>>>> Wikitech-l mailing list -- [email protected]
>>>>> To unsubscribe send an email to [email protected]
>>>>>
>>>>> https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/
>>>>
>>>> _______________________________________________
>> Wikitech-l mailing list -- [email protected]
>> To unsubscribe send an email to [email protected]
>>
>> https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/
>
> _______________________________________________
> Wikitech-l mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/

_______________________________________________
Wikitech-l mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.