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

Search in database fails if locale not set to "en" #12881

Closed
emayoral opened this Issue Jan 9, 2017 · 4 comments

Comments

Projects
None yet
4 participants
@emayoral

emayoral commented Jan 9, 2017

Steps to reproduce

  1. Log in with a locale other than english
  2. Search on the database. Select search in all tables. Any search term will do.

Expected behaviour

Search returns results. You can see expected behaviour if your locale is "en"

Actual behaviour

I get an error message (locale dependant):
Error al procesar la petición
Código de error: 500
Texto de error: Internal Server Error

Error in php error log:
[09-Jan-2017 09:42:56 Europe/Madrid] PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Select_string only accepts integers: 2883' in /usr/share/php/gettext/gettext.php:354
Stack trace:
#0 /usr/share/php/gettext/gettext.php(388): gettext_reader->select_string('2883')
#1 /usr/share/php/gettext/gettext.inc(293): gettext_reader->ngettext('%1$s match in <...', '%1$s matches in...', '2883')
#2 /usr/share/phpMyAdmin/libraries/DbSearch.php(331): _ngettext('%1$s match in <...', '%1$s matches in...', '2883')
#3 /usr/share/phpMyAdmin/libraries/DbSearch.php(283): PMA\libraries\DbSearch->_getResultsRow('MD5FaMiLyBeEr5M...', Array, true, '2883')
#4 /usr/share/phpMyAdmin/db_search.php(57): PMA\libraries\DbSearch->getSearchResults()
#5 {main}
thrown in /usr/share/php/gettext/gettext.php on line 354

Seems the problem is select_string only accepts integers but it is being passed a string because all mysql values are returned as strings and the value is not casted as integer.

Suggested fix (at least works for me):

diff -u /usr/share/phpMyAdmin/libraries/DbSearch.php.patched /usr/share/phpMyAdmin/libraries/DbSearch.php
--- /usr/share/phpMyAdmin/libraries/DbSearch.php.patched	2017-01-09 09:37:48.659142822 +0100
+++ /usr/share/phpMyAdmin/libraries/DbSearch.php	2017-01-09 09:37:58.032210548 +0100
@@ -279,7 +279,7 @@
             $num_search_result_total += $res_cnt;
             // Gets the result row's HTML for a table
             $html_output .= $this->_getResultsRow(
-                $each_table, $newsearchsqls, $odd_row, intval($res_cnt)
+                $each_table, $newsearchsqls, $odd_row, $res_cnt
             );
             $odd_row = ! $odd_row;
         } // end for

Server configuration

Operating system: CentOS 6

Web server: Apache 2.4.18

Database: mySQL 5.6.34

PHP version: PHP 5.5.21

phpMyAdmin version:

Client configuration

Browser: Firefox 50.1

Operating system: XUbuntu 16.04

@ibennetch ibennetch added the patch label Jan 11, 2017

@ibennetch

This comment has been minimized.

Show comment
Hide comment
@ibennetch

ibennetch Jan 11, 2017

Member

Strangely, I'm unable to reproduce this, so I'll leave it for one of the other developers to comment about. This code is similar in QA_4_6 and master.

Member

ibennetch commented Jan 11, 2017

Strangely, I'm unable to reproduce this, so I'll leave it for one of the other developers to comment about. This code is similar in QA_4_6 and master.

@emayoral

This comment has been minimized.

Show comment
Hide comment
@emayoral

emayoral Jan 11, 2017

It is important to have an up-to-date php-gettext to reproduce. (1.0.12)
Specifically, this is the change in gettext which causes the bug to appear:
http://bazaar.launchpad.net/~danilo/php-gettext/trunk/revision/61

However please note that this is a PMA bug, not a gettext bug. The ngettext function definition says that the third parameter should be an int , but since version 1.0.12 they are enforcing it.

emayoral commented Jan 11, 2017

It is important to have an up-to-date php-gettext to reproduce. (1.0.12)
Specifically, this is the change in gettext which causes the bug to appear:
http://bazaar.launchpad.net/~danilo/php-gettext/trunk/revision/61

However please note that this is a PMA bug, not a gettext bug. The ngettext function definition says that the third parameter should be an int , but since version 1.0.12 they are enforcing it.

@ibennetch

This comment has been minimized.

Show comment
Hide comment
@ibennetch

ibennetch Jan 12, 2017

Member
Member

ibennetch commented Jan 12, 2017

@ibennetch ibennetch added this to the 4.6.6 milestone Jan 12, 2017

@nijel nijel self-assigned this Jan 20, 2017

@nijel nijel added the bug label Jan 20, 2017

@nijel nijel closed this in 827ff57 Jan 20, 2017

schoonc pushed a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017

schoonc pushed a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017

Сорокин Александр
Fix database search with newer php-gettext
Backport from 4.6.6 (see #12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>

schoonc added a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017

Fix database search with newer php-gettext
Backport from 4.6.6 (see #12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>

schoonc added a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017

Fix database search with newer php-gettext
Backport from 4.6.6 (see #12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>

schoonc added a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017

Fix database search with newer php-gettext
Backport from 4.6.6 (see #12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>

@schoonc schoonc referenced this issue Mar 18, 2017

Merged

Fix database search with newer php-gettext #13098

4 of 4 tasks complete
@ramphy

This comment has been minimized.

Show comment
Hide comment
@ramphy

ramphy Jun 29, 2018

I have the same error, and fixed it changing the language from es_ES to EN, thank you!

ramphy commented Jun 29, 2018

I have the same error, and fixed it changing the language from es_ES to EN, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment