Skip to content

Commit

Permalink
Due to a bug in PHP failure is not reported properly by file_put_cont…
Browse files Browse the repository at this point in the history
…ents(), etc. if the bucket does not exist or the write fails for some other reason:

https://bugs.php.net/bug.php?id=60110

So we call trigger_error with E_USER_WARNING to give some indication that things are not right.
  • Loading branch information
Tom Boutell committed Oct 21, 2011
1 parent 864935b commit a1ed30d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/wrapper/aS3StreamWrapper.class.php
Expand Up @@ -936,6 +936,15 @@ public function stream_flush()
$response = $this->getService()->create_object($this->info['bucket'], $this->info['path'], array('body' => $this->data, 'acl' => $this->getOption('acl'), 'contentType' => $this->getMimeType($this->info['path'])));
if (!$response->isOK())
{
// PHP calls stream_flush when closing a stream (before calling stream_close, FYI),
// but it doesn't pay any attention to the return value of stream_flush:

// PHP bug https://bugs.php.net/bug.php?id=60110

// Call trigger_error so the programmer is not completely in the dark.
// This is similar to what the native file functionality does on I/O errors

trigger_error("Unable to write to bucket " . $this->info['bucket'] . ", path " . $this->info['path'], E_USER_WARNING);
return false;
}
$this->updateCache();
Expand Down

0 comments on commit a1ed30d

Please sign in to comment.