simple-lightbox
simple-lightbox copied to clipboard
PHP 8: Deprecation notices
PHP 8 has changed how certain things are handled (function references, keywords, etc.). While functionality of such code has not changed, PHP 8 considers its usage to be deprecated (i.e. slated for removal in a future version of PHP).
As a result, while SLB is fully functional when running PHP 8, PHP may provide a deprecation notice for some parts of its code depending on a site's error reporting level.
By default, WordPress does not display PHP notices. If you are seeing undesired PHP notices (e.g. on a live site), disabling WordPress' debug output is recommended by removing the following from the site's wp-config.php
:
// Enable WP_DEBUG mode
define( 'WP_DEBUG', true );
See WordPress' debugging documentation for more details, including alternative debugging settings (such as logging debug messages for review rather than outputting them to the browser).
Work on updating code deprecated in PHP 8 is underway. Reporting specific deprecation notices is not necessary.
#1046 would be an easy merge toward fixing some of these
@archetyped we haven't seen a plugin update overall since November '22, to say nothing of this issue with a PR ready to go. Should we expect further updates to this plugin?
Notice: PHP Deprecated: Use of "parent" in callables is deprecated in /home/webiste/public_html/wp-content/plugins/simple-lightbox/includes/class.options.php on line 501 is easy to fix
Replace
$ret = call_user_func_array( array( 'parent', 'add' ), $args );
with
$ret = call_user_func_array( array( parent::class, 'add' ), $args );
I do not understand why it is not yet fixed in offical code.
Is simple-lightbox abandoned?
trim(): Passing null to parameter #1 ($string) of type string is deprecated
wp-content/plugins/simple-lightbox/includes/class.utilities.php:545
I think this can be fixed by changing the following in /includes/class.utilities.php:545
.
The notice is gone and everything still seems to be working.
Fom
$obj = trim( $obj, $sep );
// Strip base object
if ( 0 === strpos( $obj, $base . $sep ) ) {
$obj = substr( $obj, strlen( $base . $sep ) );
}
To
if ( null !== $obj ) {
$obj = trim( $obj, $sep );
// Strip base object
if ( 0 === strpos( $obj, $base . $sep ) ) {
$obj = substr( $obj, strlen( $base . $sep ) );
}
}
I found another.
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/html/web/app/plugins/simple-lightbox/includes/class.field_type.php on line 435
Just change
$target_property = $this->util->apply_filters_ref_array( "process_placeholder_${tag}", [ '', $this, &$instance, $layout, $data ], false );
To
$target_property = $this->util->apply_filters_ref_array( "process_placeholder_{$tag}", [ '', $this, &$instance, $layout, $data ], false );
Also been receiving this error for a long time, in wp-admin, filling up my logs...
trim(): Passing null to parameter #1 ($string) of type string is deprecated
wp-content/plugins/simple-lightbox/includes/class.utilities.php:545
I have no idea why it is calling this function on every admin page with null as $obj - but anyway....
The function is: validate_client_object - so it should actually validate the object (well, string actually) is actually an string before doing anything else, yes?
The conditional check detailed above would work - can you please add this?
if ( null !== $obj ) {
$obj = trim( $obj, $sep );
// Strip base object
if ( 0 === strpos( $obj, $base . $sep ) ) {
$obj = substr( $obj, strlen( $base . $sep ) );
}
}
Great plugin otherwise, thanks!
"Work on updating code deprecated in PHP 8 is underway. Reporting specific deprecation notices is not necessary."
- @archetyped - Nov. 2, 2023 ???
Please, it's literally a couple lines of code. Asking your loyal plugin users to disable wp_debug is not a tenable solution.
I have no idea why it is calling this function on every admin page with null as $obj - but anyway....
I think because it's triggered by add_admin_page
.
+1 for this