Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.76k stars 889 forks source link

post-new.php not working. #7531

Closed frhtea closed 7 years ago

frhtea commented 7 years ago

Hi; wp 4.8, yoast 5.0.2

post-new.php not working.

tested.

error_reporting(E_ALL); ini_set(‘display_errors’, 1);

echo error.

Catchable fatal error: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post, null given in /var/www/clients/client1/web2/web/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php on line 37

HTTP ERROR 500

I can not add new posts.

Why?

Thanks, good working..

thulshof commented 7 years ago

Thanks for reporting this issue.

We'll need to know if this behavior is caused by a conflict with a plugin or theme. Therefore we want to ask you to do the following;

If it still occurs:

If it doesn't occur anymore:

If the problem reoccurred after reactivating one of your plugins, please add that information to your bug report.

Thanks!

frhtea commented 7 years ago

Log in on your WordPress website. (OK) Deactivate all non-Yoast plugins. (OK) Switch your theme to a standard theme like Twenty Fourteen. (OK)

ADD NEW POST : The problem continues..

Help me?

thulshof commented 7 years ago

Thanks for your response. How exactly can we reproduce this? Can you please tell us the exact steps you perform?

thulshof commented 7 years ago

Closing this issue due to inactivity. If this issue is still relevant, please reopen with the requested information.

speedyprem commented 7 years ago

@thulshof ,

I am also facing the same error after upgrading the Yost SEO plugin to the latest version that is 5.2. Here is the error:

Catchable fatal error: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post, null given in /home/aeroxtec/public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php on line 37

Can you please help to get rid of this error.

thulshof commented 7 years ago

@speedyprem How can we reproduce this error? Which steps should we perform? Please provide us with the exact steps to reproduce this issue, so we can start debugging.

soklysa commented 7 years ago

In the following file: public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php

