Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Notices when editing posts that have an ACF Image field #292

Open
2 tasks done
Pixelrobin opened this issue Jul 27, 2021 · 1 comment
Open
2 tasks done

PHP Notices when editing posts that have an ACF Image field #292

Pixelrobin opened this issue Jul 27, 2021 · 1 comment

Comments

@Pixelrobin
Copy link

Pixelrobin commented Jul 27, 2021

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

Please give us a description of what happened.

When editing a post that has an Image ACF field, the following PHP notices are thrown in the debug log:

[27-Jul-2021 18:42:16 UTC] PHP Notice:  Undefined index: posts_per_page in .../wp-admin/includes/ajax-actions.php on line 3006
[27-Jul-2021 18:42:16 UTC] PHP Warning:  Division by zero in .../wp-admin/includes/ajax-actions.php on line 3006

Please describe what you expected to happen and why.

No PHP notices to be thrown.

How can we reproduce this behavior?

  1. I set up logging in my wp-config.php with:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
  1. Create an ACF field group that contains an Image field and set it to show on a post type (any post type)
  2. Create or edit a post that should have that ACF field
  3. PHP notices are logged to the debug.log

Technical info

  • WordPress version: 5.8
  • ACF Content Analysis for Yoast SEO version: 3.0.1
  • Yoast SEO version: 16.8
  • ACF type: pro
  • ACF version: 5.9.9
  • Relevant plugins in case of a bug:
@jpumfrey
Copy link

jpumfrey commented Sep 14, 2021

Came across this issue recently flooding my debug log when editing posts across our sites using this plugin. As a temporary solution, I have updated the yoast-acf-analysis.js refresh function to include the missing query parameter:

var refresh = function( attachment_ids ) {
	var uncached = cache.getUncached( attachment_ids, "attachment" );

	if ( uncached.length === 0 ) {
		return;
	}

	window.wp.ajax.post( "query-attachments", {
		query: {
			post__in: uncached,
			posts_per_page: 1
		},
	} ).done( function( attachments ) {
		_.each( attachments, function( attachment ) {
			cache.set( attachment.id, attachment, "attachment" );
			window.YoastACFAnalysis.maybeRefresh();
		} );
	} );
};

i.e. posts_per_page: 1 in the post query around line ~122.

wp-content\plugins\acf-content-analysis-for-yoast-seo\js\yoast-acf-analysis.js

Hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants