rfc:tempnam-suffix-v2

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:tempnam-suffix-v2 [2023/08/08 18:36] athosrfc:tempnam-suffix-v2 [2023/08/27 01:45] (current) athos
Line 3: Line 3:
   * Date: 2023-08-02   * Date: 2023-08-02
   * Author: Athos Ribeiro, athoscribeiro@gmail.com   * Author: Athos Ribeiro, athoscribeiro@gmail.com
-  * Status: Draft+  * Status: Voting
   * First Published at: http://wiki.php.net/rfc/tempnam-suffix-v2   * First Published at: http://wiki.php.net/rfc/tempnam-suffix-v2
   * Based on work by Stefan Neufeind, neufeind@php.net at https://wiki.php.net/rfc/tempnam-suffix   * Based on work by Stefan Neufeind, neufeind@php.net at https://wiki.php.net/rfc/tempnam-suffix
Line 47: Line 47:
  
 ===== Open Issues ===== ===== Open Issues =====
-  - The **tempnam** **prefix** paramter is sanitized through the **basename** function when path separators are present in the provided string, using only the last part of the provided path. For instance, **foo/bar** would become **bar**. We could not find the historical reasons for the **prefix** parameter to behave as described, but for consistency, we are currently using the same approach for the new **suffix** parameter. +
-  - Only the 63 first characters passed to the **prefix** paramter are used. Although we could not find the historical reasons behind this decision, we are currently replicating the behavior for the new **suffix** parameter. +
-  - **In windows systems**, none of the characters passed as a suffix will be appended to the file name (i.e., **the suffix parameter will be ignored**). This is due to the underlying function (and API) used to generate temporary files, which do not provide means to set a suffix. While we could provide a custom implementation (which could be proposed in a future RFC to provide more consistency for tempnam), the current windows API being used includes a .TMP extension to the generated files, which AFAICT, does matter in windows systems. I also found a related discussion in an old bug at https://bugs.php.net/bug.php?id=44222.+
  
 ===== Unaffected PHP Functionality ===== ===== Unaffected PHP Functionality =====
Line 55: Line 53:
  
 ===== Future Scope ===== ===== Future Scope =====
-Re-work tempnam'windows implementation to match the default non-windows behaviors.+ 
 +The **tempnam** **prefix** paramter is sanitized through the **basename** function when path separators are present in the provided string, using only the last part of the provided path. For instance, **foo/bar** would become **bar**. We could not find the historical reasons for the **prefix** parameter to behave as described, but for consistency, we are currently using the same approach for the new **suffix** parameter. 
 + 
 +Moreover,o nly the 63 first characters passed to the **prefix** paramter are used. Although we could not find the historical reasons behind this decision, we are currently replicating the behavior for the new **suffix** parameter. 
 + 
 +Finally, **In windows systems**, none of the characters passed as a suffix will be appended to the file name (i.e., **the suffix parameter will be ignored**). This is due to the underlying function (and API) used to generate temporary files, which do not provide means to set a suffix. While we could provide a custom implementation, the current windows API being used includes a .TMP extension to the generated files, which AFAICT, does matter in windows systems. I also found a related discussion in an old bug at https://bugs.php.net/bug.php?id=44222. Changing such behaviors would require a different RFC. 
 + 
 +Therefore, the following changes are left for future work: 
 * Re-visit tempnam's implementation to verify the need to truncate the prefix/suffix params at 64 characters. * Re-visit tempnam's implementation to verify the need to truncate the prefix/suffix params at 64 characters.
 * Re-visit tempnam's implementation to verify the need to modify the prefix/suffix params thorugh the basename function. * Re-visit tempnam's implementation to verify the need to modify the prefix/suffix params thorugh the basename function.
 +* Re-work tempnam's windows implementation to match the default non-windows behaviors.
 +
 +The first two could be part of a minor refactoring effort for tempnam. The last one, however, should be part of a major refactoring effort for tempnam.
  
 ===== Proposed Voting Choices ===== ===== Proposed Voting Choices =====
Line 68: Line 77:
  
 ===== Implementation ===== ===== Implementation =====
-TBD+As linked above 
 + 
 +===== Vote ===== 
 + 
 +<doodle title="Support optional suffix parameter in tempnam" auth="athos" voteType="single" closed="false" closeon="2023-09-10T00:00:00Z"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
 ===== References ===== ===== References =====
rfc/tempnam-suffix-v2.1691519790.txt.gz · Last modified: 2023/08/08 18:36 by athos