Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42207 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35157 invoked from network); 9 Dec 2008 19:50:14 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Dec 2008 19:50:14 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 209.85.219.20 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 209.85.219.20 mail-ew0-f20.google.com Received: from [209.85.219.20] ([209.85.219.20:59983] helo=mail-ew0-f20.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F7/E7-11210-5FBCE394 for ; Tue, 09 Dec 2008 14:50:14 -0500 Received: by ewy13 with SMTP id 13so177518ewy.23 for ; Tue, 09 Dec 2008 11:50:09 -0800 (PST) Received: by 10.210.88.3 with SMTP id l3mr603352ebb.88.1228852209607; Tue, 09 Dec 2008 11:50:09 -0800 (PST) Received: from ?192.168.0.106? ([76.84.25.107]) by mx.google.com with ESMTPS id h4sm993014nfh.74.2008.12.09.11.50.08 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Dec 2008 11:50:08 -0800 (PST) Message-ID: <493ECBFD.6060407@chiaraquartet.net> Date: Tue, 09 Dec 2008 13:50:21 -0600 User-Agent: Thunderbird 2.0.0.18 (X11/20081125) MIME-Version: 1.0 To: internals Mailing List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: problem with include_path and write-based file functions From: greg@chiaraquartet.net (Gregory Beaver) Hi, This bug: http://bugs.php.net/bug.php?id=46680 uncovers 2 larger issues. 1) Where should a function like file_put_contents() create its file if it doesn't already exist and FILE_USE_INCLUDE_PATH is specified? The test for this is ext/standard/file/file_put_contents_variation4.phpt and a few others. file_put_contents($filename, "File in include path", FILE_USE_INCLUDE_PATH); arbitrarily creates $filename in the first portion of include_path on PHP 5.2, and arbitrarily creates $filename in cwd in PHP 5.3. Of course, if the file already exists in any of the include_path, both PHP 5.2 and 5.3 will overwrite it. The same is true of fopen() in write mode. 2) Should file_get_contents()/fopen() in read mode fall back to current directory if not found in include_path? The test for this is ext/standard/file/fopen_variation5.phpt and others In PHP 5.2, the functions simply fail if the file does not exist in include_path. Thus if include_path does not contain ".", the file is not found. In PHP 5.3, there is a fallback to check cwd for the file. For #1 I think both PHP 5.2 and 5.3 are broken. If you specify that a file should be written to inside include_path, it should fail if no file is found - allowing arbitrary file creation is just plain stupid and also dangerous - include_path has no business being used to create a file, it should only be used to find existing files. In any case, I think allowing include_path to be used at all for file modification is horrendous, and think it should be deprecated and removed from PHP 6. We should simply add file_resolve_path() function which can be used to locate a file. For #2 I think PHP 5.3 is broken, and the fallback to cwd should be removed from php_resolve_path. Comments? Greg P.S. the tests themselves should not create directories outside of their tests/ subdirectory, and should use things like PATH_SEPARATOR, but that's a minor issue