phpmyadmin icon indicating copy to clipboard operation
phpmyadmin copied to clipboard

TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, null given

Open liviuconcioiu opened this issue 2 years ago • 10 comments

Describe the bug

I have a table that has a JSON type column created on MySQL. If the database is open on MariaDB, it will show the table in use.

Now, if I click on Browse, a #4161 - Unknown data type: 'MYSQL_JSON' error is given. But, if I click on Search, a few errors come up.

5.2.2-dev

TypeError: preg_replace(): Argument #3 ($subject) must be of type array|string, null given

Internal error in .\templates\table\search\index.twig#72 Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("Undefined array key 0").```

Warning in .\libraries\classes\Controllers\Table\SearchController.php#346
Undefined array key 0

Warning in .\libraries\classes\Controllers\Table\SearchController.php#347
Undefined array key 0

To Reproduce

Steps to reproduce the behavior:

  1. Have a table with a JSON type column
  2. Open the database on MariaDB
  3. Click on Search for that table
  4. See error

Expected behavior

A #4161 - Unknown data type: 'MYSQL_JSON' error should be given, like it happens when you click on Browser Insert.

Screenshots

5.2.2-dev

https://user-images.githubusercontent.com/25424343/222019627-065288bf-777d-4ec5-bfdd-de42bd997ae9.mp4

https://user-images.githubusercontent.com/25424343/222019646-f3a83638-56a4-43fe-a40a-8f47ec03f141.mp4

Server configuration

  • phpMyAdmin version: 5.2.2-dev, 6.0.0-dev

Additional context

5.2.2-dev

Warning in .\libraries\classes\Controllers\Table\SearchController.php#346
Undefined array key 0

Backtrace

CoreExtension.php#1635: PhpMyAdmin\Controllers\Table\SearchController->getColumnProperties(
integer 0,
integer 0,
)
89e0cdc4eec79bf3db7e00c4b27a82ac.php#205: twig_get_attribute(
,
,
,
string 'getColumnProperties',
array,
string 'method',
boolean false,
boolean false,
boolean false,
integer 72,
)
Template.php#394: __TwigTemplate_4f09a00a8ff807a41e95ef41004b827a->doDisplay(
array,
array,
)
Template.php#367: Twig\Template->displayWithErrorHandling(
array,
array,
)
Template.php#379: Twig\Template->display(array)
TemplateWrapper.php#40: Twig\Template->render(
array,
array,
)
Template.php#156: Twig\TemplateWrapper->render(array)
AbstractController.php#35: PhpMyAdmin\Template->render(
string 'table/search/index',
array,
)
SearchController.php#292: PhpMyAdmin\Controllers\AbstractController->render(
string 'table/search/index',
array,
)
SearchController.php#204: PhpMyAdmin\Controllers\Table\SearchController->displaySelectionFormAction()
Routing.php#191: PhpMyAdmin\Controllers\Table\SearchController->__invoke(
,
array,
)
index.php#43: PhpMyAdmin\Routing::callControllerForRoute(
,
string '/table/search',
,
,
)

liviuconcioiu avatar Mar 01 '23 01:03 liviuconcioiu

How do you open the table from MySQL on MariaDB? Don't you need to convert it first? According to this, you have 3 options: https://mariadb.com/kb/en/json-data-type/#converting-a-mysql-table-with-json-fields-to-mariadb

kamil-tekiela avatar Mar 01 '23 09:03 kamil-tekiela

How do you open the table from MySQL on MariaDB? Don't you need to convert it first? According to this, you have 3 options: https://mariadb.com/kb/en/json-data-type/#converting-a-mysql-table-with-json-fields-to-mariadb

The tables can be seen in MariaDB, but cannot be open. The easiest way is to change the column type to TEXT in MySQL.

liviuconcioiu avatar Mar 01 '23 10:03 liviuconcioiu

How do you open the table from MySQL on MariaDB? Don't you need to convert it first? According to this, you have 3 options: https://mariadb.com/kb/en/json-data-type/#converting-a-mysql-table-with-json-fields-to-mariadb

The tables can be seen in MariaDB, but cannot be open. The easiest way is to change the column type to TEXT in MySQL.

So how did you start MySQL tables with MariaDB, just using the same data folder ?

williamdes avatar Mar 01 '23 10:03 williamdes

How do you open the table from MySQL on MariaDB? Don't you need to convert it first? According to this, you have 3 options: https://mariadb.com/kb/en/json-data-type/#converting-a-mysql-table-with-json-fields-to-mariadb

The tables can be seen in MariaDB, but cannot be open. The easiest way is to change the column type to TEXT in MySQL.

So how did you start MySQL tables with MariaDB, just using the same data folder ?

Yeah, since the engine is MyISAM.

liviuconcioiu avatar Mar 01 '23 10:03 liviuconcioiu

Would you also manage to replicate the corrupt mysql server bug ? (#17722)

williamdes avatar Mar 01 '23 10:03 williamdes

Would you also manage to replicate the corrupt mysql server bug ? (#17722)

No :(. Probably it happens if the engine is InnoDB? I've encountered a few corrupt tables in the past, but that error didn't come up.

liviuconcioiu avatar Mar 01 '23 11:03 liviuconcioiu

Would you also manage to replicate the corrupt mysql server bug ? (#17722)

No :(. Probably it happens if the engine is InnoDB? I've encountered a few corrupt tables in the past, but that error didn't come up.

I really would like to reproduce it, users seems to be saying one after the other that it helps to run a command. So we could handle it nicely and show a hint to the user

williamdes avatar Mar 01 '23 11:03 williamdes

Would you also manage to replicate the corrupt mysql server bug ? (#17722)

No :(. Probably it happens if the engine is InnoDB? I've encountered a few corrupt tables in the past, but that error didn't come up.

I really would like to reproduce it, users seems to be saying one after the other that it helps to run a command. So we could handle it nicely and show a hint to the user

I'll try and see if I can reproduce will new installs and let you know.

liviuconcioiu avatar Mar 01 '23 13:03 liviuconcioiu

I think I have the same issue. I get this error when I click on the search tab. This must have been introduced recently because I have been using the Docker version for many months without this issue.

Twig\Error\RuntimeError: An exception has been thrown during the rendering of a template ("preg_replace(): Argument #3 ($subject) must be of type array|string, null given").

PMA (running under Docker) Version information: 5.2.2 (up to date)

Apache/2.4.62 (Debian) Database client version: libmysql - mysqlnd 8.2.28 PHP extension: mysqli Documentation curl Documentation mbstring Documentation sodium Documentation PHP version: 8.2.28

(Running as SystemD service on the system) Server type: MariaDB Server connection: SSL is not being used Documentation Server version: 10.6.11-MariaDB-2 - Debian n/a Protocol version: 10 Server charset: cp1252 West European (latin1)

gerroon avatar Jun 18 '25 15:06 gerroon

Hi @liviuconcioiu Could you help with a PR to fix this issue please ?

williamdes avatar Dec 08 '25 21:12 williamdes