Page MenuHomePhabricator

Call to undefined function mysql_real_escape_string()
Closed, DuplicatePublic


Using debian jessie with PHP 7.0.4-1~dotdeb+8.1 (cli) ( NTS ).

This error is regarding this removed function in php7..any ideas on how to fix this?

This issue can be reproduced by running an bin/config check

Event Timeline

Can you show me the output of this command on your system?

$ php -r 'print_r(get_loaded_extensions());'
chad added a project: Setup.

See Also: T9640

From This extension was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0. Instead, the MySQLi or PDO_MySQL extension should be used

This probably isn't directly related to PHP7.

If possible, we try to use mysqli (this install, and most other installs, should use mysqli) . If it's not available, we fall back and try mysql.

In the web UI, we test for these extensions and warn if they aren't present. However, we don't run the same checks from the CLI (T2383). The extensions available on the CLI can differ from the extensions available in the web UI, so even if the web UI runs properly the CLI may not.

This is likely because PHP has neither mysql nor mysqli installed, which is unusual. The output of get_loaded_extensions() should confirm if that's the issue.

If so, the remedy is to install either mysql or mysqli (presumably mysqli). The root issue is T2383, but it arises rarely because in most cases one of these extensions is present, or is installed according to the install instructions, or the issue is caught in the web UI and fixed on the CLI as a side effect.

The issue is not comming from missing php-extentions. mysqli was installed and present in fpm and cli so that was not the issue.
The actual function is missing, as @eadler said in the previous comment.

For the moment I've downgraded to PHP 5.6.17-0+deb8u1 (cli) (built: Jan 13 2016 09:10:12)

php -r 'print_r(get_loaded_extensions());'

[0] => Core
[1] => date
[2] => ereg
[3] => libxml
[4] => openssl
[5] => pcre
[6] => zlib
[7] => bcmath
[8] => bz2
[9] => calendar
[10] => ctype
[11] => dba
[12] => dom
[13] => hash
[14] => fileinfo
[15] => filter
[16] => ftp
[17] => gettext
[18] => SPL
[19] => iconv
[20] => mbstring
[21] => pcntl
[22] => session
[23] => posix
[24] => Reflection
[25] => standard
[26] => shmop
[27] => SimpleXML
[28] => soap
[29] => sockets
[30] => Phar
[31] => exif
[32] => sysvmsg
[33] => sysvsem
[34] => sysvshm
[35] => tokenizer
[36] => wddx
[37] => xml
[38] => xmlreader
[39] => xmlwriter
[40] => zip
[41] => PDO
[42] => apcu
[43] => curl
[44] => gd
[45] => json
[46] => mcrypt
[47] => mysql
[48] => mysqli
[49] => pdo_mysql
[50] => readline
[51] => tidy
[52] => mhash
[53] => apc
[54] => Zend OPcache


Is that output from the version of PHP with a problem, or from PHP 5.6.17?

@epriestley that is from PHP 5.6.17

I've downgraded so I cannot run the command now on the server unfortunately.
But I think you are actually correct regarding the missing extensions. I've installed the php7-cli package but the extensions from php5-* .

Now the question is ...would php7 be ok for phabricator ?

T9640 is tracking PHP7 compatibility. We haven't extensively tested Phabricator on PHP7 yet, but I believe several users are running it without any issues. We're happy to fix issues you encounter with PHP7 if you report them.

I'm going to merge this into T2383, since I believe that's the root issue, you've worked around this locally, and you can no longer easily reproduce or confirm a fix since you don't have the original environment anymore.

OK, I'm going to switch to php7 and see if it goes.

If i'm getting into bugs/errors I will report them.

Thank you for the fast reply!

OK, after installing all the necessary extensions and changing the php.ini as recommended by phabricator everything works nice.

The only tricky part is that you have to install php7.0-apcu-bc. If you just install php7.0-apcu phabricator is going to show only a white page and an error is going to be thrown into the nginx error.log

