Abstracted filesystem in XF3

digitalpoint

Well-known member
Licensed customer
Flysystems is used for the abstracted filesystem in XenForo 2, but I was just thinking... it's not particularly complicated. Maybe it would be worthwhile thinking about getting rid of that third-party library and just use standard PHP streams instead? Internally could just use stream_wrapper_register() to register a XenForo filesystem of sorts and then just use normal PHP functions. Similar to how https is a stream wrapper for URLs within normal functions:

PHP:
file_get_contents('https://example.com');

Why not just have wrappers and the abstracted filesystem is just handled by that wrapper?

PHP:
file_get_contents('internal-data://attachments/10/10747-5c6c6dc97fc6298686c67d0d703a9fd4.data');
file_put_contents('data://avatars/h/0/1.jpg', $contents);

Wouldn't be terribly difficult, and you just do the same thing internally that you are already doing with the Flysystems implementation. Call the appropriate class for the individual functions (for example "Local").

Anyway, just a thought for something relatively simple that gets rid of a fairly substantial dependency and probably would be faster anyway since you don't need to initialize the Flysytems stack.
 
Upvote 8
One thing to consider is if the native library is used, please validate it supports references to mounted NFS/CIFS volumes via symlinks. We've run into some issues in the past where mounted file shares can cause strange behavior.
 
One thing to consider is if the native library is used, please validate it supports references to mounted NFS/CIFS volumes via symlinks. We've run into some issues in the past where mounted file shares can cause strange behavior.
Honestly symlinks would probably work better because for the "local" filesystem, you would just internally be using native PHP functions (file_get_contents, fopen, etc.) which work fine with symlinks.
 
Back
Top Bottom