Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

InnoDB does not like long primary keys so an auto_increment field is …

…used instead of the session ID

As no primary key is now known, delete the MySQL\Standard\Save database function which used "replace"
Here is the query to update existing tables: alter table osc_sessions add pk int unsigned not null auto_increment first, drop primary key, add primary key (pk), add index idx_sessions_id (id);
  • Loading branch information...
commit 6f2b45b59520dbdf008ea9d2de940c5998d6f7b3 1 parent fedde5a
@haraldpdl authored
View
6 osCommerce/OM/Core/Session/Database/SQL/ANSI/Check.php
@@ -1,8 +1,8 @@
<?php
/**
* osCommerce Online Merchant
- *
- * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
+ *
+ * @copyright Copyright (c) 2014 osCommerce; http://www.oscommerce.com
* @license BSD License; http://www.oscommerce.com/bsdlicense.txt
*/
@@ -18,7 +18,7 @@ class Check {
public static function execute($data) {
$OSCOM_PDO = Registry::get('PDO');
- $Qsession = $OSCOM_PDO->prepare('select 1 from :table_sessions where id = :id');
+ $Qsession = $OSCOM_PDO->prepare('select 1 from :table_sessions where id = :id limit 1');
$Qsession->bindValue(':id', $data['id']);
$Qsession->execute();
View
2  osCommerce/OM/Core/Session/Database/SQL/ANSI/Get.php
@@ -18,7 +18,7 @@ class Get {
public static function execute($data) {
$OSCOM_PDO = Registry::get('PDO');
- $Qsession = $OSCOM_PDO->prepare('select value from :table_sessions where id = :id');
+ $Qsession = $OSCOM_PDO->prepare('select value from :table_sessions where id = :id limit 1');
$Qsession->bindValue(':id', $data['id']);
$Qsession->execute();
View
6 osCommerce/OM/Core/Session/Database/SQL/ANSI/Save.php
@@ -1,8 +1,8 @@
<?php
/**
* osCommerce Online Merchant
- *
- * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
+ *
+ * @copyright Copyright (c) 2014 osCommerce; http://www.oscommerce.com
* @license BSD License; http://www.oscommerce.com/bsdlicense.txt
*/
@@ -22,7 +22,7 @@ public static function execute($data) {
if ( OSCOM::callDB('Session\Database\Check', array('id' => $data['id']), 'Core') ) {
$sql_query = 'update :table_sessions set expiry = :expiry, value = :value where id = :id';
} else {
- $sql_query = 'insert into :table_sessions values (:id, :expiry, :value)';
+ $sql_query = 'insert into :table_sessions (id, expiry, value) values (:id, :expiry, :value)';
}
$Qsession = $OSCOM_PDO->prepare($sql_query);
View
26 osCommerce/OM/Core/Session/Database/SQL/MySQL/Standard/Save.php
@@ -1,26 +0,0 @@
-<?php
-/**
- * osCommerce Online Merchant
- *
- * @copyright Copyright (c) 2011 osCommerce; http://www.oscommerce.com
- * @license BSD License; http://www.oscommerce.com/bsdlicense.txt
- */
-
- namespace osCommerce\OM\Core\Session\Database\SQL\MySQL\Standard;
-
- use osCommerce\OM\Core\Registry;
-
- class Save {
- public static function execute($data) {
- $OSCOM_PDO = Registry::get('PDO');
-
- $Qsession = $OSCOM_PDO->prepare('replace into :table_sessions values (:id, :expiry, :value)');
- $Qsession->bindValue(':id', $data['id']);
- $Qsession->bindInt(':expiry', $data['expiry']);
- $Qsession->bindValue(':value', $data['value']);
- $Qsession->execute();
-
- return ( ($Qsession->rowCount() === 1) || !$Qsession->isError() );
- }
- }
-?>
View
5 osCommerce/OM/Core/Site/Setup/sql/oscommerce.sql
@@ -656,10 +656,13 @@ CREATE TABLE osc_reviews (
DROP TABLE IF EXISTS osc_sessions;
CREATE TABLE osc_sessions (
+ pk int unsigned NOT NULL AUTO_INCREMENT,
id char(128) NOT NULL,
expiry int unsigned NOT NULL,
value text NOT NULL,
- PRIMARY KEY (id)
+ PRIMARY KEY (pk),
+ KEY idx_sessions_id (id),
+ KEY idx_sessions_expiry (expiry)
) ENGINE=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci;
DROP TABLE IF EXISTS osc_shipping_availability;
Please sign in to comment.
Something went wrong with that request. Please try again.