wordpress-seo icon indicating copy to clipboard operation
wordpress-seo copied to clipboard

PHP Notice wordpress-seo/src/integrations/third-party/elementor.php on line 154

Open vollyimnetz opened this issue 2 years ago • 6 comments

  • [x] I've read and understood the contribution guidelines.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Please give us a description of what happened.

PHP Notice: Trying to get property ‘post_type’ of non-object in {{path}}/wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 154

This notice appear in the logs at least for the last 9 month, every time an elementor page is saved (from the elementor page editor page). Can you please provide a fix, it polluted our logs.

Please describe what you expected to happen and why.

No notice in the logs once an elementor page is saved.

How can we reproduce this behavior?

  • install elementor and yoast
  • create an page with elementor and some content
  • save the page
  • have a look in the logs

Technical info

I had a quick look at the line that is mentioned in the error log. The line uses your function “get_metabox_post” which might return null. So a check for null is necessary to make the code work. You may change the line 154 in seo/src/integrations/third-party/elementor.php from: if ( ! $this->display_metabox( $this->get_metabox_post()->post_type ) ) { to if ( empty( $this->get_metabox_post() ) || ! $this->display_metabox( $this->get_metabox_post()->post_type ) ) {

But i do not know why the function returns null in the first place.

Used versions

WordPress: 5.8.2 Elementor: 3.4.8 Yoast SEO: 17.6

  • Tested with theme: hello-elementor

corresponding support ticket: https://wordpress.org/support/topic/php-notice-wordpress-seo-src-integrations-third-party-elementor-php-on-line-154-2 https://wordpress.org/support/topic/php-notice-wordpress-seo-src-integrations-third-party-elementor-php-on-line-154

vollyimnetz avatar Dec 13 '21 08:12 vollyimnetz

Hi @vollyimnetz, thanks for the report. This is a known issue (internal bug report). Since this isn't reported on GH yet, I will leave this open as a public facing issue.

Djennez avatar Dec 13 '21 09:12 Djennez

Same here: Trying to get property 'post_type' of non-object in .../wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 153

WP 5.9.1 Elementor 3.5.6, Pro 3.6.2 Yoast 18.2

Note: this issue was reported a year ago.

Mulli avatar Mar 03 '22 21:03 Mulli

Same issue here: PHP Notice: Trying to get property 'post_type' of non-object in wordpress-seo/src/integrations/third-party/elementor.php on line 153

WP 5.9.2 Elementor 3.6.1, Pro 3.6.4 Yoast SEO 18.4.1

pimschaaf avatar Mar 24 '22 10:03 pimschaaf

Running WordPress 5.9.3, WooCommerce 6.5.1, Yoast SEO 18.9 When I edit and save a block using Elementor, Yoast SEO generates an error message in debug.log:

PHP Notice: Trying to get property 'post_type' of non-object in \wp-content\plugins\wordpress-seo\src\integrations\third-party\elementor.php on line 153.

This is because the function “get_metabox_post” might return null.

You need to check it returns an object by adding this after line [152]:

    if(!is_object($this->get_metabox_post())) {
        return;
    }

garak734 avatar May 18 '22 15:05 garak734

When we can expect an official bug fix?

As-Tomas avatar May 26 '22 14:05 As-Tomas

Is there an ETA for a fix?

Elementor 3.6.6, Pro 3.7.2 Yoast 19.2 I don't get this error on every page. Specifically where I have an elementor form on my contact page before I open the elementor editor.... Notice: Trying to get property 'display_name' of non-object in /home/weqtvfuphcuq/public_html/wp-content/plugins/wordpress-seo/src/presenters/meta-author-presenter.php on line 40

When I open the elementor editor I get this error listed three times above the pages main container... Notice: Trying to get property 'display_name' of non-object in /home/weqtvfuphcuq/public_html/wp-content/plugins/wordpress-seo/src/presenters/meta-author-presenter.php on line 40

markman77 avatar Jul 05 '22 17:07 markman77

Same problem here.

PHP Warning: Attempt to read property "post_type" on null in /kunden/customer_id/webseiten/hello-world.net/wordpress/wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 154

Nick776 avatar Oct 22 '22 13:10 Nick776

anyone else using PHP 8.0?

Nick776 avatar Oct 24 '22 05:10 Nick776

I'm having this issue and I think it even crashes my Apache2 when trying to save changes to a page.

Fri Feb 03 02:38:09.530276 2023] [php:warn] [pid 1579194] PHP Warning: Attempt to read property "post_type" on null in /var/www/wordpress/wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 163

[Fri Feb 03 02:39:00.004524 2023] [mpm_prefork:notice] [pid 1579182] AH00170: caught SIGWINCH, shutting down gracefully

Restarting Apache2 gets me the site back, but the issue keeps returning (error when saving and apache2 crashes occasionally).

Yoast SEO Version 20.0 Elementor Version 3.10.2 Elementor Pro Version 3.10.3

Mopster avatar Feb 03 '23 03:02 Mopster

Same: [05-Feb-2023 15:47:21 UTC] PHP Warning: Attempt to read property "post_type" on null in /home/SITE/public_html/wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 163

This error has been thrown for weeks, after multiple Yoast and Elementor and Elementor Pro plugin updates.

Latest versions of Yoast and Elementor and Elementor Pro.

iamkevinjohnson avatar Feb 05 '23 15:02 iamkevinjohnson

Annoying as this has been filling up my logs for quite some time now. Running PHP 8.0.

2023/02/22 15:27:29 [error] 46196#46196: *2814832 FastCGI sent in stderr: "PHP message: PHP Warning: Attempt to read property "post_type" on null in /www/hidden/wp-includes/link-template.php on line 4066PHP message: PHP Warning: Attempt to read property "post_type" on null in /www/hidden/wp-includes/link-template.php on line 4068PHP message: PHP Warning: Attempt to read property "post_content" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/memoizers/meta-tags-context-memoizer.php on line 140PHP message: PHP Warning: Attempt to read property "post_author" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presentations/indexable-post-type-presentation.php on line 237PHP message: PHP Warning: Attempt to read property "post_date_gmt" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presentations/indexable-post-type-presentation.php on line 280PHP message: PHP Warning: Attempt to read property "post_modified_gmt" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presentations/indexable-post-type-presentation.php on line 289PHP message: PHP Warning: Attempt to read property "post_date_gmt" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presentations/indexable-post-type-presentation.php on line 289PHP message: PHP Warning: Attempt to read property "post_author" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presenters/meta-author-presenter.php on line 45PHP message: PHP Warning: Attempt to read property "post_author" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presentations/indexable-post-type-presentation.php on line 386PHP message: PHP Warning: Attempt to read property "post_author" on null in /www/hidden/wp-content/plugins/wordpress-seo/src/presenters/slack/enhanced-data-presenter.php on line 46PHP message: PHP Warning: Attempt to read property "post_author" on null in /www/ncabgroup

nelgmo avatar Feb 22 '23 15:02 nelgmo

This error appears when trying to upload a video /wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 153

idenrg avatar May 03 '23 15:05 idenrg

Still present: AH01071: Got error 'PHP message: PHP Warning: Attempt to read property "post_type" on null in {{path}}/public_html/wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 151' WordPress 6.2.2 Yoast Seo: 20.8 Elementor: 3.13.4 Elementor Pro: 3.13.2 Imho it causes a delay in saving the changes made in Elementor as well...

brobken avatar Jun 12 '23 15:06 brobken

Affected by this as well. Adding the full log entry, perhaps it helps.

2023/06/23 09:52:25 [error] 107476#107476: *1874908 FastCGI sent in stderr: "PHP message: PHP Warning: Attempt to read property "post_type" on null in /wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 151" while reading response header from upstream, client: 95.97.251.170, server: clientwebsite.com, request: "POST /wp-admin/admin-ajax.php HTTP/2.0", upstream: "fastcgi://unix:/var/run/php8.0-fpm-clientwebsite.sock:", host: "subdomain.clientwebsite.com:61600", referrer: "https://subdomain.clientwebsite.com/wp-admin/post.php?post=3727&action=elementor"

jghaanstra avatar Jun 23 '23 14:06 jghaanstra

same PHP Notice: [26-Jun-2023 17:07:32 UTC] PHP Notice: Trying to get property 'post_type' of non-object in .../wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 151 WordPress 6.2.2 Yoast Seo: 20.9 Elementor: 3.14.1

2pixels avatar Jun 26 '23 17:06 2pixels

same issue her. we cant update elementor posts anymore:

AH01071: Got error 'PHP message: PHP Warning: Attempt to read property "post_type" on null in .../wp-content/plugins/wordpress-seo/src/integrations/third-party/elementor.php on line 151PHP message: PHP Stack trace:PHP message: PHP 1. {main}() .../wp-admin/admin-ajax.php:0PHP message: PHP 2. require_once() .../wp-admin/admin-ajax.php:22PHP message: PHP 3. require_once() .../httpdocs/wp-load.php:50PHP message: PHP 4. require_once() .../httpdocs/wp-config.php:86PHP message: PHP 5. do_action($hook_name = 'init') .../httpdocs/wp-settings.php:623PHP message: PHP 6. WP_Hook->do_action($args = [0 => '']) .../httpdocs/wp-includes/plugin.php:517PHP message: PHP 7. WP_Hook->apply_filters($value = '', $args = [0 => '']) .../httpdocs/wp-includes/class-wp-hook.php:332PHP message: PHP 8. Yoast\\WP\\SEO\\Integrations\\Third_Party\\Elementor->register_elementor_hooks('') .../httpdocs/wp-includes/class-wp-hook.php:308', referer: .../wp-admin/post.php?post=3644&action=elementor

bwalger avatar Jun 28 '23 07:06 bwalger

Same issue. I am quite stumped that more than a year passed and they aren't fixing it. For what is worth it is the only error message in my server logs.

WordPress 6.2.2 Yoast Seo: 20.9 Elementor: 3.14.1 PHP 8.0 (it is the same with 8.1 and 8.2)

sequoi avatar Jul 06 '23 07:07 sequoi

same issue here in latest Free Version 20.11

everytime yoast SEO updated, I edit elementor.php file line 151, from this:

public function register_elementor_hooks() {
		if ( ! $this->display_metabox( $this->get_metabox_post()->post_type ) )

to this:

public function register_elementor_hooks() {
	    if(!isset($this->get_metabox_post()->post_type)) return;
	    if ( ! $this->display_metabox( $this->get_metabox_post()->post_type ) )

neoandien avatar Jul 16 '23 14:07 neoandien

Also getting the, " Attempt to read property "post_type" on null " error on latest seo versions

haydenrust avatar Jul 25 '23 16:07 haydenrust

Not worth the hassle for me anymore. At this point, I can not wait for them to get their sense together.

I switched to Rank Math SEO and could not be happier. Rank Math has also been imported from the Yoast feature, so everything is fine. Plus it's better to the point that I was keeping my hand in sand for a long time. You will need some time to adapt but it is much more worth it than Yoast. Of course, your mileage may vary.

sequoi avatar Jul 26 '23 05:07 sequoi

This was fixed together with https://github.com/Yoast/wordpress-seo/issues/20162 by https://github.com/Yoast/wordpress-seo/pull/20465, released in Yoast SEO 20.12

enricobattocchi avatar Sep 20 '23 12:09 enricobattocchi