justinwhall / wp-buildhook-deploy

WordPress plugin to trigger build hooks and deploy your static site.

Home Page:https://justinwhall.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning in Wordpress

arturhenryy opened this issue · comments

hey this warning seems to appear randomly when saving stuff in my wp-backend.

WordPress 4.9.8

Warning: Missing argument 2 for LBN_Post::save_post() in /homepages/5/d368499181/htdocs/si-wp-backend/wp-content/plugins/littlebot-netlify-master/includes/class-lbn-post.php on line 125

Warning: Missing argument 3 for LBN_Post::save_post() in /homepages/5/d368499181/htdocs/si-wp-backend/wp-content/plugins/littlebot-netlify-master/includes/class-lbn-post.php on line 125

Warning: Cannot modify header information - headers already sent by (output started at /homepages/5/d368499181/htdocs/si-wp-backend/wp-content/plugins/littlebot-netlify-master/includes/class-lbn-post.php:125) in /homepages/5/d368499181/htdocs/si-wp-backend/wp-includes/pluggable.php on line 1219

@justinwhall could you take a look into this issue? this happens quite often.

Looks like a unused variable. You can safely remove update from this method if you want to fix it before I get to it.

Getting this error aswell. Removing update from the save_post method did not seem to work for me.

Fatal error: Uncaught ArgumentCountError: Too few arguments to function LBN_Post::save_post(), 1 passed in /app/public/wp-includes/class-wp-hook.php on line 286 and exactly 2 expected in /app/public/wp-content/plugins/littlebot-netlify-master/includes/class-lbn-post.php:125 Stack trace: #0 /app/public/wp-includes/class-wp-hook.php(286): LBN_Post->save_post(49) #1 /app/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /app/public/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /app/public/wp-includes/post.php(2705): do_action('delete_post', 49) #4 /app/public/wp-includes/revision.php(413): wp_delete_post(49) #5 /app/public/wp-admin/edit-form-blocks.php(305): wp_delete_post_revision(49) #6 /app/public/wp-admin/post.php(166): include('/app/public/wp-...') #7 {main} thrown in /app/public/wp-content/plugins/littlebot-netlify-master/includes/class-lbn-post.php on line 125

Action hooks take a parameter that specifies how many arguments the callback function takes. In your case, it's wrong. My guess is it's still 3. example here

@justinwhall hey this error still persists even with your suggested solution.
now it is the problem that the save post gets passed only one param while it still excepts two when i am trying to delete something permanently in the trash. are you planning on cleaning this up?

Fatal error: Uncaught ArgumentCountError: Too few arguments to function LBN_Post::save_post(), 1 passed in /home1/jmbdgnmy/public_html/wp-includes/class-wp-hook.php on line 286 and exactly 2 expected in /home1/jmbdgnmy/public_html/wp-content/plugins/littlebot-netlify-master/includes/class-lbn-post.php:125

Hey guys, the original issue is warning. This warning will not show (and shouldn't) in production of you set debug to false define( 'WP_DEBUG', false );. This will not effect how the plugin work at all. In my above recommendations, I was providing some pseudo code if ya'll would like to fix the warning on your own or better yet, submit a PR. With that being said, yes, you'd need adjust coupled code to work with my suggestions other wise you could, for example, end up with fatal errors like above.

And don't fear, the original warning will be fixed.

@justinwhall yeah i think the warning is not that big of a deal but it also throws a 502 error under the conditions i described above which makes it impossible to permanently delete posts for example and in another environment it had thrown 502 errors when i saved pages

Are you saying your edited version of this plugin does or the master branch of this plugin does?

I ran into this today with a client site. I upgraded to 5.1.1 WP w/ Gutenberg and keep getting 500 on pages that are under nested parents. I edited the plugin down to 1 param $post and the specification earlier in the file to define what how many params the function needs. (sorry if my terminology is off). The warning still exists but the admin page stops the 500 error. I'll submit a PR when I am fresh.

Just released 0.9.1. which adds support for PHP 7.3 and patches this issue.