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

One specific table can not be browsed anymore: preg_match() expects parameter 2 to be string, null given #15877

Closed
felsd opened this issue Jan 29, 2020 · 20 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Projects
Milestone

Comments

@felsd
Copy link

felsd commented Jan 29, 2020

Since today I can't view the data of only one specific table anymore. I have been using phpMyAdmin on this server since several months with multiple databases and until today everything was working fine.


phpMyAdmin 4.9.4 in combination with PHP 7.0 displayed only the first column of the table and a long error message at the end of the page. Unfortunately I don't have the full message anymore, the only part that I remember is Undefined offset: 2 in the file Display/Results.php.

The 2nd column of that table is a varchar(64) with collation utf8mb4_general_ci.


After upgrading to phpMyAdmin 5.0.1 and PHP 7.3 I get an error dialog with the following message:

Error in processing request
Error code: 500
Error text: Internal Server Error (rejected)
It seems that the connection to server has been lost. Please check your network connectivity and server status.

nginx error.log:

2020/01/29 18:04:50 [error] 3521#3521: *1100 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught TypeError: preg_match() expects parameter 2 to be string, null given in /usr/share/phpmyadmin/libraries/classes/Display/Results.php:1804
Stack trace:
#0 libraries/classes/Display/Results.php(1804): preg_match('@time|date@i', NULL)
#1 libraries/classes/Display/Results.php(1695): PhpMyAdmin\Display\Results->_getSingleAndMultiSortUrls(Array, Array, '', NULL, Array, NULL)
#2 libraries/classes/Display/Results.php(1103): PhpMyAdmin\Display\Results->_getOrderLinkAndSortedHeaderHtml(NULL, Array, Array, NULL, 'SELECT * FROM `...', 25, '', Array, Array, NULL)
#3 libraries/classes/Display/Results.php(1220): PhpMyAdmin\Display\Results->_getTableHeadersForColumns(Array, Array, Array, Array, Array, false, 'SELECT * FROM `...')
#4 libraries/classes/Display/Results.php(4292): PhpMyAdmin\Display\Results->_getTableHeaders(Array, Array, 'SELECT * FROM `...', Array, Arr" while reading response header from upstream,
client: y.y.y.y, server: _, request: "GET /phpmyadmin/sql.php?server=1&db=database_name&table=accounts&pos=0&ajax_request=true&ajax_page_request=true&_nocache=1580317489743773774&token=xxxxxxxxxxxxxxxxxxxxxxxxxx
HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "x.x.x.x"

Server configuration

  • Operating system: Debian 9
  • Web server: nginx/1.10.3
  • Database version: 10.1.41-MariaDB-0+deb9u1 - Debian 9.9
  • PHP version: 7.3.14-1+0~20200123.51+debian9~1.gbpcf42df
  • phpMyAdmin version: 5.0.1

Client configuration

  • Browser: Chromium 79.0.3945.79
  • Operating system: Lubuntu 18.04
@williamdes williamdes added the Bug A problem or regression with an existing feature label Jan 29, 2020
@williamdes williamdes added this to Needs triage in issues via automation Jan 29, 2020
@williamdes williamdes moved this from Needs triage to Medium priority in issues Jan 29, 2020
@williamdes williamdes moved this from Medium priority to Needs triage in issues Jan 29, 2020
@williamdes williamdes moved this from Needs triage to High priority in issues Jan 29, 2020
@williamdes williamdes added this to the 5.0.2 milestone Jan 29, 2020
@williamdes
Copy link
Member

@yashrajbothra could you please have a look? (if you want ^^)

@yashrajbothra
Copy link
Contributor

Definitely👍

@yashrajbothra
Copy link
Contributor

After some lookup in error log i found error is related to sorting of table headers. Can you please try to elborate whole story of the issue @felsd which can help me reproducing.

if you can give structure of those tables it can help?

@felsd
Copy link
Author

felsd commented Jan 30, 2020

Only one table is affected.

Structure


