Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7398354
SpecialPageBeforeExecuteHandler.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
SpecialPageBeforeExecuteHandler.php
View Options
<?php
namespace
MediaWiki\CheckUser\HookHandler
;
use
MediaWiki\SpecialPage\Hook\SpecialPageBeforeExecuteHook
;
use
MediaWiki\SpecialPage\SpecialPage
;
use
MediaWiki\WikiMap\WikiMap
;
class
SpecialPageBeforeExecuteHandler
implements
SpecialPageBeforeExecuteHook
{
/**
* Is there a central wiki defined for the Special:GlobalContributions feature?
* If so, redirect the user there, preserving the query parameters.
*
* @param SpecialPage $special
* @param string|null $subPage
* @return bool `true` to continue default special page execution, `false` to abort
*/
public
function
onSpecialPageBeforeExecute
(
$special
,
$subPage
):
bool
{
$context
=
$special
->
getContext
();
$globalContributionsCentralWikiId
=
$context
->
getConfig
()->
get
(
'CheckUserGlobalContributionsCentralWikiId'
);
$title
=
$context
->
getTitle
();
if
(
$globalContributionsCentralWikiId
&&
$title
->
isSpecial
(
'GlobalContributions'
)
&&
$globalContributionsCentralWikiId
!==
WikiMap
::
getCurrentWikiId
()
)
{
// Note: Use the canonical (English) name for the namespace and page
// since non-English aliases would likely not be recognized by the central wiki.
$page
=
"Special:GlobalContributions"
;
$slashPos
=
strpos
(
$title
->
getText
(),
'/'
);
if
(
$slashPos
!==
false
)
{
$page
.=
substr
(
$title
->
getText
(),
$slashPos
);
}
$url
=
WikiMap
::
getForeignURL
(
$globalContributionsCentralWikiId
,
$page
,
);
$queryValues
=
$context
->
getRequest
()->
getQueryValuesOnly
();
// Don't duplicate the title, as we have this already from ::getForeignURL above
if
(
isset
(
$queryValues
[
'title'
]
)
)
{
unset
(
$queryValues
[
'title'
]
);
}
$url
=
wfAppendQuery
(
$url
,
$queryValues
);
$context
->
getOutput
()->
redirect
(
$url
);
return
false
;
}
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 15:13 (1 h, 44 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b3/a2/8df6953ed60d116df32d772c3edc
Default Alt Text
SpecialPageBeforeExecuteHandler.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment