Skip to content

Commit

Permalink
FIX: resolve errors with commits from (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
wilr committed Jul 10, 2012
1 parent 2ac2977 commit c91e855
Showing 1 changed file with 63 additions and 14 deletions.
77 changes: 63 additions & 14 deletions control/Cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class Cookie {
static $report_errors = true;

/**
* Cookie class and instance for extendability purposes
* @var string cookie class
*/
static $cookie_class = 'Cookie';

static $inst = null;
private static $inst = null;

public static function get_inst() {
if(is_null(self::$inst)) {
Expand All @@ -30,36 +30,72 @@ public static function get_inst() {
* Set a cookie variable
*
* @param string $name The variable name
* @param string $value The variable value.
* @param mixed $value The variable value.
* @param int $expiry The expiry time, in days. Defaults to 90.
* @param string $path See http://php.net/set_session
* @param string $domain See http://php.net/set_session
* @param boolean $secure See http://php.net/set_session
* @param boolean $httpOnly See http://php.net/set_session
*/
static function set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) {
public static function set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) {
return self::get_inst()->inst_set($name, $value, $expiry, $path, $domain, $secure, $httpOnly);
}

/**
* Get a cookie variable
* Get a cookie variable.
*
* @param string
* @return mixed
*/
static function get($name) {
public static function get($name) {
return self::get_inst()->inst_get($name);
}

static function forceExpiry($name, $path = null, $domain = null) {
return self::get_inst()->inst_forceExpiry($name, $path, $domain);
/**
* @param string
* @param string
* @param string
*/
public static function forceExpiry($name, $path = null, $domain = null) {
Deprecation::notice('3.1', 'Use Cookie::force_expiry instead.');

return self::force_expiry($name, $path, $domain);
}

static function set_report_errors($reportErrors) {
return self::get_inst()->inst_set_report_errors($reportErrors);
/**
* @param string
* @param string
* @param string
*/
public static function force_expiry($name, $path = null, $domain = null) {
return self::get_inst()->inst_force_expiry($name, $path, $domain);
}

static function report_errors() {
/**
* @param bool
*/
public static function set_report_errors($reportErrors) {
self::get_inst()->inst_set_report_errors($reportErrors);
}

/**
* @return bool
*/
public static function report_errors() {
return self::get_inst()->inst_report_errors();
}

/**
* Set a cookie variable
*
* @param string $name The variable name
* @param mixed $value The variable value.
* @param int $expiry The expiry time, in days. Defaults to 90.
* @param string $path See http://php.net/set_session
* @param string $domain See http://php.net/set_session
* @param boolean $secure See http://php.net/set_session
* @param boolean $httpOnly See http://php.net/set_session
*/
protected function inst_set($name, $value, $expiry = 90, $path = null, $domain = null, $secure = false, $httpOnly = false) {
if(!headers_sent($file, $line)) {
$expiry = $expiry > 0 ? time()+(86400*$expiry) : $expiry;
Expand All @@ -72,21 +108,34 @@ protected function inst_set($name, $value, $expiry = 90, $path = null, $domain =
}
}

/**
* @param string
* @return mixed
*/
protected function inst_get($name) {
return isset($_COOKIE[$name]) ? $_COOKIE[$name] : null;
}

protected function inst_forceExpiry($name, $path = null, $domain = null) {
/**
* @param string
*/
protected function inst_force_expiry($name, $path = null, $domain = null) {
if(!headers_sent($file, $line)) {
self::set($name, null, -20, $path, $domain);
}
}

/**
* @param bool
*/
protected function inst_set_report_errors($reportErrors) {
self::$report_errors = $reportErrors;
}

protected function report_errors() {
/**
* @return bool
*/
protected function inst_report_errors() {
return self::$report_errors;
}
}
}

2 comments on commit c91e855

@chillu
Copy link
Member

@chillu chillu commented on c91e855 Mar 19, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Will, thanks for helping us clean up core with deprecations! But when you do that, please also fix any usage of the deprecated methods. I've just come across multiple deprecated forceExpiry() calls in core :/

@wilr
Copy link
Member Author

@wilr wilr commented on c91e855 Mar 20, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will keep that in mind. Though I normally do a grep on a full installer with modules before doing any API changes to pick those things up. I wonder if another commit got lost in translation.

Please sign in to comment.