#	Name		Type		Collation	Attributes			Null	Default		Comments	Extra
1	id (Primary)	int(11)								No	None				AUTO_INCREMENT
2	column_1	varchar(64)	utf8mb4_general_ci				No	None		
3	column_2	varchar(64)	utf8mb4_general_ci				No	None		
4	column_3	varchar(64)	utf8mb4_general_ci				No	None		
5	column_4	varchar(64)	utf8mb4_general_ci				No	None		
6	column_5	varchar(64)	utf8mb4_general_ci				Yes	NULL		
7	column_6	varchar(128)	utf8mb4_general_ci				Yes	NULL		
8	column_7	text		utf8mb4_general_ci				Yes	NULL		
9	column_8	int(11)								No	None		
10	column_9	tinyint(1)							No	None		
11	column_10	tinyint(1)							No	None		
12	column_11	tinyint(1)							No	0		
13	column_12	tinyint(1)							No	0		
14	column_13	tinyint(1)							No	None		
15	column_14	timestamp							No	CURRENT_TIMESTAMP		
16	column_15	timestamp			on update CURRENT_TIMESTAMP	No	0000-00-00 00:00:00		ON UPDATE CURRENT_TIMESTAMP
17	column_16	timestamp							Yes	NULL		
18	column_17	varchar(16)	utf8mb4_general_ci				Yes	NULL		
19	column_18	timestamp							Yes	NULL		

Indexes

Keyname		Type	Unique	Packed	Column	Cardinality	Collation	Null	Comment
PRIMARY		BTREE	Yes	No	id	17390		A		No	

Partitions

 No partitioning defined!

Additional Info

Data: 6.5 MiB
Overhead: 4.0 MiB
Effective: 2.5 MiB
Total: 6.5 MiB
---
Format: Compact
Collation: utf8mb4_general_ci
Next autoindex: 30,300

The Story

When I click on "Browse" I get the error dialog that I mentioned and the exception appears in the nginx log.

The previous sorting of that table was either by id descending or by of the timestamp columns (column_14, column_15, column_16 or column_18).
I can't tell you that with certainty because I am not the only one browsing that table.
(preg_match('@time|date@i', NULL) might suggest that it is one of the timestamp columns?)

@yashrajbothra
Copy link
Contributor

@felsd Are you getting error again n again or it was only one time?

@felsd
Copy link
Author

felsd commented Jan 30, 2020

I still get that error.

@yashrajbothra
Copy link
Contributor

yashrajbothra commented Jan 30, 2020

I added the affected table structure to my local machine and tried reproducing the issue but unfortunately i was unable to reproduce the error.

table structure

-- phpMyAdmin SQL Dump
-- version 5.1.0-dev
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Jan 30, 2020 at 01:10 PM
-- Server version: 10.1.35-MariaDB
-- PHP Version: 7.2.9

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `bsr`
--

-- --------------------------------------------------------

--
-- Table structure for table `table`
--

