41 public function header( $string, $replace =
true, $http_response_code =
null ) {
42 \MediaWiki\HeaderCallback::warnIfHeadersSent();
43 if ( $http_response_code ) {
44 header( $string, $replace, $http_response_code );
46 header( $string, $replace );
57 foreach ( headers_list() as
$header ) {
59 if ( !strcasecmp( $name, $key ) ) {
81 return headers_sent();
114 if ( $expire ===
null ) {
120 $func =
$options[
'raw'] ?
'setrawcookie' :
'setcookie';
122 if ( Hooks::run(
'WebResponseSetCookie', [ &$name, &
$value, &$expire, &
$options ] ) ) {
125 'name' => (
string)$cookie,
126 'value' => (
string)
$value,
127 'expire' => (int)$expire,
130 'secure' => (
bool)
$options[
'secure'],
131 'httpOnly' => (bool)
$options[
'httpOnly'],
135 $key =
"{$data['name']}\n{$data['domain']}\n{$data['path']}";
139 if ( isset( $_COOKIE[$cookie] ) && !array_key_exists( $key, self::$setCookies ) ) {
140 self::$setCookies[$key] = [];
144 $deleting = ( $data[
'value'] ===
'' || $data[
'expire'] > 0 && $data[
'expire'] <= time() );
146 if ( $deleting && !isset( self::$setCookies[$key] ) ) {
147 wfDebugLog(
'cookie',
'already deleted ' . $func .
': "' . implode(
'", "', $data ) .
'"' );
148 } elseif ( !$deleting && isset( self::$setCookies[$key] ) &&
149 self::$setCookies[$key] === [ $func, $data ]
151 wfDebugLog(
'cookie',
'already set ' . $func .
': "' . implode(
'", "', $data ) .
'"' );
153 wfDebugLog(
'cookie', $func .
': "' . implode(
'", "', $data ) .
'"' );
154 if ( call_user_func_array( $func, array_values( $data ) ) ) {
155 self::$setCookies[$key] = $deleting ? null : [ $func, $data ];
199 public function header( $string, $replace =
true, $http_response_code =
null ) {
200 if ( substr( $string, 0, 5 ) ==
'HTTP/' ) {
201 $parts = explode(
' ', $string, 3 );
202 $this->code = intval( $parts[1] );
204 list( $key, $val ) = array_map(
'trim', explode(
":", $string, 2 ) );
206 $key = strtoupper( $key );
208 if ( $replace || !isset( $this->
headers[$key] ) ) {
213 if ( $http_response_code !==
null ) {
214 $this->code = intval( $http_response_code );
223 $this->code = intval(
$code );
235 $key = strtoupper( $key );
237 if ( isset( $this->
headers[$key] ) ) {
273 if ( $expire ===
null ) {
281 'expire' => (
int)$expire,
283 'domain' => (
string)
$options[
'domain'],
284 'secure' => (bool)
$options[
'secure'],
285 'httpOnly' => (
bool)
$options[
'httpOnly'],
295 if ( isset( $this->
cookies[$name] ) ) {
306 if ( isset( $this->
cookies[$name] ) ) {
$wgCookieExpiration
Default cookie lifetime, in seconds.
$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.
getHeader( $key)
Get a response header.
statusHeader( $code)
Output an HTTP status code header.
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
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add headers
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