Hello @sroskylo1
I am sorry about the issue you are experiencing and I am happy to assist you with this.
Can you please confirm you are getting this error when uploading the file to media library or by adding image-file via drag-and-dropping it into the WordPress-Editor.
Can you please also share which theme you are using?
Thanks!
Error After Update The Version 2.2.10
2023/01/12 18:34:03 [error] 334496#0: *516 FastCGI sent in stderr: “PHP message: PHP Fatal error: Uncaught Error: Cannot use object of type WP_Post as array in /var/www/htdocs/wp-content/plugins/w3-total-cache/Util_AttachToActions.php:76
Stack trace:
0 /var/www/htdocs/wp-includes/class-wp-hook.php(287): W3TC\Util_AttachToActions->on_pre_post_update(475576, Object(WP_Post))
1 /var/www/htdocs/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(”, Array)
2 /var/www/htdocs/wp-includes/plugin.php(484): WP_Hook->do_action(Array)
3 /var/www/htdocs/wp-includes/post.php(4129): do_action(‘pre_post_update’, 475791, Array)
4 /var/www/htdocs/wp-includes/post.php(5959): wp_insert_post(Array, false, true)
5 /var/www/htdocs/wp-includes/post.php(4488): wp_insert_attachment(Array, false, 0, false)
6 /var/www/htdocs/wp-admin/includes/ajax-actions.php(3080): wp_update_post(Array)
7 /var/www/htdocs/wp-includes/class-wp-hook.php(287): wp_ajax_save_attachment(”)” while reading response header from upstream, request: “POST /wp-admin/admin-ajax.php HTTP/1.0”, upstream: “fastcgi://127.0.0.1:9074”
-
This reply was modified 2 years, 5 months ago by
wpbuild.
I’m hanging in here because I have the same error. Also only since the update to the new version
Hello @michasumi @wpbuild
Thank you for reaching out and I am sorry about the problem you are experiencing.
We are working on the Fix for this and this will be fixed as soon as possible.
Thank you for your patience and please rollback to the previous version of the plugin for the time being.
Thanks!
Hello,
no problem, but can I just downgrade in the plugin?
Hello @michasumi
You can try replacing the /wp-content/plugins/w3-total-cache/Util_AttachToActions.php by downloading the file from the previous version from here.
Thanks
Super thank you. 🙂
Oh and of course a big thank you in general, for all the effort that went into the plugin.
-
This reply was modified 2 years, 5 months ago by
michasumi.
I have update on_pre_post_update function at Util_AttachToActions.php and the error is gone (row 63):
public function on_pre_post_update( $post_id, $post = null ) {
$post = get_post( $post_id );
// if attachment changed - parent post has to be flushed
// since there are usually attachments content like title
// on the page (gallery).
if ( 'attachment' === $post->post_type ) {
$post_id = $post->post_parent;
$post = get_post( $post_id );
}
if ( 'draft' !== $post->post_status ) {
return;
}
$cacheflush = Dispatcher::component( 'CacheFlush' );
$cacheflush->flush_post( $post_id );
}
p.s. I know it’s a dummy code, but it’s work) lol
-
This reply was modified 2 years, 5 months ago by
cro55er.
Hello @cro55er
Thank you for your feedback.
We’ve fixed this and the patch will be available soon.
We’ve updated line 73 in Util_AttachToActions.php
from:
$post = get_post( $post_id );
To:
$post = get_post( $post_id, ARRAY_A );
@sroskylo1 @michasumi @wpbuild Please try this solution and let me know if it works!
Thank you again for your patience.
Hello, @vmarko! Thanks for the better solution)
-
This reply was modified 2 years, 5 months ago by
cro55er.
We have published patch release 2.2.11 with the fix for this issue. We do apologize for any inconvenience.
Hello @sroskylo1 @cro55er @michasumi @wpbuild
We’ve just released the patch update 2.2.11 with the fix for this issue.
Please make sure to update the plugin and let me know if this fixes the problem for you!
Once again, thank you all for you patience and for bringing this to our attention!
Yes it works.
Thank you @vmarko @joemoto for the quick fix of the bug.
Yep it works fine, thank you 🙂