ryankozak
Forum Replies Created
-
Forum: Plugins
In reply to: [Widget Logic] Issues with PHP 7The eval() function will throw an error code if your widget logic code is not perfect. For instance
!is_page('contact')will work as expected, but if you were to forget the quotes and input something like!is_page(contact)it will output an error message to the page, which was not thrown in PHP 5.Other than that the only changes necessary for full compatibility are as @storyman stated, on lines 90 & 93.
Line 90 becomes:
$import = perg_split("/\n/",file_get_contents($_FILES['wl-options-import-file']['tmp_name'], false));Line 93 becomes:
list($key, $value) = preg_split("/\t/",$import_option);
Forum: Plugins
In reply to: [Widget Logic] Issues with PHP 7As others have mentioned the split() function has depreciated in PHP 7.
I’m also noticing an additional concern. I’ve installed the plugin on a PHP 7 test environment, and seeing this error printed repeatedly
wp-content/plugins/widget-logic/widget_logic.php(286) : eval()'d code on line 1It seems PHP 7 has changed the
eval()function to return errors, not booleans.As of PHP 7, if there is a parse error in the evaluated code, eval() throws a ParseError exception. Before PHP 7, in this case eval() returned FALSE and execution of the following code continued normally. It is not possible to catch a parse error in eval() using set_error_handler().
On line 286 there is a conditional
if(!eval($wl_value), with the way the PHP 7 function works this statement will no longer return True/False, but print errors all over the screen.Anyhow, I’m surprised this plugin hasn’t been updated for PHP 7 comparability yet due to it’s popularity. I’d rather work on a fix that would benefit the community than rework my theme to omit using the plugin entirely. If I’m able I’ll follow up with a patched version.