Edit LINE 37: public function save_post( $post_id, WP_Post $post ) {

Should be: public function save_post( $post_id, $post ) {

tboodra commented 7 years ago

I was having the same issue with WP 4.8.1 and Yoast 5.4.

I was unable to add new posts to my custom post types that I created using the CPT UI plugin. Disabling Yoast let me create new posts, but when it was enabled i got 500 errors. PHP Catchable fatal error: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post, null given in /nas/content/live/boldfolks/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php on line 37

When I changed the line mentioned above and did some testing, everything seemed to work fine, but I do get a warning now in my error log file. PHP Warning: Invalid argument supplied for foreach() in /nas/content/live/boldfolks/wp-content/plugins/wordpress-seo/admin/metabox/class-metabox.php on line 1067

Tebbott commented 7 years ago

Having this issue too. I'm unable to add any new posts to a custom post type, created with the "CPT UI" plugin.

Error in error_log: PHP Catchable fatal error: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post

I've just updated Yoast SEO plugin, but still getting the error.

Editing the class-link-watcher.php file, as suggested above, fixes this problem and allows me to add new posts.

Is this something that's going to be edited in the plugin, in a future release?

Edit: This hasn't fully fixed the issue. I can now create a new post, however, Post attributes, Format, and Custom Taxonomies are no longer being output in the back-end. Again, the custom taxonomy was created using 'CPTUI'.

lateek35 commented 7 years ago

Also facing this issue, can't create a new page With Yoast 5.4.2 and wordpress 4.8.2, no other plugin activated

Fatal error: Uncaught TypeError: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post,null given,
called in /var/www/vhosts/werk.fr/mywpvhost.fr/web/wp/wp-includes/class-wp-hook.php on line 300 
and defined in /var/www/vhosts/werk.fr/mywpvhost.fr/web/app/plugins/wordpress-seo/admin/links/class-link-watcher.php:37 

Stack trace: 
#0 /var/www/vhosts/werk.fr/mywpvhost.fr/web/wp/wp-includes/class-wp-hook.php(300): WPSEO_Link_Watcher->save_post(0, NULL) 
#1 /var/www/vhosts/werk.fr/mywpvhost.fr/web/wp/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array) 
#2 /var/www/vhosts/werk.fr/mywpvhost.fr/web/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array) 
#3 /var/www/vhosts/werk.fr/mywpvhost.fr/web/wp/wp-includes/post.php(3510): do_action('save_post', 0, NULL, false) 
#4 /var/www/vhosts/werk.fr/mywpvhost.fr/web/wp/wp-admin/includes/post.php(607): wp_insert_post(Array) 
#5 /var/www/vhosts/werk.fr/bad in /var/www/vhosts/werk.fr/mywpvhost.fr/web/app/plugins/wordpress-seo/admin/links/class-link-watcher.php on line 37

Maybe this issue should reopen ? @thulshof

palmiak commented 6 years ago

Also having exactly this problem - looks like turning off "Text link counter" solved the problem for the moment.

jrobertblack commented 6 years ago

I was having this issue as well, palmiak edit with turning off the "Text link counter" solved the error, I could not add new posts because of this issue.

merkdev commented 6 years ago

I have same issue and don't know how to fix. Tried everything. Any other solution?

palmiak commented 6 years ago

could you show us your error log?

merkdev commented 6 years ago

Catchable fatal error: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post, null given in /home/xxx/public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php on line 41

Wordpress Version : 4.8.3 Yoast Plugin Version : 5.7.1

palmiak commented 6 years ago

And turning off Text link counter didn't help?

merkdev commented 6 years ago

Unfortunately, it didn't. I turned off ;

Readability analysis Keyword analysis Advanced settings pages Ryte Admin bar menu Cornerstone content Text link counter

But I won't work. I can't Create a new page/post/custom_post_type. Also interesting thing is, I can't create any post while yoast is disabled too. Maybe I have an another problem. I will try to reinstall Wordpress. (replacing wp-admin & wp-includes).

palmiak commented 6 years ago

also try disabling other plugins - just leave Yoast On 14.11.2017 14:11:36, Kamer DINC notifications@github.com napisał/a: Unfortunately, it didn't. I turned off ; Readability analysis Keyword analysis Advanced settings pages Ryte Admin bar menu Cornerstone content Text link counter But I won't work. I can't Create a new page/post/custom_post_type. Also interesting thing is, I can't create any post while yoast is disabled too. Maybe I have an another problem. I will try to reinstall Wordpress. (replacing wp-admin & wp-includes). — You are receiving this because you commented. Reply to this email directly, view it on GitHub [https://github.com/Yoast/wordpress-seo/issues/7531#issuecomment-344254351], or mute the thread [https://github.com/notifications/unsubscribe-auth/ACO-OvavpougoXPNXtEYE6B9-HpeC3SLks5s2ZGHgaJpZM4OiANE].

merkdev commented 6 years ago

Thanks for your replies @palmiak . Finally I found the problem. The problem was a plugin named "theme switcha"

This helps me switching between themes for development while website is online. Problem is gone when i disable it. Also I did some MySQL tricks maybe they could help too.

Thanks again.

ivcata commented 6 years ago

Hi everyone,

I am also facing the same error after upgrading the Yost SEO plugin to the latest version that is 6.3

I can't use "Add New" for pages and posts.

My data:

WordPress 4.9.4 Yoast SEO Version 6.3 Firegox is up to date - Version 58.0.2 (64-bit) Google Chrome is up to date - Version 64.0.3282.167 (Official Build) (64-bit)

Here is the error:


Fatal error: Uncaught TypeError: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post, null given, called in /home/ABC/public_html/wp-includes/class-wp-hook.php on line 288 and defined in /home/ABC/public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php:41 Stack trace: #0 /home/ABC/public_html/wp-includes/class-wp-hook.php(288): WPSEO_Link_Watcher->save_post(0, NULL) #1 /home/ABC/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array) #2 /home/ABC/public_html/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /home/ABC/public_html/wp-includes/post.php(3581): do_action('save_post', 0, NULL, false) #4 /home/ABC/public_html/wp-admin/includes/post.php(608): wp_insert_post(Array) #5 /home/ABC/public_html/wp-admin/post-new.php(70): get_default_post_to_edit('page', true) #6 {main} thrown in /home/ABC/public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php on line 41


fatal-error

My steps:

I updated Yoast SEO to Version 6.3

Wanted to make new page and I got Fatal Error.

Deactivate the plugin = didn't help.

Deactivate all plugins and go with Twenty Seventeen = didn't help.

Contact my hosting to do backup from 2 days before = didn't help.

Open support topic here: https://wordpress.org/support/topic/fatal-error-version-6-3/

Did everything form this guide: https://kb.yoast.com/kb/how-to-check-for-plugin-conflicts/

Turning off "Text link counter" and all other options = didn't help.

I didn't use CPT UI or the Theme Switcha plugins.

Used Health Check plugin.

In two tabs everything looks OK - no problems.

health-check-1

Debug Information:


`

WordPress

Version: 4.9.4 Language: en_US Permalink structure: /%category%/%postname% Is this site using HTTPS?: Yes Can anyone register on this site?: No Default comment status: open Is this a multisite?: No User Count: 1 Communication with WordPress.org: WordPress.org is reachable Create loopback requests: The loopback request to your site completed successfully.

Drop-ins

advanced-cache.php: Advanced caching plugin.

Active theme

Name: Dynamik-Gen Version: 2.2.1 Author: The Cobalt Apps Team Author website: cobaltapps.com Parent theme: Genesis Supported theme features: menus, post-thumbnails, automatic-feed-links, genesis-inpost-layouts, genesis-archive-layouts, genesis-admin-menu, genesis-import-export-menu, genesis-readme-menu, genesis-auto-updates, genesis-breadcrumbs, genesis-menus, genesis-structural-wraps, widgets, html5

Other themes (2)

Genesis (genesis): Version 2.5.3 by StudioPress Twenty Seventeen (twentyseventeen): Version 1.4 by the WordPress team

Must Use Plugins (1)

Health Check Disable Plugins: Version 1.1

Active Plugins (28)

a3 Lazy Load: Version 1.8.4 by a3rev Software Anti-spam: Version 4.4 by webvitaly Autoptimize: Version 2.3.2 by Frank Goossens (futtta) Contact Form 7: Version 5.0 by Takayuki Miyoshi Disable Google Fonts: Version 1.3 by Milan Dinic Display PHP Version: Version 1.4 by David Gwyer Genesis Simple Edits: Version 2.2.0 by StudioPress Genesis Simple Share: Version 1.1.1 by StudioPress Health Check: Version 0.9.0 by The WordPress.org community Lightweight Subscribe To Comments: Version 1.5.7 by Isabel Castillo myStickymenu: Version 2.0.3 by m.r.d.a Pretty Links: Version 2.1.4 by Blair Williams PRyC WP: Add custom content to post and page (top/bottom): Version 2.4.2 by PRyC Q2W3 Fixed Widget: Version 5.1.3 by Max Bond Remove Comment Website/URL Box: Version 1.0 by Mark Hodder RSS Includes Pages: Version 3.7 by Marios Alexandrou SEO Redirection: Version 4.10 by Fakhri Alsadi Social Locker | BizPanda: Version 5.0.7 by OnePress StopBadBots: Version 4.73 by Bill Minozzi Table of Contents Plus: Version 1601 by Michael Tran Use Google Libraries: Version 1.6.2.3 by Jason Penney Widget Options: Version 3.6 by Phpbits Creative Studio WP-Optimize: Version 2.1.1 by David Anderson, Ruhani Rabin, Team Updraft WP Statistics: Version 12.3.5 by Verona Labs WP Super Cache: Version 1.5.9 by Automattic Yet Another Stars Rating: Version 1.4.8 by Dario Curvino Yoast SEO: Version 6.3 by Team Yoast Yoast SEO: Version 6.3 by Team Yoast

Media handling

Active editor: WP_Image_Editor_GD Imagick Module Version: Imagick not available ImageMagick Version: Imagick not available GD Version: bundled (2.1.0 compatible) Ghostscript Version: 8.70

Server

Server architecture: Linux 2.6.32-896.16.1.lve1.4.51.el6.x86_64 x86_64 PHP Version: 7.2.0 (Supports 64bit values) PHP SAPI: cgi-fcgi PHP max input variables: 5000 PHP time limit: 30 PHP memory limit: 256M Max input time: 60 Upload max filesize: 20M PHP post max size: 20M cURL Version: 7.38.0 OpenSSL/1.0.1e SUHOSIN installed: No Is the Imagick library available: No

Database

Extension: mysqli Server version: 5.5.58-cll Client version: mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $ Database prefix: wp_

WordPress constants

ABSPATH: /home/ABC/public_html/ WP_HOME: Undefined WP_SITEURL: Undefined WP_DEBUG: Disabled WP_MAX_MEMORY_LIMIT: 256M WP_DEBUG_DISPLAY: Enabled WP_DEBUG_LOG: Disabled SCRIPT_DEBUG: Disabled WP_CACHE: Enabled CONCATENATE_SCRIPTS: Undefined COMPRESS_SCRIPTS: Undefined COMPRESS_CSS: Undefined WP_LOCAL_DEV: Undefined

Filesystem permissions

The main WordPress directory: Writable The wp-content directory: Writable The uploads directory: Writable The plugins directory: Writable The themes directory: Writable The Must Use Plugins directory: Writable

`


Strange in Troubleshooting Mode now I have two Yoast SEO plugins???

twice-yoast seo in troubleshooting on health check plugin - 1

But I still can't use "Add New" for pages and posts because it looks so strange.

add-new-post

Disable Troubleshooting Mode in Health Check plugin.

Now in plugins I really have two Yoast SEO plugins - WOW.

twice - yoast seo in troubleshooting on health check plugin - 2 activated

Now I think to buy pro version but maybe the support first need to fix this problem?

I don't know. Can pro version help me or I need to wait?

Any help here please?

What other data do you need support?

Thank You,

Ivo Igantov

benvaassen commented 6 years ago

@ivcata Can you try deleting the plugin (both of them via FTP because I think there are two instances installed) and reinstalling? Your settings and optimizations won't be lost when you delete the plugin.

ivcata commented 6 years ago

Hi,

Fatal error was there before the appearance of both Yoast SEO plugins.

I migrated with SEO Data Transporter Plugin - (to backup my SEO data).

I deactivated two Yoast SEO plugins.

When I deactivate the Yoast SEO plugin it automatically exit from my wp admin to login window.

I deleted two wordpress-seo folders.

The problem remains - see the pic:

image

I installed fresh new Yoast SEO.

Same Fatal error again.

Any other suggestions?

Thanks

vovkasolovev commented 6 years ago

I run into this issue with same errors symptoms about Yoast 6.3.1 either.

Found out for some occasion _WPPOSTS table lost _AUTOINCREMENT and get PRIMARY KEY on ID column after my last worpdress (4.9.4) and plugins update. And _WPPOSTS have some draft records with same ID=0.

I just roll back my BD to backuped BD (Cos fixing ID=0 records was a pain). So check that table key, maybe it's not a Yoast plugin problem.

ivcata commented 6 years ago

Hi Vovka,

Thanks for your proposal.

I have got a lot of pain for last 11 days because of this bug.

Waiting for so many days without a fix. It is terrible experience.

I am a blogger, not a programmer.

That's why I don't understand very well your solution.

Can you (or someone else) explain it much simple?

Where to look? What to do? How to do it?

Thanks for your participation.

vovkasolovev commented 6 years ago

@ivcata, Try take a look on your sites database table. I am 90% sure you can find PhpMyAdmin in your hosting control for this. In PhpMyAdmin select site database and WP_POSTS table under it, go to Structure tab, and look at ID row. Is there AUTO_INCREMENT in Extra column? If no, then you have similar to my problem — to solve it backup bad database, and roll back to previous one without this error (can't help step-by-step here, it's too complex to text).

wp_posts

Hope I do not break off topic here.

ivcata commented 6 years ago

Thanks a lot @vovkasolovev,

I believe you are right in the topic.

I will ask my hosting company to help me with this solution.

They are very good and I hope finally to FIX this problem.

ivcata commented 6 years ago

My hosting company did the job and it works. The bug is gone. Finally I can blog again. Thank You @vovkasolovev

ivcata commented 6 years ago

In the beginning everything was OK, but now strange things happens after my new post and pages.

Approximately after 2 hours after creation of every new page:

1.) SEO description disapear. 2.) Featured image disapear. 3.) Page Attributes - the selected from me Template is Landing and changes to Default. 4.) Some pictures in Media looks like gray rectangles (can't see what they are).

No matter how many times I will add SEO description, Featured image, and Template, they disappear again later.

Any suggestions how to fix these?

benvaassen commented 6 years ago

@ivcata this is most likely not caused by our plugin as you stated the problem remains after deleting both wordpress-seo folders.

There seems to be something wrong with either your database and/or your WordPress installation. Unfortunately, it doesn't look like a bug that we would be able to fix and is out of our hands. You could try reinstalling WordPress, but I'm not sure if that would fix your issues. Keep in mind, we don't recommend making any changes without a backup.

ivcata commented 6 years ago

@benvaassen Thank you.

gidomanders commented 6 years ago

I faced the same issue and setting ID on the posts table to become primary with auto-increment fixed it :) I think this issue can be closed.