2016/03/15 13:05:00 [error] 24020#0: *1 FastCGI sent in stderr: "PHP message: [2016-03-15 12:05:00] EXCEPTION: (Error) Call to undefined function apc_sma_info() at [<phabricator>/src/applications/cache/spec/PhabricatorDataCacheSpec.php:82]
PHP message: arcanist(head=stable, ref.master=ccbaee585e1a, ref.stable=bb276740e7a8), phabricator(head=stable, ref.master=d76175285e96, ref.stable=fd72a2ff8101), phutil(head=stable, ref.master=d20d6e725037, ref.stable=89c7c2072813)
PHP message:   #0 PhabricatorDataCacheSpec::initAPCCommonSpec() called at [<phabricator>/src/applications/cache/spec/PhabricatorDataCacheSpec.php:56]
PHP message:   #1 PhabricatorDataCacheSpec::initAPCuSpec() called at [<phabricator>/src/applications/cache/spec/PhabricatorDataCacheSpec.php:23]
PHP message:   #2 PhabricatorDataCacheSpec::getActiveCacheSpec() called at [<phabricator>/src/applications/config/check/PhabricatorCacheSetupCheck.php:11]
PHP message:   #3 PhabricatorCacheSetupCheck::executeChecks() called at [<phabricator>/src/applications/config/check/PhabricatorSetupCheck.php:45]
PHP message:   #4 PhabricatorSetupCheck::runSetupChecks() called at [<phabricator>/src/applications/config/check/PhabricatorSetupCheck.php:126]
PHP message:   #5 PhabricatorSetupCheck::runAllChecks() called at [<phabricator>/src/applications/config/check/PhabricatorSetupCheck.php:91]
PHP message:   #6 PhabricatorSetupCheck::willProcessRequest() called at [<phabricator>/src/aphront/configuration/AphrontApplicationConfiguration.php:103]
PHP message:   #7 AphrontApplicationConfiguration::runHTTPRequest(AphrontPHPHTTPSink) called at [<phabricator>/webroot/index.php:17]" while reading response header from upstream

@valentinul can you please let me know what exactly you modified in your php.ini?

@valentinul can you please let me know what exactly you modified in your php.ini?

Hi @storrgie ,

The only thing was installing the php7.0-apcu-bc.
These are all the packages related to php7 on my server.

root@m:~# dpkg -l|grep php7
ii  php7.0-apcu                    5.1.4-1~dotdeb+8.1                  amd64        APC User Cache for PHP
ii  php7.0-apcu-bc                 1.0.3-1~dotdeb+8.1                  amd64        APCu Backwards Compatibility Module
ii  php7.0-cgi                     7.0.7-1~dotdeb+8.1                  amd64        server-side, HTML-embedded scripting language (CGI binary)
ii  php7.0-cli                     7.0.7-1~dotdeb+8.1                  amd64        command-line interpreter for the PHP scripting language
ii  php7.0-common                  7.0.7-1~dotdeb+8.1                  all          Common files for packages built from the PHP source
ii  php7.0-curl                    7.0.7-1~dotdeb+8.1                  amd64        CURL module for PHP
ii  php7.0-dev                     7.0.7-1~dotdeb+8.1                  amd64        Files for PHP7.0 module development
ii  php7.0-fpm                     7.0.7-1~dotdeb+8.1                  amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.0-gd                      7.0.7-1~dotdeb+8.1                  amd64        GD module for PHP
ii  php7.0-json                    7.0.7-1~dotdeb+8.1                  amd64        JSON module for PHP
ii  php7.0-mcrypt                  7.0.7-1~dotdeb+8.1                  amd64        libmcrypt module for PHP
ii  php7.0-mysql                   7.0.7-1~dotdeb+8.1                  amd64        MySQL module for PHP
ii  php7.0-opcache                 7.0.7-1~dotdeb+8.1                  amd64        Zend OpCache module for PHP
ii  php7.0-readline                7.0.7-1~dotdeb+8.1                  amd64        readline module for PHP
ii  php7.0-tidy                    7.0.7-1~dotdeb+8.1                  amd64        tidy module for PHP