MediaWiki  REL1_31
TitlePermissionTest.php
Go to the documentation of this file.
1 <?php
2 
10 
14  protected $userName, $altUserName;
15 
19  protected $title;
20 
25 
26  protected function setUp() {
27  parent::setUp();
28 
29  $localZone = 'UTC';
30  $localOffset = date( 'Z' ) / 60;
31 
32  $this->setMwGlobals( [
33  'wgLocaltimezone' => $localZone,
34  'wgLocalTZoffset' => $localOffset,
35  'wgNamespaceProtection' => [
36  NS_MEDIAWIKI => 'editinterface',
37  ],
38  ] );
39  // Without this testUserBlock will use a non-English context on non-English MediaWiki
40  // installations (because of how Title::checkUserBlock is implemented) and fail.
42 
43  $this->userName = 'Useruser';
44  $this->altUserName = 'Altuseruser';
45  date_default_timezone_set( $localZone );
46 
47  $this->title = Title::makeTitle( NS_MAIN, "Main Page" );
48  if ( !isset( $this->userUser ) || !( $this->userUser instanceof User ) ) {
49  $this->userUser = User::newFromName( $this->userName );
50 
51  if ( !$this->userUser->getId() ) {
52  $this->userUser = User::createNew( $this->userName, [
53  "email" => "test@example.com",
54  "real_name" => "Test User" ] );
55  $this->userUser->load();
56  }
57 
58  $this->altUser = User::newFromName( $this->altUserName );
59  if ( !$this->altUser->getId() ) {
60  $this->altUser = User::createNew( $this->altUserName, [
61  "email" => "alttest@example.com",
62  "real_name" => "Test User Alt" ] );
63  $this->altUser->load();
64  }
65 
66  $this->anonUser = User::newFromId( 0 );
67 
68  $this->user = $this->userUser;
69  }
70  }
71 
72  protected function setUserPerm( $perm ) {
73  // Setting member variables is evil!!!
74 
75  if ( is_array( $perm ) ) {
76  $this->user->mRights = $perm;
77  } else {
78  $this->user->mRights = [ $perm ];
79  }
80  }
81 
82  protected function setTitle( $ns, $title = "Main_Page" ) {
83  $this->title = Title::makeTitle( $ns, $title );
84  }
85 
86  protected function setUser( $userName = null ) {
87  if ( $userName === 'anon' ) {
88  $this->user = $this->anonUser;
89  } elseif ( $userName === null || $userName === $this->userName ) {
90  $this->user = $this->userUser;
91  } else {
92  $this->user = $this->altUser;
93  }
94  }
95 
101  public function testQuickPermissions() {
103  $prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
104 
105  $this->setUser( 'anon' );
106  $this->setTitle( NS_TALK );
107  $this->setUserPerm( "createtalk" );
108  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
109  $this->assertEquals( [], $res );
110 
111  $this->setTitle( NS_TALK );
112  $this->setUserPerm( "createpage" );
113  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
114  $this->assertEquals( [ [ "nocreatetext" ] ], $res );
115 
116  $this->setTitle( NS_TALK );
117  $this->setUserPerm( "" );
118  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
119  $this->assertEquals( [ [ 'nocreatetext' ] ], $res );
120 
121  $this->setTitle( NS_MAIN );
122  $this->setUserPerm( "createpage" );
123  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
124  $this->assertEquals( [], $res );
125 
126  $this->setTitle( NS_MAIN );
127  $this->setUserPerm( "createtalk" );
128  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
129  $this->assertEquals( [ [ 'nocreatetext' ] ], $res );
130 
131  $this->setUser( $this->userName );
132  $this->setTitle( NS_TALK );
133  $this->setUserPerm( "createtalk" );
134  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
135  $this->assertEquals( [], $res );
136 
137  $this->setTitle( NS_TALK );
138  $this->setUserPerm( "createpage" );
139  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
140  $this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
141 
142  $this->setTitle( NS_TALK );
143  $this->setUserPerm( "" );
144  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
145  $this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
146 
147  $this->setTitle( NS_MAIN );
148  $this->setUserPerm( "createpage" );
149  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
150  $this->assertEquals( [], $res );
151 
152  $this->setTitle( NS_MAIN );
153  $this->setUserPerm( "createtalk" );
154  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
155  $this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
156 
157  $this->setTitle( NS_MAIN );
158  $this->setUserPerm( "" );
159  $res = $this->title->getUserPermissionsErrors( 'create', $this->user );
160  $this->assertEquals( [ [ 'nocreate-loggedin' ] ], $res );
161 
162  $this->setUser( 'anon' );
163  $this->setTitle( NS_USER, $this->userName . '' );
164  $this->setUserPerm( "" );
165  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
166  $this->assertEquals( [ [ 'cant-move-user-page' ], [ 'movenologintext' ] ], $res );
167 
168  $this->setTitle( NS_USER, $this->userName . '/subpage' );
169  $this->setUserPerm( "" );
170  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
171  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
172 
173  $this->setTitle( NS_USER, $this->userName . '' );
174  $this->setUserPerm( "move-rootuserpages" );
175  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
176  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
177 
178  $this->setTitle( NS_USER, $this->userName . '/subpage' );
179  $this->setUserPerm( "move-rootuserpages" );
180  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
181  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
182 
183  $this->setTitle( NS_USER, $this->userName . '' );
184  $this->setUserPerm( "" );
185  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
186  $this->assertEquals( [ [ 'cant-move-user-page' ], [ 'movenologintext' ] ], $res );
187 
188  $this->setTitle( NS_USER, $this->userName . '/subpage' );
189  $this->setUserPerm( "" );
190  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
191  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
192 
193  $this->setTitle( NS_USER, $this->userName . '' );
194  $this->setUserPerm( "move-rootuserpages" );
195  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
196  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
197 
198  $this->setTitle( NS_USER, $this->userName . '/subpage' );
199  $this->setUserPerm( "move-rootuserpages" );
200  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
201  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
202 
203  $this->setUser( $this->userName );
204  $this->setTitle( NS_FILE, "img.png" );
205  $this->setUserPerm( "" );
206  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
207  $this->assertEquals( [ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ], $res );
208 
209  $this->setTitle( NS_FILE, "img.png" );
210  $this->setUserPerm( "movefile" );
211  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
212  $this->assertEquals( [ [ 'movenotallowed' ] ], $res );
213 
214  $this->setUser( 'anon' );
215  $this->setTitle( NS_FILE, "img.png" );
216  $this->setUserPerm( "" );
217  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
218  $this->assertEquals( [ [ 'movenotallowedfile' ], [ 'movenologintext' ] ], $res );
219 
220  $this->setTitle( NS_FILE, "img.png" );
221  $this->setUserPerm( "movefile" );
222  $res = $this->title->getUserPermissionsErrors( 'move', $this->user );
223  $this->assertEquals( [ [ 'movenologintext' ] ], $res );
224 
225  $this->setUser( $this->userName );
226  $this->setUserPerm( "move" );
227  $this->runGroupPermissions( 'move', [ [ 'movenotallowedfile' ] ] );
228 
229  $this->setUserPerm( "" );
230  $this->runGroupPermissions(
231  'move',
232  [ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ]
233  );
234 
235  $this->setUser( 'anon' );
236  $this->setUserPerm( "move" );
237  $this->runGroupPermissions( 'move', [ [ 'movenotallowedfile' ] ] );
238 
239  $this->setUserPerm( "" );
240  $this->runGroupPermissions(
241  'move',
242  [ [ 'movenotallowedfile' ], [ 'movenotallowed' ] ],
243  [ [ 'movenotallowedfile' ], [ 'movenologintext' ] ]
244  );
245 
246  if ( $this->isWikitextNS( NS_MAIN ) ) {
247  // NOTE: some content models don't allow moving
248  // @todo find a Wikitext namespace for testing
249 
250  $this->setTitle( NS_MAIN );
251  $this->setUser( 'anon' );
252  $this->setUserPerm( "move" );
253  $this->runGroupPermissions( 'move', [] );
254 
255  $this->setUserPerm( "" );
256  $this->runGroupPermissions( 'move', [ [ 'movenotallowed' ] ],
257  [ [ 'movenologintext' ] ] );
258 
259  $this->setUser( $this->userName );
260  $this->setUserPerm( "" );
261  $this->runGroupPermissions( 'move', [ [ 'movenotallowed' ] ] );
262 
263  $this->setUserPerm( "move" );
264  $this->runGroupPermissions( 'move', [] );
265 
266  $this->setUser( 'anon' );
267  $this->setUserPerm( 'move' );
268  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
269  $this->assertEquals( [], $res );
270 
271  $this->setUserPerm( '' );
272  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
273  $this->assertEquals( [ [ 'movenotallowed' ] ], $res );
274  }
275 
276  $this->setTitle( NS_USER );
277  $this->setUser( $this->userName );
278  $this->setUserPerm( [ "move", "move-rootuserpages" ] );
279  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
280  $this->assertEquals( [], $res );
281 
282  $this->setUserPerm( "move" );
283  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
284  $this->assertEquals( [ [ 'cant-move-to-user-page' ] ], $res );
285 
286  $this->setUser( 'anon' );
287  $this->setUserPerm( [ "move", "move-rootuserpages" ] );
288  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
289  $this->assertEquals( [], $res );
290 
291  $this->setTitle( NS_USER, "User/subpage" );
292  $this->setUserPerm( [ "move", "move-rootuserpages" ] );
293  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
294  $this->assertEquals( [], $res );
295 
296  $this->setUserPerm( "move" );
297  $res = $this->title->getUserPermissionsErrors( 'move-target', $this->user );
298  $this->assertEquals( [], $res );
299 
300  $this->setUser( 'anon' );
301  $check = [
302  'edit' => [
303  [ [ 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ] ],
304  [ [ 'badaccess-group0' ] ],
305  [],
306  true
307  ],
308  'protect' => [
309  [ [
310  'badaccess-groups',
311  "[[$prefix:Administrators|Administrators]]", 1 ],
312  [ 'protect-cantedit'
313  ] ],
314  [ [ 'badaccess-group0' ], [ 'protect-cantedit' ] ],
315  [ [ 'protect-cantedit' ] ],
316  false
317  ],
318  '' => [ [], [], [], true ]
319  ];
320 
321  foreach ( [ "edit", "protect", "" ] as $action ) {
322  $this->setUserPerm( null );
323  $this->assertEquals( $check[$action][0],
324  $this->title->getUserPermissionsErrors( $action, $this->user, true ) );
325  $this->assertEquals( $check[$action][0],
326  $this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
327  $this->assertEquals( $check[$action][0],
328  $this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
329 
331  $old = $wgGroupPermissions;
332  $wgGroupPermissions = [];
333 
334  $this->assertEquals( $check[$action][1],
335  $this->title->getUserPermissionsErrors( $action, $this->user, true ) );
336  $this->assertEquals( $check[$action][1],
337  $this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
338  $this->assertEquals( $check[$action][1],
339  $this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
340  $wgGroupPermissions = $old;
341 
342  $this->setUserPerm( $action );
343  $this->assertEquals( $check[$action][2],
344  $this->title->getUserPermissionsErrors( $action, $this->user, true ) );
345  $this->assertEquals( $check[$action][2],
346  $this->title->getUserPermissionsErrors( $action, $this->user, 'full' ) );
347  $this->assertEquals( $check[$action][2],
348  $this->title->getUserPermissionsErrors( $action, $this->user, 'secure' ) );
349 
350  $this->setUserPerm( $action );
351  $this->assertEquals( $check[$action][3],
352  $this->title->userCan( $action, $this->user, true ) );
353  $this->assertEquals( $check[$action][3],
354  $this->title->quickUserCan( $action, $this->user ) );
355  # count( User::getGroupsWithPermissions( $action ) ) < 1
356  }
357  }
358 
359  protected function runGroupPermissions( $action, $result, $result2 = null ) {
361 
362  if ( $result2 === null ) {
363  $result2 = $result;
364  }
365 
366  $wgGroupPermissions['autoconfirmed']['move'] = false;
367  $wgGroupPermissions['user']['move'] = false;
368  $res = $this->title->getUserPermissionsErrors( $action, $this->user );
369  $this->assertEquals( $result, $res );
370 
371  $wgGroupPermissions['autoconfirmed']['move'] = true;
372  $wgGroupPermissions['user']['move'] = false;
373  $res = $this->title->getUserPermissionsErrors( $action, $this->user );
374  $this->assertEquals( $result2, $res );
375 
376  $wgGroupPermissions['autoconfirmed']['move'] = true;
377  $wgGroupPermissions['user']['move'] = true;
378  $res = $this->title->getUserPermissionsErrors( $action, $this->user );
379  $this->assertEquals( $result2, $res );
380 
381  $wgGroupPermissions['autoconfirmed']['move'] = false;
382  $wgGroupPermissions['user']['move'] = true;
383  $res = $this->title->getUserPermissionsErrors( $action, $this->user );
384  $this->assertEquals( $result2, $res );
385  }
386 
392  public function testSpecialsAndNSPermissions() {
394  $this->setUser( $this->userName );
395 
396  $this->setTitle( NS_SPECIAL );
397 
398  $this->assertEquals( [ [ 'badaccess-group0' ], [ 'ns-specialprotected' ] ],
399  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
400 
401  $this->setTitle( NS_MAIN );
402  $this->setUserPerm( 'bogus' );
403  $this->assertEquals( [],
404  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
405 
406  $this->setTitle( NS_MAIN );
407  $this->setUserPerm( '' );
408  $this->assertEquals( [ [ 'badaccess-group0' ] ],
409  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
410 
411  $wgNamespaceProtection[NS_USER] = [ 'bogus' ];
412 
413  $this->setTitle( NS_USER );
414  $this->setUserPerm( '' );
415  $this->assertEquals( [ [ 'badaccess-group0' ],
416  [ 'namespaceprotected', 'User', 'bogus' ] ],
417  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
418 
419  $this->setTitle( NS_MEDIAWIKI );
420  $this->setUserPerm( 'bogus' );
421  $this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
422  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
423 
424  $this->setTitle( NS_MEDIAWIKI );
425  $this->setUserPerm( 'bogus' );
426  $this->assertEquals( [ [ 'protectedinterface', 'bogus' ] ],
427  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
428 
429  $wgNamespaceProtection = null;
430 
431  $this->setUserPerm( 'bogus' );
432  $this->assertEquals( [],
433  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
434  $this->assertEquals( true,
435  $this->title->userCan( 'bogus', $this->user ) );
436 
437  $this->setUserPerm( '' );
438  $this->assertEquals( [ [ 'badaccess-group0' ] ],
439  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
440  $this->assertEquals( false,
441  $this->title->userCan( 'bogus', $this->user ) );
442  }
443 
449  public function testJsConfigEditPermissions() {
450  $this->setUser( $this->userName );
451 
452  $this->setTitle( NS_USER, $this->userName . '/test.js' );
454  [ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
455 
456  [ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
457  [ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
458  [ [ 'badaccess-group0' ] ],
459 
460  [ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
461  [ [ 'badaccess-group0' ], [ 'mycustomjsprotected', 'bogus' ] ],
462  [ [ 'badaccess-group0' ] ]
463  );
464  }
465 
471  public function testJsonConfigEditPermissions() {
472  $this->setUser( $this->userName );
473 
474  $this->setTitle( NS_USER, $this->userName . '/test.json' );
476  [ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
477 
478  [ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
479  [ [ 'badaccess-group0' ] ],
480  [ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
481 
482  [ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ],
483  [ [ 'badaccess-group0' ] ],
484  [ [ 'badaccess-group0' ], [ 'mycustomjsonprotected', 'bogus' ] ]
485  );
486  }
487 
493  public function testCssConfigEditPermissions() {
494  $this->setUser( $this->userName );
495 
496  $this->setTitle( NS_USER, $this->userName . '/test.css' );
498  [ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
499 
500  [ [ 'badaccess-group0' ] ],
501  [ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
502  [ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
503 
504  [ [ 'badaccess-group0' ] ],
505  [ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ],
506  [ [ 'badaccess-group0' ], [ 'mycustomcssprotected', 'bogus' ] ]
507  );
508  }
509 
516  $this->setUser( $this->userName );
517 
518  $this->setTitle( NS_USER, $this->altUserName . '/test.js' );
520  [ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
521 
522  [ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
523  [ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
524  [ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
525 
526  [ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
527  [ [ 'badaccess-group0' ], [ 'customjsprotected', 'bogus' ] ],
528  [ [ 'badaccess-group0' ] ]
529  );
530  }
531 
538  $this->setUser( $this->userName );
539 
540  $this->setTitle( NS_USER, $this->altUserName . '/test.json' );
542  [ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
543 
544  [ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
545  [ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
546  [ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
547 
548  [ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ],
549  [ [ 'badaccess-group0' ] ],
550  [ [ 'badaccess-group0' ], [ 'customjsonprotected', 'bogus' ] ]
551  );
552  }
553 
560  $this->setUser( $this->userName );
561 
562  $this->setTitle( NS_USER, $this->altUserName . '/test.css' );
564  [ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
565 
566  [ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
567  [ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
568  [ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
569 
570  [ [ 'badaccess-group0' ] ],
571  [ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ],
572  [ [ 'badaccess-group0' ], [ 'customcssprotected', 'bogus' ] ]
573  );
574  }
575 
582  $this->setUser( $this->userName );
583 
584  $this->setTitle( NS_USER, $this->altUserName . '/tempo' );
586  [ [ 'badaccess-group0' ] ],
587 
588  [ [ 'badaccess-group0' ] ],
589  [ [ 'badaccess-group0' ] ],
590  [ [ 'badaccess-group0' ] ],
591 
592  [ [ 'badaccess-group0' ] ],
593  [ [ 'badaccess-group0' ] ],
594  [ [ 'badaccess-group0' ] ]
595  );
596  }
597 
598  protected function runConfigEditPermissions(
599  $resultNone,
600  $resultMyCss,
601  $resultMyJson,
602  $resultMyJs,
603  $resultUserCss,
604  $resultUserJson,
605  $resultUserJs
606  ) {
607  $this->setUserPerm( '' );
608  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
609  $this->assertEquals( $resultNone, $result );
610 
611  $this->setUserPerm( 'editmyusercss' );
612  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
613  $this->assertEquals( $resultMyCss, $result );
614 
615  $this->setUserPerm( 'editmyuserjson' );
616  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
617  $this->assertEquals( $resultMyJson, $result );
618 
619  $this->setUserPerm( 'editmyuserjs' );
620  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
621  $this->assertEquals( $resultMyJs, $result );
622 
623  $this->setUserPerm( 'editusercss' );
624  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
625  $this->assertEquals( $resultUserCss, $result );
626 
627  $this->setUserPerm( 'edituserjson' );
628  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
629  $this->assertEquals( $resultUserJson, $result );
630 
631  $this->setUserPerm( 'edituserjs' );
632  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
633  $this->assertEquals( $resultUserJs, $result );
634 
635  $this->setUserPerm( [ 'edituserjs', 'edituserjson', 'editusercss' ] );
636  $result = $this->title->getUserPermissionsErrors( 'bogus', $this->user );
637  $this->assertEquals( [ [ 'badaccess-group0' ] ], $result );
638  }
639 
645  public function testPageRestrictions() {
647 
648  $prefix = $wgContLang->getFormattedNsText( NS_PROJECT );
649 
650  $this->setTitle( NS_MAIN );
651  $this->title->mRestrictionsLoaded = true;
652  $this->setUserPerm( "edit" );
653  $this->title->mRestrictions = [ "bogus" => [ 'bogus', "sysop", "protect", "" ] ];
654 
655  $this->assertEquals( [],
656  $this->title->getUserPermissionsErrors( 'edit',
657  $this->user ) );
658 
659  $this->assertEquals( true,
660  $this->title->quickUserCan( 'edit', $this->user ) );
661  $this->title->mRestrictions = [ "edit" => [ 'bogus', "sysop", "protect", "" ],
662  "bogus" => [ 'bogus', "sysop", "protect", "" ] ];
663 
664  $this->assertEquals( [ [ 'badaccess-group0' ],
665  [ 'protectedpagetext', 'bogus', 'bogus' ],
666  [ 'protectedpagetext', 'editprotected', 'bogus' ],
667  [ 'protectedpagetext', 'protect', 'bogus' ] ],
668  $this->title->getUserPermissionsErrors( 'bogus',
669  $this->user ) );
670  $this->assertEquals( [ [ 'protectedpagetext', 'bogus', 'edit' ],
671  [ 'protectedpagetext', 'editprotected', 'edit' ],
672  [ 'protectedpagetext', 'protect', 'edit' ] ],
673  $this->title->getUserPermissionsErrors( 'edit',
674  $this->user ) );
675  $this->setUserPerm( "" );
676  $this->assertEquals( [ [ 'badaccess-group0' ],
677  [ 'protectedpagetext', 'bogus', 'bogus' ],
678  [ 'protectedpagetext', 'editprotected', 'bogus' ],
679  [ 'protectedpagetext', 'protect', 'bogus' ] ],
680  $this->title->getUserPermissionsErrors( 'bogus',
681  $this->user ) );
682  $this->assertEquals( [ [ 'badaccess-groups', "*, [[$prefix:Users|Users]]", 2 ],
683  [ 'protectedpagetext', 'bogus', 'edit' ],
684  [ 'protectedpagetext', 'editprotected', 'edit' ],
685  [ 'protectedpagetext', 'protect', 'edit' ] ],
686  $this->title->getUserPermissionsErrors( 'edit',
687  $this->user ) );
688  $this->setUserPerm( [ "edit", "editprotected" ] );
689  $this->assertEquals( [ [ 'badaccess-group0' ],
690  [ 'protectedpagetext', 'bogus', 'bogus' ],
691  [ 'protectedpagetext', 'protect', 'bogus' ] ],
692  $this->title->getUserPermissionsErrors( 'bogus',
693  $this->user ) );
694  $this->assertEquals( [
695  [ 'protectedpagetext', 'bogus', 'edit' ],
696  [ 'protectedpagetext', 'protect', 'edit' ] ],
697  $this->title->getUserPermissionsErrors( 'edit',
698  $this->user ) );
699 
700  $this->title->mCascadeRestriction = true;
701  $this->setUserPerm( "edit" );
702  $this->assertEquals( false,
703  $this->title->quickUserCan( 'bogus', $this->user ) );
704  $this->assertEquals( false,
705  $this->title->quickUserCan( 'edit', $this->user ) );
706  $this->assertEquals( [ [ 'badaccess-group0' ],
707  [ 'protectedpagetext', 'bogus', 'bogus' ],
708  [ 'protectedpagetext', 'editprotected', 'bogus' ],
709  [ 'protectedpagetext', 'protect', 'bogus' ] ],
710  $this->title->getUserPermissionsErrors( 'bogus',
711  $this->user ) );
712  $this->assertEquals( [ [ 'protectedpagetext', 'bogus', 'edit' ],
713  [ 'protectedpagetext', 'editprotected', 'edit' ],
714  [ 'protectedpagetext', 'protect', 'edit' ] ],
715  $this->title->getUserPermissionsErrors( 'edit',
716  $this->user ) );
717 
718  $this->setUserPerm( [ "edit", "editprotected" ] );
719  $this->assertEquals( false,
720  $this->title->quickUserCan( 'bogus', $this->user ) );
721  $this->assertEquals( false,
722  $this->title->quickUserCan( 'edit', $this->user ) );
723  $this->assertEquals( [ [ 'badaccess-group0' ],
724  [ 'protectedpagetext', 'bogus', 'bogus' ],
725  [ 'protectedpagetext', 'protect', 'bogus' ],
726  [ 'protectedpagetext', 'protect', 'bogus' ] ],
727  $this->title->getUserPermissionsErrors( 'bogus',
728  $this->user ) );
729  $this->assertEquals( [ [ 'protectedpagetext', 'bogus', 'edit' ],
730  [ 'protectedpagetext', 'protect', 'edit' ],
731  [ 'protectedpagetext', 'protect', 'edit' ] ],
732  $this->title->getUserPermissionsErrors( 'edit',
733  $this->user ) );
734  }
735 
740  $this->setTitle( NS_MAIN, "test page" );
741  $this->setUserPerm( [ "edit", "bogus" ] );
742 
743  $this->title->mCascadeSources = [
744  Title::makeTitle( NS_MAIN, "Bogus" ),
745  Title::makeTitle( NS_MAIN, "UnBogus" )
746  ];
747  $this->title->mCascadingRestrictions = [
748  "bogus" => [ 'bogus', "sysop", "protect", "" ]
749  ];
750 
751  $this->assertEquals( false,
752  $this->title->userCan( 'bogus', $this->user ) );
753  $this->assertEquals( [
754  [ "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n", 'bogus' ],
755  [ "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n", 'bogus' ],
756  [ "cascadeprotected", 2, "* [[:Bogus]]\n* [[:UnBogus]]\n", 'bogus' ] ],
757  $this->title->getUserPermissionsErrors( 'bogus', $this->user ) );
758 
759  $this->assertEquals( true,
760  $this->title->userCan( 'edit', $this->user ) );
761  $this->assertEquals( [],
762  $this->title->getUserPermissionsErrors( 'edit', $this->user ) );
763  }
764 
770  public function testActionPermissions() {
771  $this->setUserPerm( [ "createpage" ] );
772  $this->setTitle( NS_MAIN, "test page" );
773  $this->title->mTitleProtection['permission'] = '';
774  $this->title->mTitleProtection['user'] = $this->user->getId();
775  $this->title->mTitleProtection['expiry'] = 'infinity';
776  $this->title->mTitleProtection['reason'] = 'test';
777  $this->title->mCascadeRestriction = false;
778 
779  $this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
780  $this->title->getUserPermissionsErrors( 'create', $this->user ) );
781  $this->assertEquals( false,
782  $this->title->userCan( 'create', $this->user ) );
783 
784  $this->title->mTitleProtection['permission'] = 'editprotected';
785  $this->setUserPerm( [ 'createpage', 'protect' ] );
786  $this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
787  $this->title->getUserPermissionsErrors( 'create', $this->user ) );
788  $this->assertEquals( false,
789  $this->title->userCan( 'create', $this->user ) );
790 
791  $this->setUserPerm( [ 'createpage', 'editprotected' ] );
792  $this->assertEquals( [],
793  $this->title->getUserPermissionsErrors( 'create', $this->user ) );
794  $this->assertEquals( true,
795  $this->title->userCan( 'create', $this->user ) );
796 
797  $this->setUserPerm( [ 'createpage' ] );
798  $this->assertEquals( [ [ 'titleprotected', 'Useruser', 'test' ] ],
799  $this->title->getUserPermissionsErrors( 'create', $this->user ) );
800  $this->assertEquals( false,
801  $this->title->userCan( 'create', $this->user ) );
802 
803  $this->setTitle( NS_MEDIA, "test page" );
804  $this->setUserPerm( [ "move" ] );
805  $this->assertEquals( false,
806  $this->title->userCan( 'move', $this->user ) );
807  $this->assertEquals( [ [ 'immobile-source-namespace', 'Media' ] ],
808  $this->title->getUserPermissionsErrors( 'move', $this->user ) );
809 
810  $this->setTitle( NS_HELP, "test page" );
811  $this->assertEquals( [],
812  $this->title->getUserPermissionsErrors( 'move', $this->user ) );
813  $this->assertEquals( true,
814  $this->title->userCan( 'move', $this->user ) );
815 
816  $this->title->mInterwiki = "no";
817  $this->assertEquals( [ [ 'immobile-source-page' ] ],
818  $this->title->getUserPermissionsErrors( 'move', $this->user ) );
819  $this->assertEquals( false,
820  $this->title->userCan( 'move', $this->user ) );
821 
822  $this->setTitle( NS_MEDIA, "test page" );
823  $this->assertEquals( false,
824  $this->title->userCan( 'move-target', $this->user ) );
825  $this->assertEquals( [ [ 'immobile-target-namespace', 'Media' ] ],
826  $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
827 
828  $this->setTitle( NS_HELP, "test page" );
829  $this->assertEquals( [],
830  $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
831  $this->assertEquals( true,
832  $this->title->userCan( 'move-target', $this->user ) );
833 
834  $this->title->mInterwiki = "no";
835  $this->assertEquals( [ [ 'immobile-target-page' ] ],
836  $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
837  $this->assertEquals( false,
838  $this->title->userCan( 'move-target', $this->user ) );
839  }
840 
844  public function testUserBlock() {
845  $this->setMwGlobals( [
846  'wgEmailConfirmToEdit' => true,
847  'wgEmailAuthentication' => true,
848  ] );
849 
850  $this->setUserPerm( [ "createpage", "move" ] );
851  $this->setTitle( NS_HELP, "test page" );
852 
853  # $wgEmailConfirmToEdit only applies to 'edit' action
854  $this->assertEquals( [],
855  $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
856  $this->assertContains( [ 'confirmedittext' ],
857  $this->title->getUserPermissionsErrors( 'edit', $this->user ) );
858 
859  $this->setMwGlobals( 'wgEmailConfirmToEdit', false );
860  $this->assertNotContains( [ 'confirmedittext' ],
861  $this->title->getUserPermissionsErrors( 'edit', $this->user ) );
862 
863  # $wgEmailConfirmToEdit && !$user->isEmailConfirmed() && $action != 'createaccount'
864  $this->assertEquals( [],
865  $this->title->getUserPermissionsErrors( 'move-target',
866  $this->user ) );
867 
868  global $wgLang;
869  $prev = time();
870  $now = time() + 120;
871  $this->user->mBlockedby = $this->user->getId();
872  $this->user->mBlock = new Block( [
873  'address' => '127.0.8.1',
874  'by' => $this->user->getId(),
875  'reason' => 'no reason given',
876  'timestamp' => $prev + 3600,
877  'auto' => true,
878  'expiry' => 0
879  ] );
880  $this->user->mBlock->mTimestamp = 0;
881  $this->assertEquals( [ [ 'autoblockedtext',
882  '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
883  'Useruser', null, 'infinite', '127.0.8.1',
884  $wgLang->timeanddate( wfTimestamp( TS_MW, $prev ), true ) ] ],
885  $this->title->getUserPermissionsErrors( 'move-target',
886  $this->user ) );
887 
888  $this->assertEquals( false, $this->title->userCan( 'move-target', $this->user ) );
889  // quickUserCan should ignore user blocks
890  $this->assertEquals( true, $this->title->quickUserCan( 'move-target', $this->user ) );
891 
893  $wgLocalTZoffset = -60;
894  $this->user->mBlockedby = $this->user->getName();
895  $this->user->mBlock = new Block( [
896  'address' => '127.0.8.1',
897  'by' => $this->user->getId(),
898  'reason' => 'no reason given',
899  'timestamp' => $now,
900  'auto' => false,
901  'expiry' => 10,
902  ] );
903  $this->assertEquals( [ [ 'blockedtext',
904  '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
905  'Useruser', null, '23:00, 31 December 1969', '127.0.8.1',
906  $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ],
907  $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
908  # $action != 'read' && $action != 'createaccount' && $user->isBlockedFrom( $this )
909  # $user->blockedFor() == ''
910  # $user->mBlock->mExpiry == 'infinity'
911 
912  $this->user->mBlockedby = $this->user->getName();
913  $this->user->mBlock = new Block( [
914  'address' => '127.0.8.1',
915  'by' => $this->user->getId(),
916  'reason' => 'no reason given',
917  'timestamp' => $now,
918  'auto' => false,
919  'expiry' => 10,
920  'systemBlock' => 'test',
921  ] );
922  $this->assertEquals( [ [ 'systemblockedtext',
923  '[[User:Useruser|Useruser]]', 'no reason given', '127.0.0.1',
924  'Useruser', 'test', '23:00, 31 December 1969', '127.0.8.1',
925  $wgLang->timeanddate( wfTimestamp( TS_MW, $now ), true ) ] ],
926  $this->title->getUserPermissionsErrors( 'move-target', $this->user ) );
927  }
928 }
TitlePermissionTest\setUser
setUser( $userName=null)
Definition: TitlePermissionTest.php:86
TitlePermissionTest\testOtherCssConfigEditPermissions
testOtherCssConfigEditPermissions()
Definition: TitlePermissionTest.php:559
User\newFromId
static newFromId( $id)
Static factory method for creation from a given user ID.
Definition: User.php:614
NS_HELP
const NS_HELP
Definition: Defines.php:86
TitlePermissionTest\setTitle
setTitle( $ns, $title="Main_Page")
Definition: TitlePermissionTest.php:82
TitlePermissionTest\$anonUser
User $anonUser
Definition: TitlePermissionTest.php:24
MediaWikiTestCase\isWikitextNS
isWikitextNS( $ns)
Returns true if the given namespace defaults to Wikitext according to $wgNamespaceContentModels.
Definition: MediaWikiTestCase.php:1895
TitlePermissionTest\testOtherJsonConfigEditPermissions
testOtherJsonConfigEditPermissions()
Definition: TitlePermissionTest.php:537
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1980
TitlePermissionTest\testCascadingSourcesRestrictions
testCascadingSourcesRestrictions()
Title::checkCascadingSourcesRestrictions.
Definition: TitlePermissionTest.php:739
NS_FILE
const NS_FILE
Definition: Defines.php:80
User\newFromName
static newFromName( $name, $validate='valid')
Static factory method for creation from username.
Definition: User.php:591
$res
$res
Definition: database.txt:21
TitlePermissionTest\testJsonConfigEditPermissions
testJsonConfigEditPermissions()
Definition: TitlePermissionTest.php:471
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImgAuthModifyHeaders':Executed just before a file is streamed to a user via img_auth.php, allowing headers to be modified beforehand. $title:LinkTarget object & $headers:HTTP headers(name=> value, names are case insensitive). Two headers get special handling:If-Modified-Since(value must be a valid HTTP date) and Range(must be of the form "bytes=(\d*-\d*)") will be honored when streaming the file. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1993
true
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return true
Definition: hooks.txt:2006
TitlePermissionTest\testSpecialsAndNSPermissions
testSpecialsAndNSPermissions()
Definition: TitlePermissionTest.php:392
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:37
User\createNew
static createNew( $name, $params=[])
Add a user to the database, return the user object.
Definition: User.php:4283
NS_MAIN
const NS_MAIN
Definition: Defines.php:74
NS_SPECIAL
const NS_SPECIAL
Definition: Defines.php:63
TitlePermissionTest\testOtherJsConfigEditPermissions
testOtherJsConfigEditPermissions()
Definition: TitlePermissionTest.php:515
NS_PROJECT
const NS_PROJECT
Definition: Defines.php:78
user
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 and we might be restricted by PHP settings such as safe mode or open_basedir We cannot assume that the software even has read access anywhere useful Many shared hosts run all users web applications under the same user
Wikitext formatted, in the key only.
Definition: distributors.txt:25
TitlePermissionTest\runGroupPermissions
runGroupPermissions( $action, $result, $result2=null)
Definition: TitlePermissionTest.php:359
TitlePermissionTest\$title
Title $title
Definition: TitlePermissionTest.php:19
TitlePermissionTest\runConfigEditPermissions
runConfigEditPermissions( $resultNone, $resultMyCss, $resultMyJson, $resultMyJs, $resultUserCss, $resultUserJson, $resultUserJs)
Definition: TitlePermissionTest.php:598
MediaWikiTestCase\setMwGlobals
setMwGlobals( $pairs, $value=null)
Sets a global, maintaining a stashed version of the previous global to be restored in tearDown.
Definition: MediaWikiTestCase.php:678
title
title
Definition: parserTests.txt:219
TitlePermissionTest\testJsConfigEditPermissions
testJsConfigEditPermissions()
Definition: TitlePermissionTest.php:449
TitlePermissionTest\setUserPerm
setUserPerm( $perm)
Definition: TitlePermissionTest.php:72
$wgLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition: design.txt:56
TitlePermissionTest\testUserBlock
testUserBlock()
Title::checkUserBlock.
Definition: TitlePermissionTest.php:844
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:534
TitlePermissionTest\testPageRestrictions
testPageRestrictions()
Definition: TitlePermissionTest.php:645
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
$wgNamespaceProtection
$wgNamespaceProtection
Set the minimum permissions required to edit pages in each namespace.
Definition: DefaultSettings.php:5353
TitlePermissionTest
Database.
Definition: TitlePermissionTest.php:9
TitlePermissionTest\testOtherNonConfigEditPermissions
testOtherNonConfigEditPermissions()
Definition: TitlePermissionTest.php:581
RequestContext\resetMain
static resetMain()
Resets singleton returned by getMain().
Definition: RequestContext.php:460
$wgLocalTZoffset
$wgLocalTZoffset
Set an offset from UTC in minutes to use for the default timezone setting for anonymous users and new...
Definition: DefaultSettings.php:3168
NS_MEDIA
const NS_MEDIA
Definition: Defines.php:62
TitlePermissionTest\$altUser
User $altUser
Definition: TitlePermissionTest.php:24
MediaWikiLangTestCase
Base class that store and restore the Language objects.
Definition: MediaWikiLangTestCase.php:6
TitlePermissionTest\testActionPermissions
testActionPermissions()
Definition: TitlePermissionTest.php:770
TitlePermissionTest\setUp
setUp()
Definition: TitlePermissionTest.php:26
Title
Represents a title within MediaWiki.
Definition: Title.php:39
TitlePermissionTest\testQuickPermissions
testQuickPermissions()
Definition: TitlePermissionTest.php:101
$wgGroupPermissions
$wgGroupPermissions
Permission keys given to users in each group.
Definition: DefaultSettings.php:5123
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:22
Block
Definition: Block.php:27
NS_USER
const NS_USER
Definition: Defines.php:76
TitlePermissionTest\$userName
string $userName
Definition: TitlePermissionTest.php:14
NS_TALK
const NS_TALK
Definition: Defines.php:75
TitlePermissionTest\testCssConfigEditPermissions
testCssConfigEditPermissions()
Definition: TitlePermissionTest.php:493
TitlePermissionTest\$user
User $user
Definition: TitlePermissionTest.php:24
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:82
TitlePermissionTest\$altUserName
string $altUserName
Definition: TitlePermissionTest.php:14
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:53
false
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
TitlePermissionTest\$userUser
User $userUser
Definition: TitlePermissionTest.php:24
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:57