From 6b7d94626656674b60d6f970bd4ada46383dde1e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 10 Jul 2015 21:40:28 +0200 Subject: [PATCH 1/4] Avoid hex2bin for PHP 5.3 https://github.com/FreshRSS/FreshRSS/issues/894 And use native hexadecimal function when available (MySQL) to avoid having binary data in the SQL logs. --- app/Models/EntryDAO.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 9ddcfcfb3..f74055835 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -6,6 +6,10 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return parent::$sharedDbType !== 'sqlite'; } + public function hasNativeHex() { + return parent::$sharedDbType !== 'sqlite'; + } + protected function addColumn($name) { Minz_Log::debug('FreshRSS_EntryDAO::autoAddColumn: ' . $name); $hasTransaction = false; @@ -64,7 +68,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { . ', link, date, lastSeen, hash, is_read, is_favorite, id_feed, tags) ' . 'VALUES(?, ?, ?, ?, ' . ($this->isCompressed() ? 'COMPRESS(?)' : '?') - . ', ?, ?, ?, ?, ?, ?, ?, ?)'; + . ', ?, ?, ?, ' + . ($this->hasNativeHex() ? 'X?' : '?') + . ', ?, ?, ?, ?)'; $this->addEntryPrepared = $this->bd->prepare($sql); } @@ -77,7 +83,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { substr($valuesTmp['link'], 0, 1023), $valuesTmp['date'], time(), - hex2bin($valuesTmp['hash']), // X'09AF' hexadecimal literals do not work with SQLite/PDO + $this->hasNativeHex() ? $valuesTmp['hash'] : pack('H*', $valuesTmp['hash']), // X'09AF' hexadecimal literals do not work with SQLite/PDO //hex2bin() is PHP5.4+ $valuesTmp['is_read'] ? 1 : 0, $valuesTmp['is_favorite'] ? 1 : 0, $valuesTmp['id_feed'], @@ -109,8 +115,9 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { $sql = 'UPDATE `' . $this->prefix . 'entry` ' . 'SET title=?, author=?, ' . ($this->isCompressed() ? 'content_bin=COMPRESS(?)' : 'content=?') - . ', link=?, date=?, lastSeen=?, hash=?, ' - . ($valuesTmp['is_read'] === null ? '' : 'is_read=?, ') + . ', link=?, date=?, lastSeen=?, hash=' + . ($this->hasNativeHex() ? 'X?' : '?') + . ', ' . ($valuesTmp['is_read'] === null ? '' : 'is_read=?, ') . 'tags=? ' . 'WHERE id_feed=? AND guid=?'; $this->updateEntryPrepared = $this->bd->prepare($sql); @@ -123,7 +130,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable { substr($valuesTmp['link'], 0, 1023), $valuesTmp['date'], time(), - hex2bin($valuesTmp['hash']), + $this->hasNativeHex() ? $valuesTmp['hash'] : pack('H*', $valuesTmp['hash']), ); if ($valuesTmp['is_read'] !== null) { $values[] = $valuesTmp['is_read'] ? 1 : 0; From 1cf466cd56157ef2933d1233cba87b9e49954f25 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 10 Jul 2015 23:15:48 +0200 Subject: [PATCH 2/4] Changelog compatibility PHP5.2 https://github.com/FreshRSS/FreshRSS/issues/894 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ebfd50ac..c2fa18a68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ * Increased pagination limit to 500 articles. [#872](https://github.com/FreshRSS/FreshRSS/issues/872) * Improved UI for installation. [#855](https://github.com/FreshRSS/FreshRSS/issues/855) * Misc. - * Restore support for PHP 5.2. [#214a5cc](https://github.com/Alkarex/FreshRSS/commit/214a5cc9a4c2b821961bc21f22b4b08e34b5be68) + * Restore support for PHP 5.2. [#214a5cc](https://github.com/Alkarex/FreshRSS/commit/214a5cc9a4c2b821961bc21f22b4b08e34b5be68) [#894](https://github.com/FreshRSS/FreshRSS/issues/894) * Support for data-src for images of articles retrieved via the full-content module. [#877](https://github.com/FreshRSS/FreshRSS/issues/877) * Add a couple of default feeds for fresh installations. [#886](https://github.com/FreshRSS/FreshRSS/issues/886) * Changed some log visibilities. [#885](https://github.com/FreshRSS/FreshRSS/issues/885) From 96b720b03269826ea0a6d58d8aea8ebf7ce7c1d9 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 10 Jul 2015 23:36:52 +0200 Subject: [PATCH 3/4] Changelog with more precise version PHP 5.2.1 https://github.com/FreshRSS/FreshRSS/issues/894 https://github.com/marienfressinaud/FreshRSS/commit/0cabd1f50dd7d1cf0941a50139e6fbeed6825b4d https://github.com/FreshRSS/FreshRSS/issues/789#issuecomment-73878076 --- CHANGELOG.md | 2 +- constants.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2fa18a68..2f0bb48f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ * Increased pagination limit to 500 articles. [#872](https://github.com/FreshRSS/FreshRSS/issues/872) * Improved UI for installation. [#855](https://github.com/FreshRSS/FreshRSS/issues/855) * Misc. - * Restore support for PHP 5.2. [#214a5cc](https://github.com/Alkarex/FreshRSS/commit/214a5cc9a4c2b821961bc21f22b4b08e34b5be68) [#894](https://github.com/FreshRSS/FreshRSS/issues/894) + * Restore support for PHP 5.2.1+. [#214a5cc](https://github.com/Alkarex/FreshRSS/commit/214a5cc9a4c2b821961bc21f22b4b08e34b5be68) [#894](https://github.com/FreshRSS/FreshRSS/issues/894) * Support for data-src for images of articles retrieved via the full-content module. [#877](https://github.com/FreshRSS/FreshRSS/issues/877) * Add a couple of default feeds for fresh installations. [#886](https://github.com/FreshRSS/FreshRSS/issues/886) * Changed some log visibilities. [#885](https://github.com/FreshRSS/FreshRSS/issues/885) diff --git a/constants.php b/constants.php index d5f0cc06b..2df014053 100644 --- a/constants.php +++ b/constants.php @@ -25,4 +25,4 @@ define('FRESHRSS_PATH', dirname(__FILE__)); define('APP_PATH', FRESHRSS_PATH . '/app'); define('EXTENSIONS_PATH', FRESHRSS_PATH . '/extensions'); -define('TMP_PATH', sys_get_temp_dir()); +define('TMP_PATH', sys_get_temp_dir()); //Requires PHP 5.2.1+ From d9d9801e8da07b917aa89ce830dad2304f6ab6fc Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 12 Jul 2015 15:54:43 +0200 Subject: [PATCH 4/4] Remove superfluous comment sys_get_temp_dir() requires PHP 5.2.1+ --- constants.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/constants.php b/constants.php index 2df014053..d5f0cc06b 100644 --- a/constants.php +++ b/constants.php @@ -25,4 +25,4 @@ define('FRESHRSS_PATH', dirname(__FILE__)); define('APP_PATH', FRESHRSS_PATH . '/app'); define('EXTENSIONS_PATH', FRESHRSS_PATH . '/extensions'); -define('TMP_PATH', sys_get_temp_dir()); //Requires PHP 5.2.1+ +define('TMP_PATH', sys_get_temp_dir());