ivcata commented 6 years ago

Hi @gidomanders,

Thanks for your suggestion.

My hosting support checked wp_posts and the settings are the same but I still have these bugs.

I still hoping for help here because reinstalling WordPress is a drastic step.

I did a lot of test and now I can tell what trigger these bugs.

Maybe someone can help.

The bugs appear in two scenarios:

1.) When I restore deleted post or page. It is strange but restored URL has changed.

Example: https://www.ivoignatov.com/test-1 https://www.ivoignatov.com/test-1__trashed = (restored URL)

2.) When I empty trash.

5 Bugs Are (they appear ONLY in new pages or posts):

1.) SEO description disappear. 2.) Featured image disappear. 3.) Page Attributes - the selected Template changes automatically to Default. 4.) New pictures attached to new pages or posts looks like gray icons in Media. 5.) Everytime when I deactivate Yoast SEO plugin my admin automatically log out to login WP window.

These bugs appear ONLY in new pages or posts after I restore deleted post/page or empty trash.

The old pages and posts are not affected by these bugs.

  1. The good thing is I can publish new articles on my website after @vovkasolovev suggestion.
  2. The bad thing is my site have these 5 bugs.

Any other suggestions how to fix them?

Ivo Ignatov

sbbic commented 6 years ago

I have the same problem - no issue with my database - it's correct.

