I'm batch renaming/moving files based on ISO14496 metadata but I get an error because file handles aren't closed on object destruction.
Comment #1
Posted on Mar 5, 2012 by Happy PandaI am not sure whether the class should actually close the stream. However, you can do that yourself by passing a reference to a stream to the class and then manually close it after using the class. Try something like this:
{{{ ) { $reader = new Zend_Io_FileReader($filename); $iso = new Zend_Media_Iso14496($reader); ... // do something ... $iso = null; //destroy object ref $reader->close(); //close stream } }}}
I could perhaps add some code to close the stream automatically if the stream was opened by the class.
Comment #2
Posted on Mar 5, 2012 by Happy PandaOkay, changes made to subversion. Check out the repo and test with the latest code whether it works as you'd expect.
Comment #3
Posted on Mar 15, 2012 by Swift GiraffeComment deleted
Comment #4
Posted on Mar 15, 2012 by Swift GiraffeYour first workaround works, and I was using something similar. The change you made to the class doesn't work as expected, this is the code i tried:
$isom = new Zend_Media_Iso14496($fn);
unset($isom);
rename($fn, $fn.'.test');
?>
Btw setting to null like you did in your example doesn't destroy the object's reference, although that was what I remembered too, but xdebug_debug_zval('isom') still says refcount=1. They must have changed at some point 'cause that's what these clowns do, they keep changing PHP's behaviour and you end up spending days investigating obscure behavior :( ... so much for efficiency. Using unset() does destroy the reference, not that it matters much 'cause the GC still doesn't call the destructor until the script ends. I saw on some site someone said that even if you unset, your object might still be referenced by something other than a variable (??!!?). He didn't say what, and tbh I don't even care anymore.
Anyway man, thanks for your time and for your library, it's very useful :) Cheers.
Status: Fixed
Labels:
Type-Enhancement
Priority-Low