Skip to content

Commit cb15da1

Browse files
committed
fixup! fix(test): fail on php errors
1 parent ab12ee8 commit cb15da1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/storage/sfCacheSessionStorage.class.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,7 @@ public function initialize($options = array())
9999
}
100100

101101
if (empty($this->id)) {
102-
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'localhost';
103-
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'ua';
104-
105-
// generate new id based on random # / ip / user agent / secret
106-
$this->id = md5(mt_rand(0, 999999).$ip.$ua.$this->options['session_cookie_secret']);
102+
$this->id = $this->generateId();
107103

108104
if (sfConfig::get('sf_logging_enabled')) {
109105
$this->dispatcher->notify(new sfEvent($this, 'application.log', array('New session created')));
@@ -224,10 +220,7 @@ public function regenerate($destroy = false)
224220
$this->cache->remove($this->id);
225221
}
226222

227-
// generate session id
228-
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'ua';
229-
230-
$this->id = md5(mt_rand(0, 999999).$_SERVER['REMOTE_ADDR'].$ua.$this->options['session_cookie_secret']);
223+
$this->id = $this->generateId();
231224

232225
// save data to cache
233226
$this->cache->set($this->id, serialize($this->data));
@@ -275,4 +268,16 @@ public function shutdown()
275268
}
276269
}
277270
}
271+
272+
/**
273+
* @return string
274+
*/
275+
private function generateId()
276+
{
277+
$ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'localhost';
278+
$ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'ua';
279+
280+
// generate new id based on random # / ip / user agent / secret
281+
return md5(mt_rand(0, 999999).$ip.$ua.$this->options['session_cookie_secret']);
282+
}
278283
}

0 commit comments

Comments
 (0)