TomasHurtz commented 6 years ago

I have similar issue mentioned here: https://github.com/Yoast/wordpress-seo/issues/9403

Any solution ?

nqzhang commented 6 years ago

I faced the same issue

nocean commented 6 years ago

@vovkasolovev's solution worked for me!

andreistanescu87 commented 6 years ago

Hi guys, Problem seems to be beceause of the fcgi. I've get the same issue when i've migrated one client worpdress site from apache2+libapache-mod-php to nginx+fpm. I try find the root cause and i'll came back with updates, if i get some.

chippy-kennedy commented 6 years ago

Is anyone curious on the specific MySQL fix? I pieced together a few StackOverflow topics and found a step-by-step fix that works with PHPMyAdmin.

  1. Given you are seeing @vovkasolovev 's 'WP_POSTS table with Error', backup your database Export tab in PHPMyAdmin's database view

  2. Select SQL tab in PHPMyAdmin's database view

  3. Enter the following two lines into the Run SQL query/queries on table input box:

ALTER TABLE `wp_posts` ADD INDEX(`ID`); ALTER TABLE `wp_posts` CHANGE `ID` `ID` INT(20) UNSIGNED NOT NULL AUTO_INCREMENT;

  1. Run SQL commands by pressing Go. Confirm with PHPMyAdmin notifications.
