summaryrefslogtreecommitdiff
path: root/ext/pdo_mysql
diff options
context:
space:
mode:
authorDarek Slusarczyk <dariusz.slusarczyk@oracle.com>2019-02-11 18:47:58 +0100
committerDarek Slusarczyk <dariusz.slusarczyk@oracle.com>2019-02-11 18:47:58 +0100
commit9eacd9174c8705c869a9581647ace35e4d440907 (patch)
treea9d7a67ceb41a1cce48691da44f3c67aa80b9be6 /ext/pdo_mysql
parent2ca123e8f037f1c884dd56401ed966bf5b0f54b2 (diff)
parent6f7a47db5dc5a11333e131a071f20c0be19183a9 (diff)
downloadphp-git-9eacd9174c8705c869a9581647ace35e4d440907.tar.gz
Merge branch 'PHP-7.3' into PHP-7.4
Diffstat (limited to 'ext/pdo_mysql')
-rw-r--r--ext/pdo_mysql/mysql_driver.c15
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt5
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt26
-rw-r--r--ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt26
4 files changed, 69 insertions, 3 deletions
diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c
index a0a3e35e24..ad7989d660 100644
--- a/ext/pdo_mysql/mysql_driver.c
+++ b/ext/pdo_mysql/mysql_driver.c
@@ -484,6 +484,12 @@ static int pdo_mysql_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *return_
case PDO_MYSQL_ATTR_MAX_BUFFER_SIZE:
ZVAL_LONG(return_value, H->max_buffer_size);
break;
+#else
+ case PDO_MYSQL_ATTR_LOCAL_INFILE:
+ ZVAL_BOOL(
+ return_value,
+ (H->server->data->options->flags & CLIENT_LOCAL_FILES) == CLIENT_LOCAL_FILES);
+ break;
#endif
default:
@@ -770,6 +776,15 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options)
}
}
#endif
+ } else {
+#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
+ // in case there are no driver options disable 'local infile' explicitly
+ zend_long local_infile = 0;
+ if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
+ pdo_mysql_error(dbh);
+ goto cleanup;
+ }
+#endif
}
#ifdef PDO_MYSQL_HAS_CHARSET
diff --git a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
index 62051d7ae2..08cd8eb942 100644
--- a/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql___construct_options.phpt
@@ -19,7 +19,7 @@ MySQLPDOTest::skip();
try {
$db = new PDO($dsn, $user, $pass, array($option => $value));
if (!is_object($db) || ($value !== ($tmp = @$db->getAttribute($option))))
- printf("[%03d] Execting '%s'/%s got '%s'/%s' for options '%s'\n",
+ printf("[%03d] Expecting '%s'/%s got '%s'/%s' for options '%s'\n",
$offset,
$value, gettype($value),
$tmp, gettype($tmp),
@@ -172,8 +172,7 @@ MySQLPDOTest::skip();
[016] PDO::MYSQL_ATTR_DIRECT_QUERY should be on
[017] PDO::ATTR_EMULATE_PREPARES should be off
[018] PDO::MYSQL_ATTR_DIRECT_QUERY should be off
-[021] Execting '1'/boolean got ''/boolean' for options 'PDO::MYSQL_ATTR_LOCAL_INFILE'
-[023] Execting 'SET @a=1'/string got ''/boolean' for options 'PDO::MYSQL_ATTR_INIT_COMMAND'
+[023] Expecting 'SET @a=1'/string got ''/boolean' for options 'PDO::MYSQL_ATTR_INIT_COMMAND'
[024] SQLSTATE[42000] [1065] Query was empty
[025] SQLSTATE[42S02] [1146] Table '%s.nonexistent' doesn't exist
done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt
new file mode 100644
index 0000000000..5a0b5f67e0
--- /dev/null
+++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_default_off.phpt
@@ -0,0 +1,26 @@
+--TEST--
+ensure default for local infile is off
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+if (!MYSQLPDOTest::isPDOMySQLnd())
+ die("skip mysqlnd only test");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc');
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
+
+$dsn = MySQLPDOTest::getDSN();
+$user = PDO_MYSQL_TEST_USER;
+$pass = PDO_MYSQL_TEST_PASS;
+
+$db = new PDO($dsn, $user, $pass);
+echo var_export($db->getAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE)), "\n";
+echo "done!\n";
+?>
+--EXPECTF--
+false
+done!
diff --git a/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt b/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt
new file mode 100644
index 0000000000..4394bc0576
--- /dev/null
+++ b/ext/pdo_mysql/tests/pdo_mysql_local_infile_set_on.phpt
@@ -0,0 +1,26 @@
+--TEST--
+enable local infile
+--SKIPIF--
+<?php
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
+MySQLPDOTest::skip();
+if (!MYSQLPDOTest::isPDOMySQLnd())
+ die("skip mysqlnd only test");
+?>
+--FILE--
+<?php
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.inc');
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
+
+$dsn = MySQLPDOTest::getDSN();
+$user = PDO_MYSQL_TEST_USER;
+$pass = PDO_MYSQL_TEST_PASS;
+
+$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_LOCAL_INFILE => true));
+echo var_export($db->getAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE)), "\n";
+echo "done!\n";
+?>
+--EXPECTF--
+true
+done!