Quantcast
Channel: WordPress.org Forums » [WP-Filebase Download Manager] Support
Viewing all articles
Browse latest Browse all 1341

PHP 8.0 issue: deprecated create_function() and curly braces

$
0
0

Replies: 0

Hi there,

I’m aware that this plugin is discontinued (even the free version hosted here), but I’d like to point out that there are a few issues when using it under PHP 8.0

There is a call to the obsolete, deprecated and now removed create_function() on line 77 of wp-filebase/wp-filebase.php. This was an ancient hack from the PHP 4 days which has survived until now. PHP has supported anonymous functions (or closures) for quite a long time now, and these are free from the security issues (usage of eval()…) and bad performance of create_function().

You will basically need to rewrite line 77 in the following way:
return function() { $p=func_get_args();return wpfb_call("' . $cl . '","' . $fnc . '",$p,true); };

There is also a nasty habit of using curly braces {} to address array indexes. This was once common practice under very early versions of PHP but has been made obsolete years ago. PHP 7.4 flags them as deprecated; PHP 8.0 finally removes them.

You’ll have to go through at least

wp-filebase/classes/Item.php
wp-filebase/classes/File.php
wp-filebase/classes/Output.php
wp-filebase/classes/ProgressReporter.php
wp-filebase/classes/GetID3.php
wp-filebase/classes/Admin.php
wp-filebase/classes/Search.php
wp-filebase/classes/Sync.php
wp-filebase/classes/Download.php
wp-filebase/classes/Setup.php

and manually search for things such as $opt{0}, $val{1} and similar constructs etc., and change them to $opt[0], $val[1] and so forth. This is one of those things that takes time and patience and is not trivial to automate (you can try, using regular expressions, and a tool such as sed… make sure you’ve made a backup first!).

Once the ‘core’ plugin is thus ‘cleaned up’, there are many more of those to fix under the extras and vendor directories… just a quick search for {0 gives a hundred results or so, and there are possibly many more instances.


Viewing all articles
Browse latest Browse all 1341

Latest Images

Trending Articles



Latest Images