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

Already on GitHub? Sign in to your account

Check for a valid file created from tempnam() #478

Open
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants

cowlby commented Aug 4, 2013

I was getting a weird "file not found" error from the uglifycss filter. After searching through the code, I found that my tempdir was not writeable by PHP due to a permissions problem. tempnam() returns false when a file could not be created for writing as in this scenario. If the error is not caught, the uglifycss command runs with a missing argument (the filename). Suggesting a simple exception to help troubleshooting.

Check for a valid file created from tempnam()
tempnam() returns false when a file could not be created for writing. If the error is not caught, the uglifycss command runs with a missing argument (the filename).
Collaborator

stof commented Aug 9, 2013

Can you do the same in all filters using a temp file ?

cowlby commented Aug 17, 2013

Can you please check my sample fix that I can deploy to all the filters subsequently?

cowlby commented Aug 17, 2013

Also, just saw the build fail as I made a mistake with PHP 5.3 array de-referencing support. I can fix that if you guys can validate the use of tmpfile instead of tempnam.

Owner

kriswallsmith commented Sep 1, 2013

I'm 👍 for using tmpfile(). Help updating all the other filters would be much appreciated.

@stof stof commented on the diff Sep 12, 2013

src/Assetic/Filter/UglifyCssFilter.php
- file_put_contents($input, $asset->getContent());
- $pb->add($input);
+ fwrite($input, $asset->getContent());
+ $pb->add(stream_get_meta_data($input)['uri']);
@stof

stof Sep 12, 2013

Collaborator

Please don't use the array dereferencing to keep the compatibility with PHP 5.3. You need to assign stream_get_meta_data($input) to a variable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment