Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64160 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 19186 invoked from network); 5 Dec 2012 15:54:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Dec 2012 15:54:35 -0000 Authentication-Results: pb1.pair.com header.from=njaguar@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=njaguar@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) X-PHP-List-Original-Sender: njaguar@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-ob0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:55085] helo=mail-ob0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/C5-04278-93E6FB05 for ; Wed, 05 Dec 2012 10:54:34 -0500 Received: by mail-ob0-f170.google.com with SMTP id wp18so5403331obc.29 for ; Wed, 05 Dec 2012 07:54:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=4ZRtOHfKAW7d/ALx0IqAnI2hyn/e8id/0JuJi9NcEdM=; b=XZfWUfQCc22c0ypFDzH/TgoX2L7BBaauQnZ8bJjWxADMbhKjaVkRPpZTnF6sOJUrnV F0q6MrecfmvAsg50ye9YFSc5iwKqu4f8uAOdv4GKCL8MYnBQ6HDQVWyLcKDlaQYukyHh DnpqyQT6984PGnu72VpFWFecFsO8iwlugDCRRtJMscTv7sbWBjBGEdTgetrO2C2bIhpE ejrSq9i91A4xGESyq/NIPjmOmpOU9SuNRJ9g+5opUMa+GPNM9xIVHL1xCP9SedunbLRz +JWeXDDlb6EzB2uPOHz6nmcGMeYWSL0OVr0wv3x8JluwlCIBTScdleDiMeNJ+b+zzRWx E/lA== MIME-Version: 1.0 Received: by 10.60.23.232 with SMTP id p8mr14284059oef.53.1354722870894; Wed, 05 Dec 2012 07:54:30 -0800 (PST) Received: by 10.182.89.66 with HTTP; Wed, 5 Dec 2012 07:54:30 -0800 (PST) Date: Wed, 5 Dec 2012 09:54:30 -0600 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: date/strtotime poor performance - further digging (v 5.4.9) [PATCH] From: njaguar@gmail.com (Paul Taulborg) I ended up digging deeper and created a patch for this, and have created a bug with the patch attached. https://bugs.php.net/bug.php?id=63699 Summary of changes: - Created a new tz_checked_valid flag on the global date structure - Created a callback method when date.timezone is modified by the ini (set) - Callback checks validity if set during runtime, and will error (with line number) accordingly. This is probably useful for some users that might no otherwise have realized they made a mistake on their ini_set() line in their code. - In guess_timezone(), if tz_checked_valid is not set, attempts to validate, errors if cannot. As previously noted from my benchmarks, over 1 million runs, it increased performance from: date : 1.751 sec strftime : 1.872 sec strtotime : 3.195 sec to: date : 1.238 sec strftime : 0.999 sec strtotime : 2.337 sec Here is a test case to show that it will not blow up on invalid timezones, and revalidates accordingly: Note: If the ini is actually set wrong, it will not error until they call a date function that makes use of the timezone, just like before. Thanks!