MediaWiki REL1_33
InterwikiHooks.php
Go to the documentation of this file.
1<?php
2
4
6 public static function onExtensionFunctions() {
8
9 if ( !$wgInterwikiViewOnly ) {
10 global $wgLogTypes;
11
12 // Set up the new log type - interwiki actions are logged to this new log
13 // TODO: Move this out of an extension function once T200385 is implemented.
14 $wgLogTypes[] = 'interwiki';
15 }
16 }
17
21 public static function onUserGetAllRights( array &$rights ) {
23 if ( !$wgInterwikiViewOnly ) {
24 // New user right, required to modify the interwiki table through Special:Interwiki
25 $rights[] = 'interwiki';
26 }
27 }
28
29 public static function onInterwikiLoadPrefix( $prefix, &$iwData ) {
31 // docs/hooks.txt says: Return true without providing an interwiki to continue interwiki search.
32 if ( $wgInterwikiCentralDB === null || $wgInterwikiCentralDB === wfWikiID() ) {
33 // No global set or this is global, nothing to add
34 return true;
35 }
36 if ( !Language::fetchLanguageName( $prefix ) ) {
37 // Check if prefix exists locally and skip
38 $lookup = MediaWikiServices::getInstance()->getInterwikiLookup();
39 foreach ( $lookup->getAllPrefixes( null ) as $id => $localPrefixInfo ) {
40 if ( $prefix === $localPrefixInfo['iw_prefix'] ) {
41 return true;
42 }
43 }
44 $dbr = wfGetDB( DB_REPLICA, [], $wgInterwikiCentralDB );
45 $res = $dbr->selectRow(
46 'interwiki',
47 '*',
48 [ 'iw_prefix' => $prefix ],
49 __METHOD__
50 );
51 if ( !$res ) {
52 return true;
53 }
54 // Excplicitly make this an array since it's expected to be one
55 $iwData = (array)$res;
56 // At this point, we can safely return false because we know that we have something
57 return false;
58 }
59 return true;
60 }
61
62}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
static onUserGetAllRights(array &$rights)
static onInterwikiLoadPrefix( $prefix, &$iwData)
static onExtensionFunctions()
MediaWikiServices is the service locator for the application scope of MediaWiki.
$res
Definition database.txt:21
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
const DB_REPLICA
Definition defines.php:25