Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

Update Image.php #963

Merged
merged 3 commits into from
Sep 7, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Faker/Provider/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,15 @@ public static function image($dir = null, $width = 640, $height = 480, $category
$fp = fopen($filepath, 'w');
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_FILE, $fp);
$success = curl_exec($ch);
$success = curl_exec($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;

if ($success) {
fclose($fp);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this happen regardless of success?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

true

} else {
unlink($filepath);
}

curl_close($ch);
fclose($fp);
} elseif (ini_get('allow_url_fopen')) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the same checks go here in case curl isn't enabled?

// use remote fopen() via copy()
$success = copy($url, $filepath);
Expand Down