MediaWiki  1.33.0
InterwikiHooks.php
Go to the documentation of this file.
1 <?php
2 
4 
6  public static function onExtensionFunctions() {
7  global $wgInterwikiViewOnly;
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 ) {
22  global $wgInterwikiViewOnly;
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 ) {
30  global $wgInterwikiCentralDB;
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 }
Language\fetchLanguageName
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:933
InterwikiHooks
Definition: InterwikiHooks.php:5
value
if( $inline) $status value
Definition: SyntaxHighlight.php:345
$res
$res
Definition: database.txt:21
InterwikiHooks\onInterwikiLoadPrefix
static onInterwikiLoadPrefix( $prefix, &$iwData)
Definition: InterwikiHooks.php:29
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
InputBox
InputBox class.
Definition: InputBox.php:12
$dbr
$dbr
Definition: testCompression.php:50
name
and how to run hooks for an and one after Each event has a name
Definition: hooks.txt:6
InterwikiHooks\onUserGetAllRights
static onUserGetAllRights(array &$rights)
Definition: InterwikiHooks.php:21
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2636
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
div
div
Definition: parserTests.txt:6850
form
null means default in associative array form
Definition: hooks.txt:1985
MediaWiki
This document describes the state of Postgres support in MediaWiki
Definition: postgres.txt:4
$wgLogTypes
$wgLogTypes
The logging system has two levels: an event type, which describes the general category and can be vie...
Definition: DefaultSettings.php:7676
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
array
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))
captcha-old.action
action
Definition: captcha-old.py:212
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:2602
language
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 distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed we want its recipients to know that what they have is not the so that any problems introduced by others will not reflect on the original authors reputations any free program is threatened constantly by software patents We wish to avoid the danger that redistributors of a free program will individually obtain patent in effect making the program proprietary To prevent we have made it clear that any patent must be licensed for everyone s free use or not licensed at all The precise terms and conditions for distribution and modification follow GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR DISTRIBUTION AND MODIFICATION This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License The refers to any such program or and a work based on the Program means either the Program or any derivative work under copyright a work containing the Program or a portion of either verbatim or with modifications and or translated into another language(Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying
InterwikiHooks\onExtensionFunctions
static onExtensionFunctions()
Definition: InterwikiHooks.php:6
style
Bar style
Definition: parserTests.txt:218
type
! test InputBox type
Definition: inputBoxParserTests.txt:2
Test
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
options
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In we can take all the code that deals with the little used title reversing options(say) and put it in one place. Instead of having little title-reversing if-blocks spread all over the codebase in showAnArticle