• Got the following error:

    An error of type E_ERROR was caused in line 433 of the file /home/geoffmobile/public_html/blog/wp-content/plugins/efficient-related-posts/efficient-related-posts.php. Error message: Uncaught Error: [] operator not supported for strings in /home/geoffmobile/public_html/blog/wp-content/plugins/efficient-related-posts/efficient-related-posts.php:433
    Stack trace:
    #0 /home/geoffmobile/public_html/blog/wp-content/plugins/efficient-related-posts/efficient-related-posts.php(448): efficientRelatedPosts->_findRelations(Object(WP_Post), true)
    #1 /home/geoffmobile/public_html/blog/wp-includes/class-wp-hook.php(289): efficientRelatedPosts->processPost(Object(WP_Post))

    Fix is below:
    In efficient-related-posts.php
    find the function called: _findRelations()
    Replace the following block of code:

    			if ($processRelated) {
    				foreach ( $allRelatedPosts as $p ) {
    					$threshold = get_post_meta($p->ID, '_relation_threshold', true);
    
    					if ( empty($threshold) || $threshold <= $p->matches ) {
    						// Get the current related posts
    						$relatedPosts = get_post_meta($p->ID, '_efficient_related_posts', true);
    						$relatedPosts[] = array('ID'=>$post->ID,'post_title'=>$post->post_title,'post_excerpt'=>$post->post_excerpt);
    						// Find the relations, but limit the posts that are checked to save memory/time
    						$this->_findRelations( $p->ID, false, $relatedPosts );
    					}
    				}
    			}

    with

    			if ($processRelated) {
    				foreach ( $allRelatedPosts as $p ) {
    					$threshold = get_post_meta($p->ID, '_relation_threshold', true);
    
    					if ( empty($threshold) || $threshold <= $p->matches ) {
    						// Get the current related posts
    						$relatedPosts = get_post_meta($p->ID, '_efficient_related_posts', true);
                                                    if (empty($relatedPosts)) {
                                                        $relatedPosts = array();
                                                    }
    						$relatedPosts[] = array('ID'=>$post->ID,'post_title'=>$post->post_title,'post_excerpt'=>$post->post_excerpt);
    						// Find the relations, but limit the posts that are checked to save memory/time
    						$this->_findRelations( $p->ID, false, $relatedPosts );
    					}
    				}
    			}
  • The topic ‘Fixing bug when updating post for the first time’ is closed to new replies.