[go: nahoru, domu]

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

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

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

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

emayoral opened this issue Jan 9, 2017 · 4 comments
Assignees
Labels
Bug A problem or regression with an existing feature patch
Milestone

Comments

@emayoral
Copy link
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
Copy link
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.

@emayoral
Copy link
Author

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
Copy link
Member
ibennetch commented Jan 12, 2017 via email

@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 A problem or regression with an existing feature label Jan 20, 2017
@nijel nijel closed this as completed 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
Backport from 4.6.6 (see phpmyadmin#12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>
schoonc added a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017
Backport from 4.6.6 (see phpmyadmin#12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>
schoonc added a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017
Backport from 4.6.6 (see phpmyadmin#12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>
schoonc added a commit to schoonc/phpmyadmin that referenced this issue Mar 18, 2017
Backport from 4.6.6 (see phpmyadmin#12881)

Signed-off-by: Сорокин Александр <ale10059@yandex.ru>
@ramphy
Copy link
ramphy commented Jun 29, 2018

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A problem or regression with an existing feature patch
Projects
None yet
Development

No branches or pull requests

4 participants