Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue #14700: DbHttpSession broke (mariadb) with data too long
Fixed issue #13950: (MS)SQL Error when saving getting a session token via API Dev: update data transparently (reset after allow usage after) Dev: usage of iSessionExpirationTime
- Loading branch information
Showing
9 changed files
with
73 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,16 @@ | ||
<?php | ||
|
||
/** | ||
* @inheritdoc | ||
* Leave it for compatibility of old config.php file | ||
*/ | ||
class DbHttpSession extends \CDbHttpSession | ||
{ | ||
|
||
/** | ||
* Session write handler. | ||
* Do not call this method directly. | ||
* @param string $id session ID | ||
* @param string $data session data | ||
* @return boolean whether session write is successful | ||
* @inheritdoc | ||
* Usage of config | ||
*/ | ||
public function writeSession($id, $data) | ||
public function getTimeout() | ||
{ | ||
// exception must be caught in session write handler | ||
// http://us.php.net/manual/en/function.session-set-save-handler.php | ||
try { | ||
$expire = time() + $this->getTimeout(); | ||
$db = $this->getDbConnection(); | ||
if ($db->getDriverName() == 'pgsql') { | ||
$data = new CDbExpression($db->quoteValueExtended($data, PDO::PARAM_LOB)."::bytea"); | ||
} | ||
if ($db->getDriverName() == 'sqlsrv' || $db->getDriverName() == 'mssql' || $db->getDriverName() == 'dblib') { | ||
$data = new CDbExpression('CONVERT(VARBINARY(MAX), '.$db->quoteValue($data).')'); | ||
} | ||
if ($db->createCommand()->select('id')->from($this->sessionTableName)->where('id=:id', array(':id'=>$id))->queryScalar() === false) { | ||
$db->createCommand()->insert($this->sessionTableName, array( | ||
'id'=>$id, | ||
'data'=>$data, | ||
'expire'=>$expire, | ||
)); | ||
} else { | ||
$db->createCommand()->update($this->sessionTableName, array( | ||
'data'=>$data, | ||
'expire'=>$expire | ||
), 'id=:id', array(':id'=>$id)); | ||
} | ||
} catch (Exception $e) { | ||
if (YII_DEBUG) { | ||
echo $e->getMessage(); | ||
} | ||
// it is too late to log an error message here | ||
return false; | ||
} | ||
return true; | ||
return (int)Yii::app()->getConfig('iSessionExpirationTime',ini_get('session.gc_maxlifetime')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters