Welcome Guest, Not a member yet? Register   Sign In
Possible discrepancy in FileLocator between Windows and Linux
#1

Hi all,

I think I stumbled upon a small discrepancy between the handling/output of the FileLocator but wanted to confirm if this is useful to be discussed on GitHub before posting there.

Summary
When trying to load a view, the use of '\' instead of '/' will load the correct file on Windows machines but throw a file not found exception on Linux systems (whereof the latter should be intended behaviour as far as I understand).

Test Case
Setup CodeIgniter 4.0.4 with everything working fine on a Windows developement environment (XAMPP).
Install lonnieezell\myth-auth latest developement version. ( This is not needed, as the error should be reproducible with any view, however, I want to tell the whole story here).
Publish myth-auth configuration and views via spark.
Rename view in published myth-auth config from 'App\Views\Auth\login' to 'Auth\Login'. (Please don't ask why, it was a stupid idea)

Expected Result
Upon trying to load the view, the FileLocator will check whether the requested file name is namespaced or not. As 'Auth\Login' appears to be namespaced it will search for the file that way but not find it and will throw a file not found exception.

Actual Result
Surprisingly, on Windows systems, the view file is still correctly located and displayed.
On the Linux production system the exception is thrown as expected.

Suggested Action
While I know that changing the view file path the way I did was just wrong, I think this might happen to other beginners, too (be it due to lack of caution or understanding or simple misspelling).
As far as I understand the principle of the FileLocator, the behaviour on the Windows machine is wrong here, as the view file should not be detected. I think this should be related to the different directory seperators on Windows/Linux, but would need to take a closer look where exactly the detection wrongly succeeds.
The problem I see with this discrepancy is (as it happened to me), that the system works nicely in the developement environment, but instantly crashes when pushed to production, such that I needed to do some debugging in production.

Do you think this is an issue to be adressed?

Cheers
Alex
Reply


Messages In This Thread
Possible discrepancy in FileLocator between Windows and Linux - by aschmitz - 08-14-2020, 12:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB