From ab597ba95843b0d8578ab0d7e8d3b058f88a9c74 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 10 Dec 2015 17:17:49 +0100 Subject: [PATCH] Import: workaround for ZF1 binary data corrpution --- library/Director/Import/Import.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/library/Director/Import/Import.php b/library/Director/Import/Import.php index 87bb3e57..f7162ee5 100644 --- a/library/Director/Import/Import.php +++ b/library/Director/Import/Import.php @@ -359,9 +359,26 @@ class Import { $db = $this->db; - $existing = $db->fetchCol( - $db->select()->from($table, 'checksum')->where('checksum IN (?)', $checksums) - ); + // TODO: The following is a quickfix for binary data corrpution reported + // in https://github.com/zendframework/zf1/issues/655 caused by + // https://github.com/zendframework/zf1/commit/2ac9c30f + // + // Should be reverted once fixed, eventually with a check continueing + // to use this workaround for specific ZF versions (1.12.16 and 1.12.17 + // so far). Alternatively we could also use a custom quoteInto method. + + // The former query looked as follows: + // + // $query = $db->select()->from($table, 'checksum') + // ->where('checksum IN (?)', $checksums) + + $hexed = array_map('Icinga\Module\Director\Util::binary2hex', $checksums); + $query = $db + ->select() + ->from($table, 'checksum') + ->where('LOWER(HEX(checksum)) IN (?)', $hexed) + + $existing = $db->fetchCol($query); return array_diff($checksums, $existing); }