Skip to content

Commit 502b6aa

Browse files
committedApr 1, 2015
Fix "Warning: curl_setopt(): supplied argument is not a valid File-Handle resource"
1 parent 34d2b95 commit 502b6aa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎src/Curl/Curl.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,14 @@ public function downloadComplete($fh)
171171
}
172172

173173
// Fix "PHP Notice: Use of undefined constant STDOUT" when reading the
174-
// PHP script from stdin.
174+
// PHP script from stdin. Using null causes "Warning: curl_setopt():
175+
// supplied argument is not a valid File-Handle resource".
175176
if (!defined('STDOUT')) {
176-
define('STDOUT', null);
177+
define('STDOUT', fopen('php://stdout', 'w'));
177178
}
178179

179180
// Reset CURLOPT_FILE with STDOUT to avoid: "curl_exec(): CURLOPT_FILE
180-
// resource has gone away, resetting to default". Using null causes
181-
// "curl_setopt(): supplied argument is not a valid File-Handle
182-
// resource".
181+
// resource has gone away, resetting to default".
183182
$this->setOpt(CURLOPT_FILE, STDOUT);
184183

185184
// Reset CURLOPT_RETURNTRANSFER to tell cURL to return subsequent

0 commit comments

Comments
 (0)