From: <var...@us...> - 2021-01-16 17:56:37
|
Revision: 10238 http://sourceforge.net/p/phpwiki/code/10238 Author: vargenau Date: 2021-01-16 17:56:34 +0000 (Sat, 16 Jan 2021) Log Message: ----------- Remove USE_SAFE_DBSESSION Modified Paths: -------------- trunk/config/config-default.ini trunk/config/config-dist.ini trunk/configurator.php trunk/doc/INSTALL.mssqlnative trunk/lib/DbSession/ADODB.php trunk/lib/DbSession/PDO.php trunk/lib/DbSession/SQL.php trunk/lib/DbSession.php Modified: trunk/config/config-default.ini =================================================================== --- trunk/config/config-default.ini 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/config/config-default.ini 2021-01-16 17:56:34 UTC (rev 10238) @@ -17,7 +17,6 @@ ENABLE_SPAMBLOCKLIST = false GOOGLE_LINKS_NOFOLLOW = true NUM_SPAM_LINKS = 20 -USE_SAFE_DBSESSION = false ENABLE_DISCUSSION_LINK = false ENABLE_CAPTCHA = false ENABLE_MAILNOTIFY = true Modified: trunk/config/config-dist.ini =================================================================== --- trunk/config/config-dist.ini 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/config/config-dist.ini 2021-01-16 17:56:34 UTC (rev 10238) @@ -138,12 +138,6 @@ ; Captcha will use a random word, otherwise a dictionary word. ;USE_CAPTCHA_RANDOM_WORD = false -; USE_SAFE_DBSESSION should be enabled, if you encounter session problems, with -; duplicate INSERT sess_id warnings at the bottom of the page. Reason is a -; unreliable affected_rows implementation() in the sql backend. -; Default is Disabled, using the fastest DbSession UPDATE method. -;USE_SAFE_DBSESSION = false - ; If true don't use UserName/Blog/day/time pagenames for the ADMIN_USER, but ; Blog/day/time only. Convenience for a single-user blog theme. ;BLOG_DEFAULT_EMPTY_PREFIX = true Modified: trunk/configurator.php =================================================================== --- trunk/configurator.php 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/configurator.php 2021-01-16 17:56:34 UTC (rev 10238) @@ -465,9 +465,6 @@ $properties["USE_CAPTCHA_RANDOM_WORD"] = new boolean_define_commented_optional('USE_CAPTCHA_RANDOM_WORD'); -$properties["USE_SAFE_DBSESSION"] = - new boolean_define_commented_optional('USE_SAFE_DBSESSION'); - $properties["BLOG_DEFAULT_EMPTY_PREFIX"] = new boolean_define_commented_optional('BLOG_DEFAULT_EMPTY_PREFIX'); Modified: trunk/doc/INSTALL.mssqlnative =================================================================== --- trunk/doc/INSTALL.mssqlnative 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/doc/INSTALL.mssqlnative 2021-01-16 17:56:34 UTC (rev 10238) @@ -43,7 +43,6 @@ have to edit schemas/sqlsrv-initialize.sql before you perform step three (above). You might also edit schemas/sqlsrv-destroy.sql at the same time, so you don't forget. - d) USE_SAFE_DBSESSION should be set to 'true' Note: DATABASE_DIRECTORY and DATABASE_DBA_HANDLER are ignored for mssql. Modified: trunk/lib/DbSession/ADODB.php =================================================================== --- trunk/lib/DbSession/ADODB.php 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/lib/DbSession/ADODB.php 2021-01-16 17:56:34 UTC (rev 10238) @@ -172,26 +172,10 @@ $sess_data = base64_encode($sess_data); $qdata = $dbh->qstr($sess_data); - /* AffectedRows with sessions seems to be instable on certain platforms. - * Enable the safe and slow USE_SAFE_DBSESSION then. - */ - if (USE_SAFE_DBSESSION) { - $dbh->Execute("DELETE FROM $table" - . " WHERE sess_id=$qid"); - $rs = $dbh->Execute("INSERT INTO $table" + $dbh->execute("DELETE FROM $table WHERE sess_id=$qid"); + $rs = $dbh->execute("INSERT INTO $table" . " (sess_id, sess_data, sess_date, sess_ip)" . " VALUES ($qid, $qdata, $time, $qip)"); - } else { - $rs = $dbh->Execute("UPDATE $table" - . " SET sess_data=$qdata, sess_date=$time, sess_ip=$qip" - . " WHERE sess_id=$qid"); - $result = $dbh->Affected_Rows(); - if ($result === false or $result < 1) { // false or int > 0 - $rs = $dbh->Execute("INSERT INTO $table" - . " (sess_id, sess_data, sess_date, sess_ip)" - . " VALUES ($qid, $qdata, $time, $qip)"); - } - } $result = !$rs->EOF; if ($result) $rs->free(); $this->_disconnect(); Modified: trunk/lib/DbSession/PDO.php =================================================================== --- trunk/lib/DbSession/PDO.php 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/lib/DbSession/PDO.php 2021-01-16 17:56:34 UTC (rev 10238) @@ -168,46 +168,21 @@ if (is_a($dbh, 'ADODB_postgres64')) $sess_data = base64_encode($sess_data); - /* AffectedRows with sessions seems to be unstable on certain platforms. - * Enable the safe and slow USE_SAFE_DBSESSION then. - */ - if (USE_SAFE_DBSESSION) { - $this->_backend->beginTransaction(); - $delete = $this->prepare("DELETE FROM $table" - . " WHERE sess_id=?"); - $delete->bindParam(1, $id, PDO::PARAM_STR, 32); - $delete->execute(); - $sth = $dbh->prepare("INSERT INTO $table" - . " (sess_id, sess_data, sess_date, sess_ip)" - . " VALUES (?, ?, ?, ?)"); - $sth->bindParam(1, $id, PDO::PARAM_STR, 32); - $sth->bindParam(2, $sess_data, PDO::PARAM_LOB); - $sth->bindParam(3, $time, PDO::PARAM_INT); - $sth->bindParam(4, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); - if ($result = $sth->execute()) { - $this->_backend->commit(); - } else { - $this->_backend->rollBack(); - } + $this->_backend->beginTransaction(); + $delete = $this->prepare("DELETE FROM $table WHERE sess_id=?"); + $delete->bindParam(1, $id, PDO::PARAM_STR, 32); + $delete->execute(); + $sth = $dbh->prepare("INSERT INTO $table" + . " (sess_id, sess_data, sess_date, sess_ip)" + . " VALUES (?, ?, ?, ?)"); + $sth->bindParam(1, $id, PDO::PARAM_STR, 32); + $sth->bindParam(2, $sess_data, PDO::PARAM_LOB); + $sth->bindParam(3, $time, PDO::PARAM_INT); + $sth->bindParam(4, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); + if ($result = $sth->execute()) { + $this->_backend->commit(); } else { - $sth = $dbh->prepare("UPDATE $table" - . " SET sess_data=?, sess_date=?, sess_ip=?" - . " WHERE sess_id=?"); - $sth->bindParam(1, $sess_data, PDO::PARAM_LOB); - $sth->bindParam(2, $time, PDO::PARAM_INT); - $sth->bindParam(3, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); - $sth->bindParam(4, $id, PDO::PARAM_STR, 32); - $result = $sth->execute(); // implicit affected rows - if ($result === false or $result < 1) { // false or int > 0 - $sth = $dbh->prepare("INSERT INTO $table" - . " (sess_id, sess_data, sess_date, sess_ip)" - . " VALUES (?, ?, ?, ?)"); - $sth->bindParam(1, $id, PDO::PARAM_STR, 32); - $sth->bindParam(2, $sess_data, PDO::PARAM_LOB); - $sth->bindParam(3, $time, PDO::PARAM_INT); - $sth->bindParam(4, $request->get('REMOTE_ADDR'), PDO::PARAM_STR, 15); - $result = $sth->execute(); - } + $this->_backend->rollBack(); } $this->_disconnect(); return $result; Modified: trunk/lib/DbSession/SQL.php =================================================================== --- trunk/lib/DbSession/SQL.php 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/lib/DbSession/SQL.php 2021-01-16 17:56:34 UTC (rev 10238) @@ -178,26 +178,10 @@ $sess_data = base64_encode($sess_data); $qdata = $dbh->quote($sess_data); - /* AffectedRows with sessions seems to be unstable on certain platforms. - * Enable the safe and slow USE_SAFE_DBSESSION then. - */ - if (USE_SAFE_DBSESSION) { - $dbh->query("DELETE FROM $table" - . " WHERE sess_id=$qid"); - $res = $dbh->query("INSERT INTO $table" - . " (sess_id, sess_data, sess_date, sess_ip)" - . " VALUES ($qid, $qdata, $time, $qip)"); - } else { - $res = $dbh->query("UPDATE $table" - . " SET sess_data=$qdata, sess_date=$time, sess_ip=$qip" - . " WHERE sess_id=$qid"); - $result = $dbh->AffectedRows(); - if ($result === false or $result < 1) { // 0 cannot happen: time, -1 (failure) on mysql - $res = $dbh->query("INSERT INTO $table" - . " (sess_id, sess_data, sess_date, sess_ip)" - . " VALUES ($qid, $qdata, $time, $qip)"); - } - } + $dbh->query("DELETE FROM $table WHERE sess_id=$qid"); + $res = $dbh->query("INSERT INTO $table" + . " (sess_id, sess_data, sess_date, sess_ip)" + . " VALUES ($qid, $qdata, $time, $qip)"); $this->_disconnect(); return !DB::isError($res); } Modified: trunk/lib/DbSession.php =================================================================== --- trunk/lib/DbSession.php 2021-01-16 17:44:56 UTC (rev 10237) +++ trunk/lib/DbSession.php 2021-01-16 17:56:34 UTC (rev 10238) @@ -33,7 +33,6 @@ * Quasi-major rewrite/decruft/fix by Jeff Dairiki <da...@da...>. * ADODB, dba and PDO classes by Reini Urban. * - * Warning: Enable USE_SAFE_DBSESSION if you get INSERT duplicate id warnings. */ class DbSession { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |