com php-src: Skip tests when secure_file_priv dir not writable: ext/pdo_mysql/tests/pdo_mysql_exec_loa d_data.phpt
ext/pdo_mysql/tests/pdo_mysql_prepare _load_data.phpt
| From: | Matteo Beccati | Date: | Thu, 15 Dec 2016 08:31:00 +0000 |
| Subject: | com php-src: Skip tests when secure_file_priv dir not writable: ext/pdo_mysql/tests/pdo_mysql_exec_loa d_data.phpt ext/pdo_mysql/tests/pdo_mysql_prepare _load_data.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96336@lists.php.net to get a copy of this message | ||
Commit: 0c9324ea9ba32e85ccca4f52287d013b0a6ef2a4
Author: Matteo Beccati <mbeccati@php.net> Thu, 15 Dec 2016 09:31:00 +0100
Parents: 60da307c615d7f9b4f1b8a6013489e874fe10a01
Branches: PHP-5.6 PHP-7.0 PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0c9324ea9ba32e85ccca4f52287d013b0a6ef2a4
Log:
Skip tests when secure_file_priv dir not writable
Changed paths:
M ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
M ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
Diff:
diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
index ebf22ef..38b49b6 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
@@ -16,6 +16,17 @@ if (count($tmp) < 2)
if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
die("skip Test cannot be run against remote database server");
+$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
+if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] !=
'')) {
+ if (!is_writable($row['value']))
+ die("skip secure_file_priv directory not writable: {$row['value']}");
+
+ $filename = $row['value'] . DIRECTORY_SEPARATOR .
"pdo_mysql_exec_load_data.csv";
+
+ if (file_exists($filename) && !is_writable($filename))
+ die("skip {$filename} not writable");
+}
+
?>
--FILE--
<?php
diff --git a/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
b/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
index 37d9cbd..9b07ac2 100644
--- a/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
+++ b/ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt
@@ -16,6 +16,17 @@ if (count($tmp) < 2)
if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1'))
die("skip Test cannot be run against remote database server");
+$stmt = $db->query("SHOW VARIABLES LIKE 'secure_file_priv'");
+if (($row = $stmt->fetch(PDO::FETCH_ASSOC)) && ($row['value'] !=
'')) {
+ if (!is_writable($row['value']))
+ die("skip secure_file_priv directory not writable: {$row['value']}");
+
+ $filename = $row['value'] . DIRECTORY_SEPARATOR .
"pdo_mysql_exec_load_data.csv";
+
+ if (file_exists($filename) && !is_writable($filename))
+ die("skip {$filename} not writable");
+}
+
?>
--FILE--
<?php
@@ -115,4 +126,4 @@ Warning: PDOStatement::execute(): SQLSTATE[HY000]: General error: %s in %s on li
1 => %d,
2 => %s,
)
-done!
\ No newline at end of file
+done!