Skip to content

Conversation

@manuelm
Copy link
Contributor

@manuelm manuelm commented Nov 7, 2013

Move php_shutdown_temporary_directory() from php_module_shutdown()
to php_request_shutdown()

Move php_shutdown_temporary_directory() from php_module_shutdown()
to php_request_shutdown()
@kaplanlior
Copy link
Contributor

if you want this to be merged to the 5.4, please mark the pull request against the php-5.4 branch instead of master.

@manuelm
Copy link
Contributor Author

manuelm commented Nov 7, 2013

Thanks, I've removed my wish as I'm not sure how relevant that is for 5.4. There's no sys_temp_dir ini directive so only users using apache putenv are affected.
I leave this open for you to decide.

@jpauli
Copy link
Member

jpauli commented Feb 23, 2015

Not sure about it.
Putting the shutdown code from request to module shutdown is the quick and dirty way of doing things, which may have a little inpact on performances.

I was thinking about reseting the env in the ini set handler for sys_temp_dir, which would then need to be changed (OnUpdateStringUnempty actually)
I'm however spotting a problem that the temporary_directory variable is a global that is not protected as it should be (http://lxr.php.net/xref/PHP_5_5/main/php_open_temporary_file.c#179), this may need to be addressed as well.

@lifeforms
Copy link

I'm hit hard by this problem, as we give virtualhosts their own tmp directory, but tempnam() and sys_get_temp_dir() returns random results all over the place... It would really be awesome if this bug got some love.

I wonder if caching the function's result is really needed at all. I see the cache was introduced in 2002. The function's contents do not look very expensive, and I would assume that user scripts don't call this function enormous numbers of times...

@jpauli
Copy link
Member

jpauli commented Apr 29, 2015

I have made some improvements about this bug.
Can be found at https://github.com/jpauli/php-src/tree/fix-66048

If OK, I'll then review it again then merge it

@lifeforms
Copy link

Wow, that looks awesome. I will test it tomorrow!

@kaplanlior
Copy link
Contributor

@lifeforms any news?

@lifeforms
Copy link

@kaplanlior Oh, sorry, I commented on the PHP bug itself: https://bugs.php.net/bug.php?id=66048 Copying my comments:

The fix resolves the issue completely!

First built php7 master from source on Ubuntu 14.04 LTS to reproduce the problem on PHP7: yep!

Then built fix-66048: problem resolved! :)

I tried to apply the diff to 5.6.8 but wasn't immediately successful as it's quite different (error_clear_last and such), do you think it can be backported?

@jpauli
Copy link
Member

jpauli commented May 6, 2015

This cannot be backported as it could break apps in stable branches.
I'll merge this against PHP7.

@manuelm
Copy link
Contributor Author

manuelm commented May 7, 2015

@jpauli In your first comment you claim moving the php_shutdown_temporary_directory function from module to request shutdown handler (you said it the other way round) is the "quick and dirty way" of doing things. So you came up with a solution which is doing exactly the same (plus some renames and moves).

Anyway I'm fine with your solution for PHP7 but can someone please merge THIS fix to the PHP 5.6 branch. PHP 5.6 won't be gone anytime soon and the fix is really very simple and straight forward.

@manuelm
Copy link
Contributor Author

manuelm commented May 7, 2015

Furthermore: We're using this patch since I've created this PR. Customers have thousands of apps running, no breakage. In fact the current behavior breaks apps because wrong sys_temp_dir variables get passed to them. fpm and cgi/fastcgi don't suffer from this bug and no breaking apps in sight.

@lifeforms
Copy link

Yeah, current behavior is very problematic :( What could be wrong with the PR?

@jpauli
Copy link
Member

jpauli commented May 13, 2015

This has been merged in 5.5 and up

@jpauli jpauli closed this May 13, 2015
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

Successfully merging this pull request may close these issues.

4 participants