MrFisc Posted August 3, 2018 Posted August 3, 2018 I'm currently receiving some complaints from a few of my users for an application i released saying that they're getting this error: Class 'IPS\Helpers\Form\CheckBox' not found I don't receive this error when I install the application locally on a fresh install of the software. Does anyone know what might be causing this? He is running 4.3.5 and I'm running 4.3.4, i'm curious if there might have been a change between these two versions that caused this.
CodingJungle Posted August 3, 2018 Posted August 3, 2018 7 minutes ago, MrFisc said: I'm currently receiving some complaints from a few of my users for an application i released saying that they're getting this error: Class 'IPS\Helpers\Form\CheckBox' not found I don't receive this error when I install the application locally on a fresh install of the software. Does anyone know what might be causing this? He is running 4.3.5 and I'm running 4.3.4, i'm curious if there might have been a change between these two versions that caused this. it is \IPS\Helpers\Form\Checkbox not CheckBox, that is the only thing i see that could cause it, but it should cause havoc for everyone if that is the reason.
MrFisc Posted August 3, 2018 Author Posted August 3, 2018 1 minute ago, CodingJungle said: it is \IPS\Helpers\Form\Checkbox not CheckBox, that is the only thing i see that could cause it, but it should cause havoc for everyone if that is the reason. Yup that was the issue. I've sent out instructions on how to resolve it and will be patching it in the next release. For my test system i'll need to research how to get my web server to be case sensitive to avoid this potentially happening in the future.
CodingJungle Posted August 3, 2018 Posted August 3, 2018 class names are case insensitive, but it is the autoloader that is throwing the error, since the filename is Checkbox.php (so when \IPS\Helpers\Form\CheckBox comes in, it can't find the file, so its not loading the class).. so it is always a good idea to call a class by the way it is declared. if i had to take a wild guess, i would say on your dev, the Checkbox class is being loaded properly before you calling it with CheckBox, but it is not loaded before hand for the other users.
Martin A. Posted August 4, 2018 Posted August 4, 2018 I would say it's a Windows/UNIX thing, where Windows don't care about case and UNIX does.
CodingJungle Posted August 4, 2018 Posted August 4, 2018 1 hour ago, Martin A. said: I would say it's a Windows/UNIX thing, where Windows don't care about case and UNIX does. yeah, you're right. its the underlying OS that is the issue ? (windows you can't have a file called foo.txt and Foo.txt, cause it is case insensitive). i don't think there is a way to correct this in a config for php or apache in windows, i doubt IPS would be willing to renamed all their files/folders to lower case, so the autoloader can just do: require mb_strtolower( $className).'.php'; and load the class regardless of OS. One thing you can do if you want to make your windows more like linux, you could use WSL (windows subsystem for linux) to install ubuntu, and run a LAMP stack thru it, but that isn't as easy as it sounds and not for everyone ?
CodingJungle Posted August 4, 2018 Posted August 4, 2018 @bfarber @Daniel F @Mark @Lindy they could add something like this in the autoloader, right after they call reflections on line 316 of init.php if (mb_stripos(PHP_OS, 'WIN') === 0) { $actualClass = $reflection->getName(); $userClass = "{$namespace}\\_{$class}"; if( $actualClass !== $userClass ){ trigger_error( "Class '{$namespace}\\{$class}' not found", \E_USER_ERROR ); } } Reflections will return the actual class name, compare it with the called class name, and if they don't match, throw an error. its the only way i can think of to put a psuedo case sensitive check without having to drastically alter things :).
Aiwa Posted August 4, 2018 Posted August 4, 2018 I submitted this as a bug a while back. Paraphrase of the answer... ... Unfortunately, this is a PHP quirk with case-sensitivity with regards to class names. Consider the following test case: <?php namespace IPS\core\modules\front\members; class profile {} var_dump( class_exists( 'IPS\core\modules\front\members\Profile', FALSE ) ); class_exists() will return TRUE in this case. ..... PHP says the class exists regardless of case, but when attempting to load the class it fails. My bug report was around the DEV center saying a class exists when creating a code hook when the code hook is destined to not function if case defined doesn't match the class.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.