Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Warning: fclose(): xx is not a valid stream resource #7

Closed
harikt opened this issue May 15, 2015 · 4 comments
Closed

PHP Warning: fclose(): xx is not a valid stream resource #7

harikt opened this issue May 15, 2015 · 4 comments

Comments

@harikt
Copy link

harikt commented May 15, 2015

I was making use of the Rackspace adapter via flysytsem .

The code is as below .

$flysystem = new Filesystem(new RackspaceAdapter($container));
$fp = fopen($file, 'r+');
if ($fp) {
    $flysystem->writeStream($destination, $fp);
    fclose($fp);
}

I noticed when trying to close it says not a resource.

PHP Warning: fclose(): xx is not a valid stream resource in ...

Wonder whether flysystem at some point is automatically closing the same ?

Good thing is it is sending the data to the Cloud. So the file is already present on both local and server :) .

@frankdejonge
Copy link
Member

@harikt Hi, this is something I know. The rackspace sdk closes the resource internally. Which is a unexpected side-effect. One should always first check if the resource is still valid before closing.

@harikt
Copy link
Author

harikt commented May 15, 2015

Thank you. Just wanted to mention it.

Hari K T

You can ring me : +91 9388 75 8821

http://harikt.com , https://github.com/harikt ,
http://www.linkedin.com/in/harikt , http://www.xing.com/profile/Hari_KT

Skype : kthari85
Twitter : harikt

On Fri, May 15, 2015 at 11:59 AM, Frank de Jonge notifications@github.com
wrote:

@harikt https://github.com/harikt Hi, this is something I know. The
rackspace sdk closes the resource internally. Which is a unexpected
side-effect. One should always first check if the resource is still valid
before closing.


Reply to this email directly or view it on GitHub
#7 (comment)
.

@dopesong
Copy link

If I'm correct Amazon S3 SDK does the same.

So I think there should be mentioned that about it:

if (is_resource($stream)) {
    fclose($stream);
}

@harikt
Copy link
Author

harikt commented May 26, 2015

I do agree it will be nice to mention it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants