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

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

Projects

None yet

3 participants

@emayoral
emayoral commented Jan 9, 2017 edited

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
Contributor

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

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
Contributor
@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 added a commit that closed this issue Jan 20, 2017
@nijel nijel Fix database search with newer php-gettext
We really need integer from count query.

Fixes #12881

Signed-off-by: Michal Čihař <michal@cihar.com>
827ff57
@nijel nijel closed this in 827ff57 Jan 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment