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

Use of undefined constant MYSQLI_TYPE_JSON #16043

Closed
jsfrerot opened this issue Mar 25, 2020 · 24 comments
Closed

Use of undefined constant MYSQLI_TYPE_JSON #16043

jsfrerot opened this issue Mar 25, 2020 · 24 comments
Assignees
Labels
Bug A problem or regression with an existing feature
Projects
Milestone

Comments

@jsfrerot
Copy link

jsfrerot commented Mar 25, 2020

Describe the bug

I get the following error when browsing data in tables:
Warning in ./libraries/classes/Dbi/DbiMysqli.php#463
Use of undefined constant MYSQLI_TYPE_JSON - assumed 'MYSQLI_TYPE_JSON' (this will throw an Error in a future version of PHP)

To Reproduce

Steps to reproduce the behavior:
Install phpmyadmin 5.0.2

  1. Connect to a db server
  2. click on a table to browse it's content
  3. a popup will appear "Some errors have been detected on the server!
    Please look at the bottom of this window."
  4. See error
Warning in ./libraries/classes/Dbi/DbiMysqli.php#463
 Use of undefined constant MYSQLI_TYPE_JSON - assumed 'MYSQLI_TYPE_JSON' (this will throw an Error in a future version of PHP)

Backtrace

./libraries/classes/DatabaseInterface.php#2911: PhpMyAdmin\Dbi\DbiMysqli->getFieldsMeta()
./libraries/classes/Sql.php#1845: PhpMyAdmin\DatabaseInterface->getFieldsMeta()
./libraries/classes/Sql.php#2271: PhpMyAdmin\Sql->getQueryResponseForResultsReturned(
,
array,
string 'luna_test_config',
string 'config_db',
NULL,
NULL,
,
string './themes/pmahomme/img/',
string '402',
integer 25,
NULL,
NULL,
NULL,
NULL,
NULL,
string 'SELECT * FROM `config_db`',
NULL,
)
./libraries/classes/Sql.php#2117: PhpMyAdmin\Sql->executeQueryAndGetQueryResponse(
array,
boolean true,
string 'luna_test_config',
string 'config_db',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `config_db`',
NULL,
NULL,
)
./sql.php#241: PhpMyAdmin\Sql->executeQueryAndSendQueryResponse(
array,
boolean true,
string 'luna_test_config',
string 'config_db',
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
string '',
string './themes/pmahomme/img/',
NULL,
NULL,
NULL,
string 'SELECT * FROM `config_db`',
NULL,
NULL,
)

Expected behavior

No errors ;)

Screenshots

Screenshot from 2020-03-25 13-34-25

Server configuration

  • Operating system: Centos 7
  • Web server: nginx 1.16.1
  • Database version: mysql 5.5
  • PHP version: 7.2.27
  • phpMyAdmin version: 5.0.2

Client configuration

  • Browser: chrome
  • Operating system: ubuntu 19.10
@williamdes williamdes added the Bug A problem or regression with an existing feature label Mar 25, 2020
@williamdes williamdes added this to Needs triage in issues via automation Mar 25, 2020
@williamdes
Copy link
Member

I was looking for a way to reproduce this issue that I see very often on the reporting server.
I hope to reproduce it this time, this error does not make sense in php 7

@williamdes williamdes added this to the 5.0.3 milestone Mar 25, 2020
@jsfrerot
Copy link
Author

Let me know if you need more informations.

@williamdes williamdes self-assigned this Mar 30, 2020
@williamdes
Copy link
Member

williamdes commented Apr 5, 2020

@jsfrerot could you send the output of php -m ?

@jsfrerot
Copy link
Author

jsfrerot commented Apr 7, 2020

He, here is the output of "php -m" as requested

[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
geoip
gettext
gmp
hash
iconv
json
libxml
mbstring
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
zip
zlib

[Zend Modules]


@redrain-wang
Copy link

redrain-wang commented Apr 7, 2020

if (!defined('MYSQLI_TYPE_JSON')) {
define('MYSQLI_TYPE_JSON', 245);
}

@williamdes
Copy link
Member

If someone want to investigate before I have time to do so I would really appreciate

This constant exists on my version of php

@williamdes
Copy link
Member

I think I will revert the commit that removed this safe guard
I does not make sense but I do not understand what is wrong

Could someone post his phpinfo?

@williamdes
Copy link
Member

williamdes commented Apr 20, 2020

On yours

MysqlI Support enabled
Client API library version 10.2.26
Active Persistent Links 0
Inactive Persistent Links 0
Active Links 0
Client API header version 10.2.31-MariaDB
MYSQLI_SOCKET /var/lib/mysql/mysql.sock
mysqlnd enabled
Version mysqlnd 7.4.4
Loaded plugins mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_caching_sha2_password,auth_plugin_sha256_password
API Extensions no value

On my setup

MysqlI Support enabled
Client API library version mysqlnd 7.4.2
Active Persistent Links 0
Inactive Persistent Links 0
Active Links 0
mysqlnd enabled
Version mysqlnd 7.4.2
Loaded plugins mysqlnd,debug_trace,auth_plugin_mysql_native_password,auth_plugin_mysql_clear_password,auth_plugin_caching_sha2_password,auth_plugin_sha256_password
API Extensions mysqli,pdo_mysql

Maybe this is causing this issue

And you setup has --without-mysqli flag when it was compiled

@rd18aac
Copy link

rd18aac commented Apr 20, 2020

I don't have much experience with PHP modules so if anyone knows why this worked, please let me know...

I simply unchecked mysqli (red) and enabled nd_mysqli (green).

Screenshot 2020-04-20 at 11 36 41

I did this once on another web host to get an MVC application working and I only just thought of trying it.

@rd18aac
Copy link

rd18aac commented Apr 20, 2020

Screenshot 2020-04-20 at 11 42 40

Is this looking correct?

@williamdes
Copy link
Member

Screenshot 2020-04-20 at 11 42 40

Is this looking correct?

🤷‍♂️
Is the issue fixed by changing extensions ?

@rd18aac
Copy link

rd18aac commented Apr 20, 2020

Yeah, beats me.

WordPress, Adminer and my other custom PHP sites had no issue with the change.

This article goes through the the process and apparently changing allows certain functions...

https://www.plus2net.com/php_tutorial/mysqli_mysqlnd.php

@williamdes
Copy link
Member

Thank you !
This will help me document why I am adding back the constant, this issue will be fixed in the next 5.0 version

@williamdes
Copy link
Member

williamdes commented Apr 25, 2020

Ref: #11438 (comment)
#11438

@williamdes
Copy link
Member

williamdes commented Apr 25, 2020

Removed by c6313ac

williamdes added a commit that referenced this issue Apr 25, 2020
Signed-off-by: William Desportes <williamdes@wdes.fr>
@williamdes
Copy link
Member

Could you apply dc38860 and let me know if it fixes the issue ?

issues automation moved this from Needs triage to Closed Apr 25, 2020
@jsfrerot
Copy link
Author

@williamdes I confirm it fixes the issue.
Thank you !

@pkbarbiedoll
Copy link

dc38860 also worked for me.

@BenceSzalai
Copy link

FYI: Had the same issue. dc38860 also worked for me.

@prepstarr
Copy link

I am having a similar issue...

@hashtag32
Copy link

Thanks @williamdes!

@murelh
Copy link

murelh commented Sep 6, 2020

if (!defined('MYSQLI_TYPE_JSON')) {
define('MYSQLI_TYPE_JSON', 245);
}

Hi @redrain-wang
Why 245 ?

@williamdes
Copy link
Member

if (!defined('MYSQLI_TYPE_JSON')) {
define('MYSQLI_TYPE_JSON', 245);
}

Hi @redrain-wang
Why 245 ?

It is the real value when the constant is defined by/in php itself

@MauricioFauth
Copy link
Member

Looks like MYSQLI_TYPE_JSON is only defined if the server supports the JSON field type and PHP is using mysqlnd (MySQL 5.7.8+ and MariaDB 10.2.7+, but I didn't test this).

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 23, 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

10 participants