@@ -90,7 +90,7 @@ public function loadChannel($channelName, $create = false)
90
90
if ($ res ->count ()){
91
91
if (!isset (self ::$ channels )) self ::$ channels = array ();
92
92
$ single = $ res ->fetchSingle ();
93
- $ data = unserialize (base64_decode ( $ single) );
93
+ $ data = unserialize ($ single );
94
94
if (is_array ($ data )) {
95
95
if (!is_array ($ data ["MESSAGES " ])) $ data ["MESSAGES " ] = array ();
96
96
if (!is_array ($ data ["CLIENTS " ])) $ data ["CLIENTS " ] = array ();
@@ -109,6 +109,7 @@ public function __destruct()
109
109
{
110
110
if (isSet (self ::$ channels ) && is_array (self ::$ channels ) && !empty ($ this ->sqlDriver )) {
111
111
$ inserts = [];
112
+ $ insertValues = [];
112
113
$ deletes = [];
113
114
$ driver = $ this ->sqlDriver ["driver " ];
114
115
if (!dibi::isConnected ()){
@@ -117,12 +118,14 @@ public function __destruct()
117
118
foreach (self ::$ channels as $ channelName => $ data ) {
118
119
if (is_array ($ data )) {
119
120
if (isSet ($ data ["CLIENTS " ]) && count ($ data ["CLIENTS " ])) {
120
- $ serialized = base64_encode ( serialize ($ data) );
121
+ $ serialized = serialize ($ data );
121
122
if ($ driver === "postgre " ){
122
123
dibi::query ("DELETE FROM [ajxp_mq_queues] WHERE [channel_name] = %s " , $ channelName );
123
124
dibi::query ('INSERT INTO [ajxp_mq_queues] ' , ["channel_name " => $ channelName , "content " => $ serialized ]);
124
125
}else {
125
- $ inserts [] = "(' $ channelName', ' " .$ serialized ."') " ;
126
+ $ inserts [] = "(%s, %bin) " ;
127
+ $ insertValues [] = $ channelName ;
128
+ $ insertValues [] = $ serialized ;
126
129
}
127
130
}else {
128
131
$ deletes [] = $ channelName ;
@@ -131,7 +134,9 @@ public function __destruct()
131
134
}
132
135
if (count ($ inserts )){
133
136
try {
134
- dibi::query ('REPLACE INTO [ajxp_mq_queues] ([channel_name],[content]) VALUES ' .implode (", " , $ inserts ));
137
+ $ args = ['REPLACE INTO [ajxp_mq_queues] ([channel_name],[content]) VALUES ' .implode (", " , $ inserts )];
138
+ $ args = array_merge ($ args , $ insertValues );
139
+ call_user_func_array (array ("dibi " , "query " ), $ args );
135
140
}catch (\DibiException $ dE ){
136
141
$ this ->logError (__CLASS__ , $ dE ->getMessage ());
137
142
}
0 commit comments