50 self::$disableForPostSend =
true;
59 public function header( $string, $replace =
true, $http_response_code =
null ) {
60 if ( self::$disableForPostSend ) {
61 wfDebugLog(
'header',
'ignored post-send header {header}',
'all', [
63 'replace' => $replace,
64 'http_response_code' => $http_response_code,
65 'exception' =>
new RuntimeException(
'Ignored post-send header' ),
70 \MediaWiki\HeaderCallback::warnIfHeadersSent();
71 if ( $http_response_code ) {
72 header( $string, $replace, $http_response_code );
74 header( $string, $replace );
85 foreach ( headers_list() as
$header ) {
87 if ( !strcasecmp( $name, $key ) ) {
100 if ( self::$disableForPostSend ) {
101 wfDebugLog(
'header',
'ignored post-send status header {code}',
'all', [
103 'exception' =>
new RuntimeException(
'Ignored post-send status header' ),
117 return headers_sent();
159 if ( strcasecmp(
$options[
'sameSite'],
'none' ) === 0
160 && !empty(
$options[
'sameSiteLegacy'] )
163 $legacyOptions[
'sameSiteLegacy'] =
false;
164 $legacyOptions[
'sameSite'] =
'';
168 if ( $expire ===
null ) {
174 if ( self::$disableForPostSend ) {
176 wfDebugLog(
'cookie',
'ignored post-send cookie {cookie}',
'all', [
177 'cookie' => $prefixedName,
179 'name' => $prefixedName,
180 'value' => (
string)
$value,
181 'expire' => (
int)$expire,
183 'domain' => (
string)
$options[
'domain'],
184 'secure' => (
bool)
$options[
'secure'],
185 'httpOnly' => (
bool)
$options[
'httpOnly'],
186 'sameSite' => (
string)
$options[
'sameSite']
188 'exception' =>
new RuntimeException(
'Ignored post-send cookie' ),
193 if ( !Hooks::run(
'WebResponseSetCookie', [ &$name, &
$value, &$expire, &
$options ] ) ) {
201 $func =
$options[
'raw'] ?
'setrawcookie' :
'setcookie';
203 'expires' => (int)$expire,
206 'secure' => (
bool)
$options[
'secure'],
207 'httponly' => (bool)
$options[
'httpOnly'],
208 'samesite' => (
string)
$options[
'sameSite'],
212 $key =
"{$prefixedName}\n{$setOptions['domain']}\n{$setOptions['path']}";
216 if ( isset( $_COOKIE[$prefixedName] ) && !array_key_exists( $key, self::$setCookies ) ) {
217 self::$setCookies[$key] = [];
221 $deleting = (
$value ===
'' || $setOptions[
'expires'] > 0 && $setOptions[
'expires'] <= time() );
223 $logDesc =
"$func: \"$prefixedName\", \"$value\", \"" .
224 implode(
'", "', $setOptions ) .
'"';
225 $optionsForDeduplication = [ $func, $prefixedName,
$value, $setOptions ];
227 if ( $deleting && !isset( self::$setCookies[$key] ) ) {
228 wfDebugLog(
'cookie',
"already deleted $logDesc" );
230 } elseif ( !$deleting && isset( self::$setCookies[$key] ) &&
231 self::$setCookies[$key] === $optionsForDeduplication
233 wfDebugLog(
'cookie',
"already set $logDesc" );
238 if ( $func ===
'setrawcookie' ) {
240 SetCookieCompat::setrawcookie( $prefixedName,
$value, $setOptions );
243 SetCookieCompat::setcookie( $prefixedName,
$value, $setOptions );
245 self::$setCookies[$key] = $deleting ? null : $optionsForDeduplication;
286 public function header( $string, $replace =
true, $http_response_code =
null ) {
287 if ( substr( $string, 0, 5 ) ==
'HTTP/' ) {
288 $parts = explode(
' ', $string, 3 );
289 $this->code = intval( $parts[1] );
291 list( $key, $val ) = array_map(
'trim', explode(
":", $string, 2 ) );
293 $key = strtoupper( $key );
295 if ( $replace || !isset( $this->headers[$key] ) ) {
296 $this->headers[$key] = $val;
300 if ( $http_response_code !==
null ) {
301 $this->code = intval( $http_response_code );
310 $this->code = intval(
$code );
322 $key = strtoupper( $key );
324 if ( isset( $this->headers[$key] ) ) {
325 return $this->headers[$key];
360 if ( $expire ===
null ) {
368 'expire' => (
int)$expire,
370 'domain' => (
string)
$options[
'domain'],
371 'secure' => (bool)
$options[
'secure'],
372 'httpOnly' => (
bool)
$options[
'httpOnly'],
382 if ( isset( $this->
cookies[$name] ) ) {
393 if ( isset( $this->
cookies[$name] ) ) {
$wgCookieExpiration
Default cookie lifetime, in seconds.
bool $wgUseSameSiteLegacyCookies
If true, when a cross-site cookie with SameSite=None is sent, a legacy cookie with an "ss0" prefix wi...
$wgCookieHttpOnly
Set authentication cookies to HttpOnly to prevent access by JavaScript, in browsers that support this...
$wgCookiePath
Set this variable if you want to restrict cookies to a certain path within the domain specified by $w...
$wgCookieDomain
Set to set an explicit domain on the login cookies eg, "justthis.domain.org" or "....
$wgCookieSecure
Whether the "secure" flag should be set on the cookie.
$wgCookiePrefix
Cookies generated by MediaWiki have names starting with this prefix.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
header( $string, $replace=true, $http_response_code=null)
Stores a HTTP header.
setCookie( $name, $value, $expire=0, $options=[])
getStatusCode()
Get the HTTP response code, null if not set.
headersSent()
Test if headers have been sent.
static header( $code)
Output an HTTP status code header.
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
setCookie( $name, $value, $expire=0, $options=[])
Set the browser cookie.
hasCookies()
Checks whether this request is performing cookie operations.
static bool $disableForPostSend
Used to disable setters before running jobs post-request (T191537)
getHeader( $key)
Get a response header.
statusHeader( $code)
Output an HTTP status code header.
static disableForPostSend()
Disable setters for post-send processing.
header( $string, $replace=true, $http_response_code=null)
Output an HTTP header, wrapper for PHP's header()
clearCookie( $name, $options=[])
Unset a browser cookie.
headersSent()
Test if headers have been sent.
static array $setCookies
Used to record set cookies, because PHP's setcookie() will happily send an identical Set-Cookie to th...
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
it sets a lot of them automatically from cookies
This code would result in ircNotify being run twice when an article is and once for brion Hooks can return three possible true was required This is the default since MediaWiki *some string
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 & $options
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
Allows to change the fields on the form that will be generated $name