]> granicus.if.org Git - php/commitdiff
Skip tests when secure_file_priv dir not writable
authorMatteo Beccati <mbeccati@php.net>
Thu, 15 Dec 2016 08:31:00 +0000 (09:31 +0100)
committerMatteo Beccati <mbeccati@php.net>
Thu, 15 Dec 2016 08:31:00 +0000 (09:31 +0100)
ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt
ext/pdo_mysql/tests/pdo_mysql_prepare_load_data.phpt

index ebf22ef61bec0a2d63608b9c5ffdec471ebf9a76..38b49b6efaa48be6f210f77da14c035b7a12acaa 100644 (file)
@@ -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
index 37d9cbdb7768de5dab24c7228ff1465e72f8fa55..9b07ac2479ab7d596546ab6659b79ed75ae38daa 100644 (file)
@@ -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!