php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66046 Use PHP's default temp. directory
Submitted: 2013-11-07 13:28 UTC Modified: 2015-04-01 16:20 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: manuel-php at mausz dot at Assigned: danack (profile)
Status: Closed Package: imagick (PECL)
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2013-11-07 13:28 UTC] manuel-php at mausz dot at
Description:
------------
imagick should use PHP's default temp. directory. Since PHP 5.5 there's also a sys_temp_dir ini-directive the admin can define.

Change is simple:
--- imagick.c.orig      2013-11-07 14:01:04.067659662 +0100
+++ imagick.c   2013-11-07 14:01:19.107922325 +0100
@@ -2889,6 +2889,7 @@
 
 PHP_RINIT_FUNCTION(imagick)
 {
+       SetImageRegistry(StringRegistryType, "temporary-path", (const void *)php_get_temporary_directory(TSRMLS_C), NULL);
        return SUCCESS;
 }


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-11-07 14:43 UTC] mkoppanen@php.net
Does this override MAGICK_TMP_PATH environment variable?
 [2013-11-07 14:48 UTC] manuel-php at mausz dot at
Yes, looks like it does: http://www.imagemagick.org/api/MagickCore/resource_8c_source.html#l00376

Maybe we should only do this if MAGICK_TEMPORARY_PATH & MAGICK_TMPDIR is *not* set?
 [2013-11-07 15:05 UTC] mkoppanen@php.net
This would be unexpected for users who expect the files to be stored into TMPDIR if other env variables are not set.

While this is a sensible idea this has to wait until next major version.
 [2013-11-07 15:12 UTC] manuel-php at mausz dot at
TMPDIR-users won't be affected unless they use PHP >=5.5 and set sys_temp_dir + TMPDIR to different values. Doubt that there's a even single user using such configuration.

php_get_temporary_directory returns INI(sys_temp_dir) OR ENV[TMPDIR] OR P_tmpdir, whichever comes first.
 [2013-11-07 15:23 UTC] mkoppanen@php.net
Other scenario where this seems problematic are cases when user calls putenv runtime and expects that to change the temporary directory. Not sure how common this is.
 [2013-11-07 15:36 UTC] manuel-php at mausz dot at
Yes, that's another scenario.

However I'm perfectly fine with adding this change to your next major release.
 [2015-01-09 21:30 UTC] danack@php.net
-Assigned To: +Assigned To: danack
 [2015-01-09 21:30 UTC] danack@php.net
> imagick should use PHP's default temp. directory.

Although the functionality to set the temp path, it shouldn't be in the ini file. Instead we should expose it through functions. I think we need:

Imagick::setRegistry calls SetImageRegistry
Imagick::getRegistry calls GetImageRegistry
Imagick::listRegistry returns an array of all the key pairs in the registry through GetNextImageRegistry() and GetImageRegistry


http://www.imagemagick.org/api/registry.php
 [2015-04-01 16:20 UTC] danack@php.net
-Status: Assigned +Status: Closed
 [2015-04-01 16:20 UTC] danack@php.net
This was implemented in Imagick 3.3.0RC1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC