Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
serialized data can contain null bytes, store them in blob
Browse files Browse the repository at this point in the history
Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
  • Loading branch information
Etienne CHAMPETIER committed Oct 8, 2013
1 parent ae1dde8 commit b551098
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion core/src/plugins/conf.sql/class.AJXP_SqlUser.php
Expand Up @@ -191,7 +191,7 @@ public function setPref($prefName, $prefValue)
// Update an existing rights row, because only some of the rights have changed.
} else {

dibi::query('UPDATE [ajxp_user_prefs] SET ', Array('val'=>$prefValue), 'WHERE [login] = %s AND [name] = %s', $this->getId(), $prefName);
dibi::query('UPDATE [ajxp_user_prefs] SET [val] = %bin WHERE [login] = %s AND [name] = %s', $prefValue, $this->getId(), $prefName);

$this->log('UPDATE PREFERENCE: [Login]: '.$this->getId().' [Preference]:'.$prefName.' [Value]:'.$prefValue);
$this->prefs[$prefName] = $prefValue;
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/conf.sql/class.sqlConfDriver.php
Expand Up @@ -94,9 +94,9 @@ public function _savePluginConfig($pluginId, $options)
{
$res_opts = dibi::query('SELECT COUNT(*) FROM [ajxp_plugin_configs] WHERE [id] = %s', $pluginId);
if ($res_opts->fetchSingle()) {
dibi::query('UPDATE [ajxp_plugin_configs] SET [configs] = %s WHERE [id] = %s', serialize($options), $pluginId);
dibi::query('UPDATE [ajxp_plugin_configs] SET [configs] = %bin WHERE [id] = %s', serialize($options), $pluginId);
} else {
dibi::query('INSERT INTO [ajxp_plugin_configs]', array('id' => $pluginId, 'configs' => serialize($options)));
dibi::query('INSERT INTO [ajxp_plugin_configs] ([id],[configs]) VALUES (%s,%bin)', $pluginId, serialize($options));
}
}

Expand Down
6 changes: 3 additions & 3 deletions core/src/plugins/conf.sql/create.mysql
Expand Up @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS ajxp_user_prefs (
rid INTEGER PRIMARY KEY AUTO_INCREMENT,
login VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
val VARCHAR(2000)
val BLOB
);

CREATE TABLE IF NOT EXISTS ajxp_user_bookmarks (
Expand Down Expand Up @@ -49,7 +49,7 @@ CREATE TABLE IF NOT EXISTS ajxp_repo_options (
oid INTEGER PRIMARY KEY AUTO_INCREMENT,
uuid VARCHAR(33) NOT NULL,
name VARCHAR(50) NOT NULL,
val VARCHAR(2000),
val BLOB,
INDEX (uuid)
);

Expand All @@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS ajxp_groups (

CREATE TABLE IF NOT EXISTS ajxp_plugin_configs (
id VARCHAR(50) NOT NULL,
configs LONGTEXT NOT NULL,
configs LONGBLOB NOT NULL,
PRIMARY KEY (id)
);

Expand Down
6 changes: 3 additions & 3 deletions core/src/plugins/conf.sql/create.pgsql
Expand Up @@ -15,7 +15,7 @@ CREATE TABLE IF NOT EXISTS ajxp_user_prefs (
rid serial PRIMARY KEY,
login varchar(255) NOT NULL,
name varchar(255) NOT NULL,
val varchar(2000)
val bytea
);

CREATE TABLE IF NOT EXISTS ajxp_user_bookmarks (
Expand Down Expand Up @@ -48,7 +48,7 @@ CREATE TABLE IF NOT EXISTS ajxp_repo_options (
oid serial PRIMARY KEY,
uuid varchar(33) NOT NULL,
name varchar(50) NOT NULL,
val varchar(2000)
val bytea
);

CREATE INDEX ajxp_repo_options_uuid_idx ON ajxp_repo_options (uuid);
Expand All @@ -66,7 +66,7 @@ CREATE TABLE IF NOT EXISTS ajxp_groups (

CREATE TABLE IF NOT EXISTS ajxp_plugin_configs (
id varchar(50) PRIMARY KEY,
configs text NOT NULL
configs bytea NOT NULL
);

CREATE TABLE IF NOT EXISTS ajxp_simple_store (
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/conf.sql/create.sqlite
Expand Up @@ -64,7 +64,7 @@ CREATE TABLE IF NOT EXISTS ajxp_groups (

CREATE TABLE IF NOT EXISTS ajxp_plugin_configs (
id text NOT NULL,
configs longtext NOT NULL
configs longblob NOT NULL
);

CREATE TABLE IF NOT EXISTS ajxp_simple_store (
Expand Down
4 changes: 2 additions & 2 deletions core/src/plugins/mq.sql/create.mysql
@@ -1,8 +1,8 @@
CREATE TABLE IF NOT EXISTS ajxp_simple_store (
object_id VARCHAR(255) NOT NULL,
store_id VARCHAR(50) NOT NULL,
serialized_data LONGTEXT NULL,
serialized_data LONGBLOB NULL,
binary_data LONGBLOB NULL,
related_object_id VARCHAR(255) NULL,
PRIMARY KEY(object_id, store_id)
);
);
2 changes: 1 addition & 1 deletion core/src/plugins/mq.sql/create.pgsql
@@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS ajxp_simple_store (
object_id varchar(255) NOT NULL,
store_id varchar(50) NOT NULL,
serialized_data text,
serialized_data bytea,
binary_data bytea,
related_object_id varchar(255),
PRIMARY KEY(object_id, store_id)
Expand Down
2 changes: 1 addition & 1 deletion core/src/plugins/mq.sql/create.sqlite
@@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS ajxp_simple_store (
object_id text NOT NULL,
store_id text NOT NULL,
serialized_data longtext,
serialized_data blob,
binary_data blob,
related_object_id text DEFAULT NULL
);

0 comments on commit b551098

Please sign in to comment.