diff options
author | MichaelHeerklotz <michael.heerklotz@web.de> | 2018-04-23 06:09:18 +0300 |
---|---|---|
committer | Matthieu Aubry <mattab@users.noreply.github.com> | 2018-04-23 06:09:18 +0300 |
commit | 93a363ce7b5dd284b9d463e39442c2da0211b200 (patch) | |
tree | 6794efd347bb7f093172453dd3dfd990968fd849 /core/Db | |
parent | cde2b27ec4343aaeb5a21aa39a2f10c26d7bbb02 (diff) |
Enable LOAD DATA LOCAL INFILE for PHP >= 5.6.17 when mysqlnd is used. (#12710)
* Enable LOAD DATA LOCAL INFILE for PHP >= 5.6.17 when mysqlnd is used. See https://bugs.php.net/bug.php?id=68077
Added setting "load_data_infile_remote" to skip local file access for setups where database and webserver are not on the same system.
* Switch to using multi_server_environment config and tweak boolean logic.
Diffstat (limited to 'core/Db')
-rw-r--r-- | core/Db/BatchInsert.php | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/Db/BatchInsert.php b/core/Db/BatchInsert.php index 6e27f51891..a0c6718ed5 100644 --- a/core/Db/BatchInsert.php +++ b/core/Db/BatchInsert.php @@ -179,7 +179,11 @@ class BatchInsert * this requires that the db user have the FILE privilege; however, since this is * a global privilege, it may not be granted due to security concerns */ - $keywords = array(''); + if (Config::getInstance()->General['multi_server_environment']) { + $keywords = array(); // don't try 'LOAD DATA INFILE' if in a multi_server_environment + } else { + $keywords = array(''); + } /* * Second attempt: using the LOCAL keyword means the client reads the file and sends it to the server; @@ -187,10 +191,12 @@ class BatchInsert * @see http://bugs.php.net/bug.php?id=54158 */ $openBaseDir = ini_get('open_basedir'); - $safeMode = ini_get('safe_mode'); + $isUsingNonBuggyMysqlnd = function_exists('mysqli_get_client_stats') && version_compare(PHP_VERSION, '5.6.17', '>='); + $safeMode = ini_get('safe_mode'); - if (empty($openBaseDir) && empty($safeMode)) { - // php 5.x - LOAD DATA LOCAL INFILE is disabled if open_basedir restrictions or safe_mode enabled + if (($isUsingNonBuggyMysqlnd || empty($openBaseDir)) && empty($safeMode)) { + // php 5.x - LOAD DATA LOCAL INFILE only used if open_basedir is not set (or we're using a non-buggy version of mysqlnd) + // and if safe mode is not enabled $keywords[] = 'LOCAL '; } |