-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Version 2.1.66
$ApiVersion = 2.1;
Describe the bug
Cascade of warnings coming from:
Deprecated: Use of "self" in callables is deprecated in /home/fullpriceexit/vendor/studio-42/elfinder/php/elFinderVolumeDriver.class.php on line 6891
Deprecated: Use of "self" in callables is deprecated in /home/fullpriceexit/vendor/studio-42/elfinder/php/elFinderVolumeDriver.class.php on line 6892
To Reproduce
Make sure server is running PHP 8.2+
Explanation
Old/Deprecated Syntax: In older PHP versions, you could pass a callable method to a function like is_callable() or call_user_func_array() using an array structure like: ['self', 'methodName'] or [self::class, 'methodName']
This syntax was often used when defining an anonymous function or callback that referenced another method within the same class.
The Problem in PHP 8.1+: PHP now wants the callable to be a static and resolved reference at the time it's passed. Using self, parent, or static in the first element of a callable array relies on runtime context.
The Recommended Fix: The correct and future-proof way to reference a static method within the same class (without relying on runtime context via self) is to use a closure or to ensure the method is actually called through a class instance or a defined static name.
If the original code on line 6891 was something like: if (is_callable(['self', 'method']))
The modern, non-deprecated way to achieve the same would be (if the method is static): if (is_callable([CLASS, 'method']))
Since this code is within the elFinder library's vendor files, it means elFinder needs an update to be fully compliant with PHP 8.1+. The simplest fix on your end is still to suppress the display of these warnings using the ini_set('display_errors', 0); approach in your connector file.
Expected behavior
Shouldn't thhrow an error. Setting error_reporting(0); at the start of php/elFinderVolumeDriver.class.php fixes everything.
Additional context
Might be nice to have a single debug var that turns errors off / on application wide. Since PHP can technically deprecate ANYTHING and break ANYTHING with every update, leaving errors off seems like the only way to make stuff "future proof", but then it is hell to debug.
P.S. AWESOME project guys. Wish it was a little easier to integrate with Quill but this is like a BETTER version of what CK Editor wants $500/month for! Quill (quilljs.com) is awesome too! It'd be great to see a Quill / el Finder integration.