front / wp-redisearch

Flexible and fast search engine for Wordpress.
26 stars 5 forks source link

PHP Fatal error on Save Post #10

Closed thanasis991 closed 3 years ago

thanasis991 commented 3 years ago

There is a problem with wp_redisearch_index_post_on_publish (index update) hook function on post save/publish.

After wp_redisearch_index_post_on_publish is fired on save_post, wp_insert_post i get this error:

2021/01/11 17:50:48 [error] 1612#0: *37678 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined method FKRediSearch\Index::prepare_post() in /var/www/vhosts/my.site.tld/wp-content/plugins/redisearch/src/Admin/Admin.php:335
Stack trace:
#0 /var/www/vhosts/my.site.tld/wp-includes/class-wp-hook.php(287): WpRediSearch\Admin->wp_redisearch_index_post_on_publish()
#1 /var/www/vhosts/my.site.tld/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
#2 /var/www/vhosts/my.site.tld/wp-includes/plugin.php(478): WP_Hook->do_action()
#3 /var/www/vhosts/my.site.tld/wp-includes/post.php(4260): do_action()
#4 /var/www/vhosts/my.site.tld/wp-includes/post.php(4354): wp_insert_post()
#5 /var/www/vhosts/my.site.tld/wp-admin/includes/post.php(419): wp_update_post()
#6 /var/www/vhosts/my.site.tld/wp-admin/post.php(227): edit_post()
#7 {main}
  thrown in /var/www/vhosts/my.site.tld/wp-content/plugins/redisearch/src/Admin/Admin.php on line 335" while reading response header from upstream, client: 79.129.48.149, server: my.site.tld, request: "POST /wp-admin/post.php HTTP/1.1", upstream: "fastcgi://unix:/etc/opt/remi/php74/sock/my.site.tld.sock:", host: "my.site.tld", referrer: "https://my.site.tld/"

Indeed, i have mass searched all project and vendor files but function prepare_post does not exist anywhere. The only function that exists is preparePost but this does not exist in \FKRediSearch\Index but in \WpRediSearch\RediSearch\Index

and as i can see the FKRediSearch Class is called $index = new \FKRediSearch\Index($client); . . $indexing_options['fields'] = $index->prepare_post( $post_id ); (Line 335:Admin.php)

the same applies for $index->deletePosts( $index_name, $post_id ); (Line 298: Admin.php)

and for $index->addPosts( $index_name, $post_id, $indexing_options ); (Line 388: Admin.php)

-- Indexing and Searching are working as expected.

wp-redisearch v.0.3.1 PHP 7.4.9 on nginx/1.18.0

foadyousefi commented 3 years ago

Thanks for the report and detailed explanation. This is a mistake I did while updating to the newest RediSearch version. Working on it and will release the fix in a very short time.

foadyousefi commented 3 years ago

Hi @thanasis991

I fixed the issue and released a new version. If you download 0.3.2, it should resolve this error.

By the way, this plugin is also available on Wordpress plugins directory: https://wordpress.org/plugins/redisearch/

Highly appreciate it if you could confirm the error has been fixed.

thanasis991 commented 3 years ago

Thanks. I will check it in a while and get back to you with the results.

I have also spotted some other problems. Note my DB has ~1.100.000 posts to be indexed

I will report them later today

foadyousefi commented 3 years ago

I will be more than happy if you explain other issues.

But please open new issue(s) if the other problem(s) are not related to this one.

foadyousefi commented 3 years ago

Closing since there is no response.