Hello,
I’m working on a WordPress theme that is currently running under PHP v. 7.0. When run under PHP7.1 +, certain pages/functions result in a fatal error and the resulting pages are blank. I have narrowed the issue down to 3 search page templates that have an array declaration that has a blank [ ] which I know will not automatically convert to an array under PHP 7.1+. Check the following code snippet under line 9.
> <?php
> $_ids = array();
> function getIds( $query ) {
> global $wpdb;
> $tmp = "";
> $searchresults = $wpdb->get_results($query, ARRAY_A);
> if ( !empty ($searchresults) ) {
> foreach( $searchresults as $_post ) {
> $tmp[] = $_post['ID'];
> }
> }
> return $tmp;
> }
>
> global $wpdb;
>
> $query = $wpdb->prepare("SELECT p.* FROM $wpdb->posts p WHERE p.post_type = %s AND p.post_status = %s", 'listing', 'publish');
> $all = getIds( $query );
> $_ids = ( !empty($all) ? ( !empty($_ids) ? array_intersect( $_ids, $all) : $all ) : "" );
>
> if (get_option('wp_filtersold') == 'Yes') {
> $query = $wpdb->prepare("SELECT p.* FROM $wpdb->posts p, $wpdb->postmeta p1
> WHERE p.ID = p1.post_id AND p1.meta_key= %s AND p1.meta_value = %s", 'sold_value', 'No');
> $sbr = getIds( $query );
> $_ids = ( !empty($sbr) ? ( !empty($_ids) ? array_intersect( $_ids, $sbr) : "" ) : "" );
> }
>
> ?>
Is there an easy fix to this? The developer has not been heard from in over a year and there is no direct support or upgrades to the theme likely.
Thanks,
Peter