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

Ensure we don't run updates more than once #677

Merged
merged 2 commits into from
Feb 1, 2024
Merged

Ensure we don't run updates more than once #677

merged 2 commits into from
Feb 1, 2024

Conversation

dkotter
Copy link
Collaborator

@dkotter dkotter commented Jan 31, 2024

Description of the Change

As mentioned in #623, there's a scenario where manually triggering some of the Azure Image Processing Features from the attachment edit screen can result in an infinite loop.

As part of the refactoring done in #611, this was fixed so that we wouldn't ever encounter an infinite loop but we still end up running those update functions twice, which is not ideal.

This PR fixes that by ensuring we remove the hooked action before we update the attachment.

Closes #623

How to test the Change

  1. Set up the Descriptive Text Generator Feature
  2. Set it up to save the result to either Image caption or Image description (Alt text never had an issue)
  3. On an image that has already been uploaded, go to the attachment edit screen
  4. Check the box in the ClassifAI Image Processing metabox and save the attachment
  5. Ensure the descriptive text is saved

Changelog Entry

Fixed - Ensure we only run image updates once.

Credits

Props @dkotter, @Sidsector9, @sksaju

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@dkotter dkotter added this to the 3.0.0 milestone Jan 31, 2024
@dkotter dkotter self-assigned this Jan 31, 2024
@dkotter dkotter requested review from jeffpaul and a team as code owners January 31, 2024 20:33
@dkotter dkotter requested review from 10upbot, a team, iamdharmesh and Sidsector9 and removed request for a team, jeffpaul, 10upbot and iamdharmesh January 31, 2024 20:38
Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good but I'm seeing fatal errors for the following:

Regenerate smart thumbnail

Screenshot 2024-02-01 at 1 13 07 PM

Rescan for text

Screenshot 2024-02-01 at 1 12 47 PM

@dkotter
Copy link
Collaborator Author

dkotter commented Feb 1, 2024

The code looks good but I'm seeing fatal errors for the following:

Hmm.. do you have any specific steps you're taking here? I'm not able to reproduce the problem but in looking at the error message, it seems the image metadata is returning as a string instead of an array (which we use wp_get_attachment_metadata to get that and supposedly it always returns either an array or false).

I've added an additional check to ensure we don't proceed if the metadata isn't an array but would still be interested to know how you're able to reproduce this.

Copy link
Member

@Sidsector9 Sidsector9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this issue. Tests well 👍

@dkotter dkotter merged commit 517af08 into develop Feb 1, 2024
12 checks passed
@dkotter dkotter deleted the fix/623 branch February 1, 2024 19:39
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

Successfully merging this pull request may close these issues.

Infinite loop when re-scanning image
2 participants