Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51648 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 62246 invoked from network); 9 Mar 2011 18:34:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2011 18:34:30 -0000 Authentication-Results: pb1.pair.com header.from=pencap@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=pencap@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: pencap@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-ew0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:64317] helo=mail-ew0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 63/04-40157-438C77D4 for ; Wed, 09 Mar 2011 13:34:29 -0500 Received: by ewy2 with SMTP id 2so221165ewy.29 for ; Wed, 09 Mar 2011 10:34:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=I/GeZWWZ2jAYQRqczXfWYwzaxM33jNIW7e4o1l/7qYo=; b=KDxyRErEoVSMYVWOHYjOw9UwhPQ3xkii7dplP2sZ61M2JXzhYbWzvTOvld46EAtKRC KvfsCGnKryLth700c8mPZil6Ogwbsc7kZmP/fr2tbXUSOYpL6qZ1P/7EKgoyqfJnnPWn eN1TpIVMtd7GmuxIZU4WsncSY11MpYRBf8BhY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=kA8aW6/U3e5MXKbAMaze4VIsV3o3jUY/r+ySmYAM0nX3KVa+b4y6FbETQ4zbjA50zR ShpWCMRDixDaLyJHD8pzpnESJQubpjungZXV3l40G1EVDvKVjkDocXBtxs8HH0H85cKl 1ric2QdfoL/pewIQb0UdMqwi57FPz0EX1MXfE= MIME-Version: 1.0 Received: by 10.213.107.79 with SMTP id a15mr270285ebp.86.1299695658383; Wed, 09 Mar 2011 10:34:18 -0800 (PST) Received: by 10.213.10.6 with HTTP; Wed, 9 Mar 2011 10:34:18 -0800 (PST) In-Reply-To: References: <4F372AC9-7C88-43E5-BCE1-58B5BFD34135@easen.co.uk> <09CA4F51-E610-4070-ACF0-A35E8BE5EF1D@easen.co.uk> Date: Wed, 9 Mar 2011 12:34:18 -0600 Message-ID: To: PHP Internals Cc: Marc Easen , =?UTF-8?B?QW5kcsOpIFLDuG1ja2U=?= Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: [PATCH] Bug #49852 & Bug #53065 - Adding spl_autoload_case_sensitivity() From: pencap@gmail.com (Mike Willbanks) I was just thinking about this again and have a working patch for this. It seems like the only potential BC break is on linux if people were using all lowercase paths. To me it would seem like this is really not the case or would happen only sometimes. The quick solution is to utilize the following patch: Index: ext/spl/php_spl.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ext/spl/php_spl.c (revision 306413) +++ ext/spl/php_spl.c (working copy) @@ -229,7 +229,7 @@ zval *result =3D NULL; int ret; - class_file_len =3D spprintf(&class_file, 0, "%s%s", lc_name, file_extensi= on); + class_file_len =3D spprintf(&class_file, 0, "%s%s", class_name, file_exte= nsion); #if DEFAULT_SLASH !=3D '\\' { It would seem that this could be addressed for PHP Next with the BC break (since it is very unlikely to really hit). Regards, Mike On Tue, Feb 22, 2011 at 9:04 PM, Mike Willbanks wrote: > I think it would be better just to fix the issue in the code. =C2=A0If yo= u > run include 'My/Path/To/File.php' does it lowercase it? =C2=A0It does not= . > The expected behavior would to not lowercase it. =C2=A0There are ways tha= t > this could be fixed directly in the code. =C2=A0The only real requirement > that it looks like the need for lowercase is for the hash table that > is internally maintained by spl_autoload for the loading of classes. > > To fix this w/o a BC break and give the expected behavior, it could > look for the class first by lowercasing the path and then secondarily > look by the correct case (or the opposite). =C2=A0The only real usefulnes= s > of the default behavior is for windows users whereas the majority of > installs is on *nix platforms. > > The other way (and cleaner IMO) than the current patch if the above > wouldn't work is to add a forth parameter to spl_autoload_register to > tell it to by type sensitive. =C2=A0The only BC break that is really > possible here is for *nix users that are expecting it to always be > lowercase, however, this seems to be more or less an edge case and > should ultimately just be fixed. =C2=A0I have not seen one project that > utilizes the spl_autoload default functionality since their class > naming structure generally consists of upper and lowercase letters. > > To keep consistency it could certainly be a boolean with the function > declaration of (keeping BC of course): > bool spl_autoload_register ([ callback $autoload_function [, bool > $throw =3D true [, bool $prepend =3D false [, bool $case_sensitive =3D fa= lse > ]]]] ) > > I can build a patch for this route if someone would like... I just > think that instead of the SplClassLoader proposal something also needs > to happen with the spl_autoload area as well. > > Regards, > > Mike > >> Wouldn't it be better to join forces with the SplClassLoader proposal[1]= ? >> A C implementation of PSR-0 has been prpoposed [2] as well, and would be >> nice to get something like that into 5.next >> >> However for your imminent performance needs, you should be aware that an >> hash map based autoloaders can be fast as well [3]. >> >> >> [1] http://wiki.php.net/rfc/splclassloader >> [2] http://blog.runpac.com/post/splclassloader-php-extension-benchmarks >> [3] >> http://weierophinney.net/matthew/archives/245-Autoloading-Benchmarks.htm= l >> >> Best >> ar >> >> >> On Wed, Jan 12, 2011 at 11:53 PM, Marc Easen wrote: >> >>> Hello again, >>> >>> Has anyone had a chance to look at my patch? >>> >>> Forgive me for being quite eager to get this into trunk, as it will imp= rove >>> the performance of all PHP Frameworks which currently implement their o= wn >>> autoloader method due to the oddities of the SPL autoloader. >>> >>> >>> >>> Kind Regards >>> Marc >>> >>> >>> On 26 Dec 2010, at 13:20, Marc Easen wrote: >>> >>> Hello everyone, >>> >>> Firstly I would like to introduce myself, my name is Marc Easen and I'v= e >>> working with PHP for past 6 years or so. I'm really excited to see wher= e PHP >>> is going with the addition of namespaces and now traits, and hopefully = I'm >>> able to contribute back to PHP community. >>> >>> I've currently working on a high performance PHP Framework based on ver= sion >>> 5.3.3+ (5.3.99-dev for traits). Due to the high performance nature of t= his >>> framework I've been looking at ways of improving the loading of the cla= sses. >>> It seems by default the spl_autoload() function lowercases the class na= me >>> before trying to locate the file, a couples of users have reported this >>> previously and have requested a fix (bug #49852 >>> http://bugs.php.net/bug.php?id=3D49852 & bug #53065 >>> http://bugs.php.net/bug.php?id=3D53065). spl_autoload() lower casing th= e >>> class names when it is trying to locate the file does not work on *nix = based >>> system in a lot of PHP Frameworks - Zend Framework being on of them. >>> >>> Understanding the requirement to support backwards compatibility both >>> submitters suggested implementing a spl_autoload_case_sensitivity() >>> function. The patch I have attached adds such a function to the SPL >>> extension. The patch is against trunk (r306670), it also includes phpt = tests >>> for this function. >>> >>> Please could someone review this patch and let me know what you think. >>> >>> Kind Regards, >>> >>> Marc >>> >>> >>> >>> >>> >> >