Skip to content

Commit bc56972

Browse files
committed
Improved error handling on decoding errors in the server part.
1 parent d0fc019 commit bc56972

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

server/lib/classes/modules.inc.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,12 @@ function processDatalog() {
9898
$data = unserialize($d["data"]);
9999
}
100100
//** Decode data back to locale
101-
/*
102101
foreach($data['old'] as $key => $val) {
103102
$data['old'][$key] = utf8_decode($val);
104103
}
105104
foreach($data['new'] as $key => $val) {
106105
$data['new'][$key] = utf8_decode($val);
107106
}
108-
*/
109107

110108
$replication_error = false;
111109

@@ -165,7 +163,12 @@ function processDatalog() {
165163

166164

167165
if($replication_error == false) {
168-
$this->raiseTableHook($d["dbtable"],$d["action"],$data);
166+
if(is_array($data['old']) || is_array($data['new'])) {
167+
$this->raiseTableHook($d["dbtable"],$d["action"],$data);
168+
} else {
169+
$app->log("Data array was empty for datalog_id ".$d["datalog_id"],LOGLEVEL_WARN);
170+
}
171+
//$this->raiseTableHook($d["dbtable"],$d["action"],$data);
169172
//$app->dbmaster->query("DELETE FROM sys_datalog WHERE datalog_id = ".$d["datalog_id"]);
170173
//$app->log("Deleting sys_datalog ID ".$d["datalog_id"],LOGLEVEL_DEBUG);
171174
$app->dbmaster->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf["server_id"]);
@@ -194,17 +197,19 @@ function processDatalog() {
194197
$data = unserialize($d["data"]);
195198
}
196199
//** decode data back to current locale
197-
/*
198200
foreach($data['old'] as $key => $val) {
199201
$data['old'][$key] = utf8_decode($val);
200202
}
201203
foreach($data['new'] as $key => $val) {
202204
$data['new'][$key] = utf8_decode($val);
203205
}
204-
*/
205206

206207
$this->current_datalog_id = $d["datalog_id"];
207-
$this->raiseTableHook($d["dbtable"],$d["action"],$data);
208+
if(is_array($data['old']) || is_array($data['new'])) {
209+
$this->raiseTableHook($d["dbtable"],$d["action"],$data);
210+
} else {
211+
$app->log("Data array was empty for datalog_id ".$d["datalog_id"],LOGLEVEL_WARN);
212+
}
208213
//$app->db->query("DELETE FROM sys_datalog WHERE datalog_id = ".$rec["datalog_id"]);
209214
//$app->log("Deleting sys_datalog ID ".$rec["datalog_id"],LOGLEVEL_DEBUG);
210215
$app->db->query("UPDATE server SET updated = ".$d["datalog_id"]." WHERE server_id = ".$conf["server_id"]);

0 commit comments

Comments
 (0)