22 return (
new self )->setCookieInternal(
true, $name,
$value,
$options );
37 return (
new self )->setCookieInternal(
false, $name,
$value,
$options );
49 $supportsAssoc = version_compare( PHP_VERSION,
'7.3.0',
'>=' );
50 if ( $supportsAssoc ) {
102 $func = $urlEncode ?
'setcookie()' :
'setrawcookie()';
111 if ( $key ===
'expires' ) {
112 $expires = (int)
$opt;
114 } elseif ( $key ===
'path' ) {
117 } elseif ( $key ===
'domain' ) {
120 } elseif ( $key ===
'secure' ) {
121 $secure = (bool)
$opt;
123 } elseif ( $key ===
'httponly' ) {
124 $httponly = (bool)
$opt;
126 } elseif ( $key ===
'samesite' ) {
130 $this->
error(
"$func: Unrecognized key '$key' found in the options array" );
134 if ( $found == 0 && count(
$options ) > 0 ) {
135 $this->
error(
"$func: No valid options were found in the given array" );
138 if ( !strlen( $name ) ) {
139 $this->
error(
'Cookie names must not be empty' );
141 } elseif ( strpbrk( $name,
"=,; \t\r\n\013\014" ) !==
false ) {
142 $this->
error(
"Cookie names cannot contain any of the following " .
143 "'=,; \\t\\r\\n\\013\\014'" );
147 if ( !$urlEncode &&
$value !==
null
148 && strpbrk(
$value,
",; \t\r\n\013\014" ) !==
false
150 $this->
error(
"Cookie values cannot contain any of the following ',; \\t\\r\\n\\013\\014'" );
154 if ( $path !==
null && strpbrk( $path,
",; \t\r\n\013\014" ) !==
false ) {
155 $this->
error(
"Cookie paths cannot contain any of the following ',; \\t\\r\\n\\013\\014'" );
159 if ( $domain !==
null && strpbrk( $domain,
",; \t\r\n\013\014" ) !==
false ) {
160 $this->
error(
"Cookie domains cannot contain any of the following ',; \\t\\r\\n\\013\\014'" );
166 $dt = gmdate(
"D, d-M-Y H:i:s T", 1 );
167 $buf .=
"Set-Cookie: $name=deleted; expires=$dt; Max-Age=0";
169 $buf .=
"Set-Cookie: $name=";
171 $buf .= urlencode(
$value );
176 if ( $expires > 0 ) {
177 $dt = gmdate(
"D, d-M-Y H:i:s T", $expires );
178 $p = strrpos( $dt,
'-' );
179 if ( $p ===
false || substr( $dt, $p + 5, 1 ) !==
' ' ) {
180 $this->
error(
"Expiry date cannot have a year greater than 9999" );
184 $buf .=
"; expires=$dt";
186 $diff = $expires - $this->
time();
190 $buf .=
"; Max-Age=$diff";
194 if ( $path !==
null && strlen( $path ) ) {
195 $buf .=
"; path=$path";
197 if ( $domain !==
null && strlen( $domain ) ) {
198 $buf .=
"; domain=$domain";
204 $buf .=
"; HttpOnly";
206 if ( $samesite !==
null && strlen( $samesite ) ) {
207 $buf .=
"; SameSite=$samesite";
214 $this->
error(
"Cannot modify header information - headers already sent" );
225 protected function error( $message ) {
226 trigger_error( $message, E_USER_WARNING );
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
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults error
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