bobbingwide / oik-bob-bing-wide

More lazy smart shortcodes
https://www.oik-plugins.com/oik-plugins/oik-bob-bing-wide-more-lazy-smart-shortcodes/
GNU General Public License v2.0
1 stars 0 forks source link

Support PHP 7.3 and 7.4 #17

Closed bobbingwide closed 4 years ago

bobbingwide commented 7 years ago

Changes in PHP 7.1 mean that some logic which worked without problems under PHP 7 and earlier now issue Notices, Warnings Errors and even Fatal errors.

In the code for the [bw_post] and [bw_page] shortcodes we get Warning: Illegal string offset 'post_type' from the following code construct.

function bw_post( $atts=null, $content=null, $tag=null ) {
  $atts['post_type'] = bw_array_get_from( $atts, "post_type,0", "post" ); 

The code assumes that $atts is passed as an array or can be handled as an array. When no parameters are set on the shortcode then $atts is passed as null. The warning is issued from the assignment.

Many WordPress shortcodes avoid this issue by using shortcode_atts(), which casts the $atts parameter to an array. We might be able to find a solution by changing bw_shortcode_event, in oik.

bobbingwide commented 4 years ago

Well, PHP 7.1's out of support now so let's just make it 7.3 and 7.4

Message issued with PHP 7.4 Notice: Trying to access array offset on value of type null in C:\apache\htdocs\wordpress\wp-content\plugins\oik-bob-bing-wide\shortcodes\oik-csv.php on line 153

bobbingwide commented 4 years ago

V1.34.0 has now been released to oik-plugins.com and tested with PHP 7.3 and PHP 7.4. This can now be closed.