Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid hex2bin for PHP 5.3 #895

Merged
merged 4 commits into from
Jul 12, 2015
Merged

Avoid hex2bin for PHP 5.3 #895

merged 4 commits into from
Jul 12, 2015

Conversation

Alkarex
Copy link
Member

@Alkarex Alkarex commented Jul 10, 2015

#894
And use native hexadecimal function when available (MySQL) to avoid
having binary data in the SQL logs.

FreshRSS#894
And use native hexadecimal function when available (MySQL) to avoid
having binary data in the SQL logs.
@Alkarex Alkarex added this to the 1.1.2 milestone Jul 10, 2015
@@ -77,7 +83,7 @@ public function addEntry($valuesTmp) {
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+
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not like using hex2bin() with MySQL anyway, because having binary data in the SQL logs was not nice, sometimes interfering with my SSH client.

@@ -25,4 +25,4 @@
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+
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this comment...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed Alkarex@d9d9801

@marienfressinaud
Copy link
Member

I think I'm ok with that but don't we need to unpack the value somewhere?

sys_get_temp_dir() requires PHP 5.2.1+
@Alkarex
Copy link
Member Author

Alkarex commented Jul 12, 2015

@marienfressinaud I am not sure to understand your comment. If you say we should use an intermediate variable, I do not think there is a great advantage in doing so: the return value is used only once, and it is only a simple kind of string formatting / serialization (just like hex2bin()). Furthermore, it would be a (tiny bit) more work for PHP with an extra variable.
But I do not really mind.

Ahh, now I understand :-) The unpack is done natively in the SQL requests with hex(hash), e.g.
https://github.com/Alkarex/FreshRSS/blob/96b720b03269826ea0a6d58d8aea8ebf7ce7c1d9/app/Models/EntryDAO.php#L605

@marienfressinaud
Copy link
Member

👍 perfect!

marienfressinaud added a commit that referenced this pull request Jul 12, 2015
Avoid hex2bin for PHP 5.3
@marienfressinaud marienfressinaud merged commit 10deab0 into FreshRSS:dev Jul 12, 2015
@Alkarex Alkarex deleted the hex2bin branch July 12, 2015 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants