*/
private $args;
+ /**
+ * @var Config
+ */
+ private $config;
+
/**
* Load up our object with user supplied data
*/
- function __construct() {
+ function __construct( Config $config ) {
wfProfileIn( __METHOD__ );
+ $this->config = $config;
+
$this->mode = "";
if ( !empty( $_GET["rs"] ) ) {
* BEWARE! Data are passed as they have been supplied by the user,
* they should be carefully handled in the function processing the
* request.
+ *
+ * @param User $user
*/
- function performAction() {
- global $wgAjaxExportList, $wgUser;
-
+ function performAction( User $user ) {
if ( empty( $this->mode ) ) {
return;
}
wfProfileIn( __METHOD__ );
- if ( !in_array( $this->func_name, $wgAjaxExportList ) ) {
+ if ( !in_array( $this->func_name, $this->config->get( 'AjaxExportList' ) ) ) {
wfDebug( __METHOD__ . ' Bad Request for unknown function ' . $this->func_name . "\n" );
wfHttpError(
'Bad Request',
"unknown function " . $this->func_name
);
- } elseif ( !User::isEveryoneAllowed( 'read' ) && !$wgUser->isAllowed( 'read' ) ) {
+ } elseif ( !User::isEveryoneAllowed( 'read' ) && !$user->isAllowed( 'read' ) ) {
wfHttpError(
403,
'Forbidden',
*/
private $mText;
+ /**
+ * @var Config
+ */
+ private $mConfig;
+
/**
* @param string|null $text
+ * @param Config|null $config
*/
- function __construct( $text = null ) {
+ function __construct( $text = null, Config $config = null ) {
$this->mCacheDuration = null;
$this->mVary = null;
+ $this->mConfig = $config ?: ConfigFactory::getDefaultInstance()->makeConfig( 'main' );
$this->mDisabled = false;
$this->mText = '';
* Construct the header and output it
*/
function sendHeaders() {
- global $wgUseSquid, $wgUseESI;
-
if ( $this->mResponseCode ) {
$n = preg_replace( '/^ *(\d+)/', '\1', $this->mResponseCode );
header( "Status: " . $this->mResponseCode, true, (int)$n );
# and tell the client to always check with the squid. Otherwise,
# tell the client to use a cached copy, without a way to purge it.
- if ( $wgUseSquid ) {
+ if ( $this->mConfig->get( 'UseSquid' ) ) {
# Expect explicit purge of the proxy cache, but require end user agents
# to revalidate against the proxy on each visit.
# Surrogate-Control controls our Squid, Cache-Control downstream caches
- if ( $wgUseESI ) {
+ if ( $this->mConfig->get( 'UseESI' ) ) {
header( 'Surrogate-Control: max-age=' . $this->mCacheDuration . ', content="ESI/1.0"' );
header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
} else {
$this->context->setTitle( $title );
$wgTitle = $title;
- $dispatcher = new AjaxDispatcher();
- $dispatcher->performAction();
+ $dispatcher = new AjaxDispatcher( $this->config );
+ $dispatcher->performAction( $this->context->getUser() );
wfProfileOut( __METHOD__ );
return;
}