siteadvice commented 6 years ago

@chippy-kennedy That solution worked for me. Thanks.

kalne commented 5 years ago

Is anyone curious on the specific MySQL fix? I pieced together a few StackOverflow topics and found a step-by-step fix that works with PHPMyAdmin.

  1. Given you are seeing @vovkasolovev 's 'WP_POSTS table with Error', backup your database Export tab in PHPMyAdmin's database view
  2. Select SQL tab in PHPMyAdmin's database view
  3. Enter the following two lines into the Run SQL query/queries on table input box:

ALTER TABLE `wp_posts` ADD INDEX(`ID`); ALTER TABLE `wp_posts` CHANGE `ID` `ID` INT(20) UNSIGNED NOT NULL AUTO_INCREMENT;

  1. Run SQL commands by pressing Go. Confirm with PHPMyAdmin notifications.

work for me to, thanks

pyodor commented 5 years ago

This, https://github.com/Yoast/wordpress-seo/issues/7531#issuecomment-326758563 works for me, but is the plugin going to be updated with this fix? Or any update on this issue?

VeteranSoldier commented 5 years ago

My ''AUTO_INCREMENT'' Error Solution (Wordpress):

(**) database undamaged: open your database (from your backups) with Notepad++. Search AUTO_INCREMENT. if you find 40-60 AUTO_INCREMENT, it's undamaged.

