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

Working with temp files #67

Closed
gottsohn opened this issue Feb 22, 2016 · 6 comments
Closed

Working with temp files #67

gottsohn opened this issue Feb 22, 2016 · 6 comments

Comments

@gottsohn
Copy link

The following functions in PHP fail to provide the correct result with files created using tempnam(…) function

  • is_readable
  • is_writeable

Imagine a file is being read into a tempfile from the internet, getID3 will fail to process it.

PHP 5.5.30

@JamesHeinrich
Copy link
Owner

Is this bug documented somewhere? Is it specific to PHP 5.5(.30)?

A quick test on PHP 5.3.3 (*nix) and PHP 5.4.7 (Win) showed no problems:
echo (is_readable($filename = tempnam('/tmp','getid3')) ? '' : 'not-').'readable: '.$filename;
What does that line of code output for you?

@gottsohn
Copy link
Author

It outputs false for me.
For is_readable and is_writeable, is_file works fine.
I came across the error on Google App Engine, where I host my application.

I have only tried this out on PHP 5.5.X.
I'll find time later on to break down the issue, but this is the result I've gotten so far.

@JamesHeinrich
Copy link
Owner

"false" is an unexpected output from that line -- it should say either readable or not-readable and confirmation of the temp filename that's generated. Perhaps this code is more explicit:

$filename = tempnam('/tmp', 'foo');
echo 'filename: '.$filename.'<br>';
echo (is_readable($filename) ? 'readable' : 'not-readable').'<br>';
echo (is_writeable($filename) ? 'writeable' : 'not-writeable').'<br>';
unlink($filename);

When you have time later to do some debugging it would be appreciated. After a few minutes of searching I can't find any other reports of the problem you describe with tempnam.

At this point my speculation is that tempnam() is returning false for you. getID3 attempts to auto-detect the appropriate system temp directory in which to create temp files, but if that's failing for you there is an override line you can uncomment in getid3.php line 63 where you can enter a temp directory you do have read/write access to.

@gottsohn
Copy link
Author

Sorry about that, my response was the bool value of is_writeable. I didn't explicitly run your code block.

Anyways, I ran a full test, the temp file can we written, read and copied to a different location (on the local file system), and so on, but will always return false from the two highlighted functions.

Here's the result from your code block as well.

filename: vfs://root/temp//tmp/foo56cb16f2992517.13579214
not-readable
not-writeable

It's a PHP issue, not the getID3 library.
I edited a piece of the library to get it to run properly on my app.
I could submit a PR later on with What-Why-How in detail so you'll get the full gist.

@JamesHeinrich
Copy link
Owner

I think filename: vfs://... is the key issue here.

Your analysis and code suggestions are welcome.

@JamesHeinrich
Copy link
Owner

Closing issue for now. If you have future analysis or suggestions you wish to post, please do so.

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

2 participants