Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64410 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33462 invoked from network); 21 Dec 2012 10:23:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Dec 2012 10:23:40 -0000 Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=brianofish@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.83.42 as permitted sender) X-PHP-List-Original-Sender: brianofish@gmail.com X-Host-Fingerprint: 74.125.83.42 mail-ee0-f42.google.com Received: from [74.125.83.42] ([74.125.83.42:33106] helo=mail-ee0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 79/47-20281-AA834D05 for ; Fri, 21 Dec 2012 05:23:38 -0500 Received: by mail-ee0-f42.google.com with SMTP id c41so2352919eek.29 for ; Fri, 21 Dec 2012 02:23:35 -0800 (PST) X-Received: by 10.14.0.133 with SMTP id 5mr30509546eeb.29.1356085415831; Fri, 21 Dec 2012 02:23:35 -0800 (PST) Received: from rofl.localnet ([213.135.15.139]) by mx.google.com with ESMTPS id 43sm20786562eed.10.2012.12.21.02.23.33 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Dec 2012 02:23:34 -0800 (PST) To: internals@lists.php.net Date: Fri, 21 Dec 2012 11:23:31 +0100 Message-ID: <2231783.D0TjppFWz5@rofl> User-Agent: KMail/4.9.4 (Linux/3.6.11-k10-bof; KDE/4.9.4; x86_64; ; ) In-Reply-To: <50D43307.8060704@mmd.net> References: <50D1D9B9.4060505@mmd.net> <2081737.rfJYvbmhGA@rofl> <50D43307.8060704@mmd.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [PHP-DEV] Crashes in lex_scan at Zend/zend_language_scanner.c / BUG #52752 From: php@bof.de (Patrick Schaaf) > I understood you correctly using temp file and then rename should fix > that? Like this? > >> file_put_contents('test.tpl.tmp', " mt_rand(4000, 5000))." ?>\n", LOCK_EX); > rename('test.tpl.tmp','test.tpl'); Exactly! You could also do it like this: $tmpname = 'test.tpl.tmp.'.posix_getpid(); file_put_contents($tmpname, '....'); rename($tmpname, 'test.tpl'); That way - adding the process ID to the temporary filename - does not run into the danger of two processes changing the file at the same time. The LOCK_EX should handle that case, too, but I usually go for the "appended PID" approach and don't worry about file locking at all. best regards Patrick