Dzire2Dzine commented 5 years ago

Error Details

An error of type E_ERROR was caused in line 45 of the file /home//public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php. Error message: Uncaught TypeError: Argument 2 passed to WPSEO_Link_Watcher::save_post() must be an instance of WP_Post, null given, called in /home//public_html/wp-includes/class-wp-hook.php on line 288 and defined in /home/*****/public_html/wp-content/plugins/wordpress-seo/admin/links/class-link-watcher.php:45 Stack trace:

0 /home/*****/public_html/wp-includes/class-wp-hook.php(288): WPSEO_Link_Watcher->save_post(0, NULL)

1 /home/*****/public_html/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters(NULL, Array)

2 /home/*****/public_html/wp-includes/plugin.php(465): WP_Hook->do_action(Array)

3 /home/*****/public_html/wp-includes/post.php(3951): do_action('save_post', 0, NULL, false)

4 /home/*****/public_html/wp-admin/includes/post.php(666): wp_insert_post(Array)

5 /home/*****/public_html/wp-admin/post-new.php(66): get_default_post_to_edit('post', true)

6 {main}

thrown

anhtruc92cr commented 5 years ago

Is anyone curious on the specific MySQL fix? I pieced together a few StackOverflow topics and found a step-by-step fix that works with PHPMyAdmin.

  1. Given you are seeing @vovkasolovev 's 'WP_POSTS table with Error', backup your database Export tab in PHPMyAdmin's database view
  2. Select SQL tab in PHPMyAdmin's database view
  3. Enter the following two lines into the Run SQL query/queries on table input box:

ALTER TABLE `wp_posts` ADD INDEX(`ID`); ALTER TABLE `wp_posts` CHANGE `ID` `ID` INT(20) UNSIGNED NOT NULL AUTO_INCREMENT;

  1. Run SQL commands by pressing Go. Confirm with PHPMyAdmin notifications.

I have the same issue. This comment help me but it happens again after few hours. Does anyone know the root cause?

jclopezec commented 4 years ago

@vovkasolovev Thanks you are a genius. This worked for me!