Two bugs in WP Solr Pro 2.3.8 plugin when indexing documents cause fatal errors

  • connect
    Participant
    1 month, 1 week ago #45768

    I was having issues with WP Solr Pro (500 server errors when trying to index), so I cleared out the index and started indexing from scratch. I got two PHP fatal errors in WP Solr Pro WordPress 2.3.8 plugin code that I managed to patch and get the indexing working again. I’m submitting them here so that you can include them in the next release.

    Firstly, I got this error:

    Error on line 1790 of file …/wp-content/plugins/wpsolr-pro/wpsolr/core/classes/utilities/class-wpsolr-option.php: foreach() argument must be of type array|object, string given

    The $results variable doesn’t appear to be an array at this point, so it was easy enough to check for that:
    if ( is_array( $results ) ) {
    foreach ( $results as $model_type => &$fields ) {
    $fields = array_keys( $fields );
    }
    }

    The second fatal error was this:

    Error on line 440 of file …\/wp-content\/plugins\/wpsolr-pro\/wpsolr\/core\/classes\/models\/post\/class-wpsolr-model-post.php: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given

    Similar fix here too – just make sure the variable is countable:

    if ( is_countable( $custom_fields ) && count( $custom_fields ) > 0 ) {

    wpsolr
    Keymaster
    1 month, 1 week ago #45769

    Thanks for the feedback.

    Did you upgrade WPSOlr from an old version? It looks like there is a mismatch in custom fields stored formats.

    connect
    Participant
    1 month, 1 week ago #45770

    Yes, the plugin was updated from 2.3.3 to 2.3.8, but I would have hoped that deleting the index would have avoid any compatibility changes between versions. Still, the fixes I suggested are probably worth including in a future release, just in case someone else jumps more than one version like we did.

    wpsolr
    Keymaster
    1 month, 1 week ago #45771

    It will. Thanks.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.