MediaWiki REL1_33
ApiPrefixUniquenessTest.php
Go to the documentation of this file.
1<?php
2
10
11 public function testPrefixes() {
12 $main = new ApiMain( new FauxRequest() );
13 $query = new ApiQuery( $main, 'foo' );
14 $moduleManager = $query->getModuleManager();
15
16 $modules = $moduleManager->getNames();
17 $prefixes = [];
18
19 foreach ( $modules as $name ) {
20 $module = $moduleManager->getModule( $name );
21 $class = get_class( $module );
22
23 $prefix = $module->getModulePrefix();
24 if ( $prefix === '' /* HACK: T196962 */ || $prefix === 'wbeu' ) {
25 continue;
26 }
27
28 if ( isset( $prefixes[$prefix] ) ) {
29 $this->fail(
30 "Module prefix '{$prefix}' is shared between {$class} and {$prefixes[$prefix]}"
31 );
32 }
33 $prefixes[$module->getModulePrefix()] = $class;
34
35 if ( $module instanceof ApiQueryGeneratorBase ) {
36 // namespace with 'g', a generator can share a prefix with a module
37 $prefix = 'g' . $prefix;
38 if ( isset( $prefixes[$prefix] ) ) {
39 $this->fail(
40 "Module prefix '{$prefix}' is shared between {$class} and {$prefixes[$prefix]}" .
41 " (as a generator)"
42 );
43 }
44 $prefixes[$module->getModulePrefix()] = $class;
45 }
46 }
47 $this->assertTrue( true ); // dummy call to make this test non-incomplete
48 }
49}
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
This is the main API class, used for both external and internal processing.
Definition ApiMain.php:41
Checks that all API query modules, core and extensions, have unique prefixes.
This is the main query class.
Definition ApiQuery.php:36
WebRequest clone which takes values from a provided array.
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition hooks.txt:1617