56 if ( isset( $attr[
'expires'] ) ) {
57 $this->isSessionKey =
false;
58 $this->expires = strtotime( $attr[
'expires'] );
61 if ( isset( $attr[
'path'] ) ) {
62 $this->path = $attr[
'path'];
67 if ( isset( $attr[
'domain'] ) ) {
68 if ( self::validateCookieDomain( $attr[
'domain'] ) ) {
69 $this->domain = $attr[
'domain'];
96 if ( substr(
$domain, -1 ) ==
'.' ||
98 count( $dc ) == 2 && $dc[0] ===
''
104 if ( preg_match(
'/^[0-9.]+$/',
$domain ) ) {
105 if ( count( $dc ) != 4 ) {
109 if ( ip2long(
$domain ) ===
false ) {
113 if ( $originDomain == null || $originDomain ==
$domain ) {
121 if ( ( count( $dc ) == 2 && strlen( $dc[0] ) <= 2 )
122 || ( count( $dc ) == 3 && strlen( $dc[0] ) ==
"" && strlen( $dc[1] ) <= 2 ) ) {
125 if ( ( count( $dc ) == 2 || ( count( $dc ) == 3 && $dc[0] ==
'' ) )
126 && preg_match(
'/(com|net|org|gov|edu)\...$/',
$domain ) ) {
131 if ( $originDomain != null ) {
132 if ( substr(
$domain, 0, 1 ) !=
'.' &&
$domain != $originDomain ) {
136 if ( substr(
$domain, 0, 1 ) ==
'.'
177 || ( strlen(
$domain ) > strlen( $this->domain )
178 && substr( $this->domain, 0, 1 ) ==
'.'
182 -strlen( $this->domain ),
183 strlen( $this->domain ),
199 return ( $this->path && substr_compare( $this->path,
$path, 0, strlen( $this->path ) ) == 0 );
206 return $this->isSessionKey || $this->expires > time();
static validateCookieDomain($domain, $originDomain=null)
Return the true if the cookie is valid is valid.
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 noclasses & $ret
set($value, $attr)
Sets a cookie.
serializeToHttpRequest($path, $domain)
Serialize the cookie jar into a format useful for HTTP Request headers.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
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 name
__construct($name, $value, $attr)