Skip to content

Commit 2fb88ff

Browse files
committed
Fix "Operation not permitted" (PHP 5.3) and "Permission denied" (HHVM) errors
1 parent 001cfd6 commit 2fb88ff

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,8 @@ public function testDownload()
338338
$upload_test->server('upload_response', 'POST', array(
339339
'image' => '@' . $upload_file_path,
340340
));
341-
$uploaded_file_path = $upload_test->curl->response;
341+
$uploaded_file_path = $upload_test->curl->response->file_path;
342342
$this->assertNotEquals($upload_file_path, $uploaded_file_path);
343-
$this->assertEquals(md5_file($upload_file_path), md5_file($uploaded_file_path));
344343
$this->assertEquals(md5_file($upload_file_path), $upload_test->curl->response_headers['ETag']);
345344

346345
// Download the file.
@@ -363,8 +362,12 @@ public function testDownload()
363362
$this->assertFalse(is_bool($download_test->curl->response));
364363
$this->assertFalse(is_bool($download_test->curl->raw_response));
365364

365+
// Remove server file.
366+
$this->assertEquals('true', $download_test->server('upload_cleanup', 'POST', array(
367+
'file_path' => $uploaded_file_path,
368+
)));
369+
366370
unlink($upload_file_path);
367-
unlink($uploaded_file_path);
368371
unlink($downloaded_file_path);
369372
$this->assertFalse(file_exists($upload_file_path));
370373
$this->assertFalse(file_exists($uploaded_file_path));

tests/PHPCurlClass/server.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,15 @@
124124
} elseif ($test === 'upload_response') {
125125
$tmp_filename = tempnam('/tmp', 'php-curl-class.');
126126
move_uploaded_file($_FILES['image']['tmp_name'], $tmp_filename);
127+
header('Content-Type: application/json');
127128
header('ETag: ' . md5_file($tmp_filename));
128-
echo $tmp_filename;
129+
echo json_encode(array(
130+
'file_path' => $tmp_filename,
131+
));
132+
exit;
133+
} elseif ($test === 'upload_cleanup') {
134+
$unsafe_file_path = $_POST['file_path'];
135+
echo var_export(unlink($unsafe_file_path), true);
129136
exit;
130137
} elseif ($test === 'download_response') {
131138
$unsafe_file_path = $_GET['file_path'];

0 commit comments

Comments
 (0)