CREATE TABLE `table` (
  `id` int(11) NOT NULL,
  `column_1` varchar(64) CHARACTER SET utf8mb4 NOT NULL,
  `column_2` varchar(64) CHARACTER SET utf8mb4 NOT NULL,
  `column_3` varchar(64) CHARACTER SET utf8mb4 NOT NULL,
  `column_4` varchar(64) CHARACTER SET utf8mb4 NOT NULL,
  `column_5` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
  `column_6` varchar(128) CHARACTER SET utf8mb4 DEFAULT NULL,
  `column_7` text CHARACTER SET utf8mb4,
  `column_8` int(11) NOT NULL,
  `column_9` tinyint(1) NOT NULL,
  `column_10` tinyint(1) NOT NULL,
  `column_11` tinyint(1) NOT NULL DEFAULT '0',
  `column_12` tinyint(1) NOT NULL DEFAULT '0',
  `column_13` tinyint(1) NOT NULL,
  `column_14` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `column_15` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
  `column_16` timestamp NULL DEFAULT NULL,
  `column_17` varchar(16) CHARACTER SET utf8mb4 DEFAULT NULL,
  `column_18` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `table`
--
ALTER TABLE `table`
  ADD PRIMARY KEY (`id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `table`
--
ALTER TABLE `table`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

@williamdes Can You please help me reproducing the issue ?

@williamdes
Copy link
Member

@yashrajbothra sorry, no computer for now
I am traveling, when I get home in a week if no one found a solution :)

@yashrajbothra
Copy link
Contributor

Ping @williamdes

@williamdes
Copy link
Member

I could not reproduce the issue but I am investigating
Thank you for the ping

@williamdes williamdes self-assigned this Feb 11, 2020
williamdes added a commit that referenced this issue Feb 11, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
issues automation moved this from High priority to Closed Feb 11, 2020
@williamdes
Copy link
Member

@felsd can you try af18dce ?

@felsd
Copy link
Author

felsd commented Feb 17, 2020

@williamdes Sorry for the late response - I just tried that but it didn't to the trick unfortunately.

Here is a more detailed error message:

 Undefined offset: 2

Backtrace

./libraries/classes/Display/Results.php#2614: PhpMyAdmin\Display\Results->_getRowValues(
,
array,
integer 0,
boolean false,
array,
string 'grid_edit click2',
array,
string 'SELECT * FROM `accounts` ORDER BY `last_session` ASC ',
array,
)
./libraries/classes/Display/Results.php#4300: PhpMyAdmin\Display\Results->_getTableBody(
,
array,
array,
array,
boolean false,
)
./libraries/classes/Sql.php#1666: PhpMyAdmin\Display\Results->getTable(
,
array,
array,
boolean false,
)
./libraries/classes/Sql.php#2002: PhpMyAdmin\Sql->getHtmlForSqlQueryResultsTable(
,
string './themes/pmahomme/img/',
NULL,
array,
boolean true,
string '20095',
integer 25,
NULL,
,
array,
)
./libraries/classes/Sql.php#2271: PhpMyAdmin\Sql->getQueryResponseForResultsReturned(
,
array,
string 'MY_DATABASE_NAME',
string 'accounts',
NULL,
NULL,
,
string './themes/pmahomme/img/',
string '20095',
integer 25,
NULL,
NULL,
NULL,
NULL,
NULL,
string 'SELECT * FROM `accounts` ORDER BY `last_session` ASC ',
NULL,
)
./libraries/classes/Sql.php#2100: PhpMyAdmin\Sql->executeQueryAndGetQueryResponse(
array,
boolean true,
string 'MY_DATABASE_NAME',
string 'accounts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `accounts` ORDER BY `last_session` ASC ',
NULL,
NULL,
)
./sql.php#241: PhpMyAdmin\Sql->executeQueryAndSendQueryResponse(
array,
boolean true,
string 'MY_DATABASE_NAME',
string 'accounts',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `accounts`',
NULL,
NULL,
)

@williamdes
Copy link
Member

williamdes commented Feb 17, 2020

Thank you
I opened a new bug #15972

@hcniet
Copy link

hcniet commented Mar 11, 2020

I had the same issue. i try go to table options (operations) -> flush table and OPTIMIZE TABLE. This work for me. Maybe the problem is with mysql cache.

@felsd
Copy link
Author

felsd commented Mar 11, 2020

@hcniet Thank you, that fixed it for me.

@ajengrf
Copy link

ajengrf commented May 17, 2020

I had the same issue. i try go to table options (operations) -> flush table and OPTIMIZE TABLE. This work for me. Maybe the problem is with mysql cache.

@hcniet thanks you saved me!

@beYondeR732
Copy link

beYondeR732 commented Oct 30, 2020

I got the same issue on few tables.
It occured after I changed the position of some columns in a SELECT's results.

To fix it, go to : structure tab > Move columns, switch some columns and save.

@williamdes
Copy link
Member

Are you using the latest version @beYondeR732 ?

@beYondeR732
Copy link

I was on version 4.8 when I had the issue.
I upgraded to the latest version (5.0.4) but it didn't fix the problem.

The solution posted above worked fine for me.

@mityan64
Copy link

mityan64 commented May 31, 2021

I was on version 4.8 when I had the issue.
I upgraded to the latest version (5.0.4) but it didn't fix the problem.

The solution posted above worked fine for me.

My phpMyAdmin version : 5.1.0-3.el7.remi (up to date)
Thank you, it really helped me. The problem occurred when I started doing the sorting.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 1, 2022
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
Projects
issues
  
Closed
Development

No branches or pull requests

7 participants