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

Fix some primary category issues #363

Merged
merged 5 commits into from
Nov 10, 2022
Merged

Fix some primary category issues #363

merged 5 commits into from
Nov 10, 2022

Conversation

dkotter
Copy link
Contributor

@dkotter dkotter commented Nov 10, 2022

Description of the Change

This is a follow up to #350.

If Yoast is not being used, everything works as expected. But if Yoast is installed, if no category is selected, we return the value null, which breaks our sync. This PR adjust our get_primary_category function to add some better checks, ensuring if we don't have a primary category set we fallback to grabbing the first category set. Or if we have a primary category set but that category no longer exists, we now check for that and return false instead.

If we return false in this function, we've also adjusted the output to the tracker to ensure we are sending an empty array instead of an array with an empty string in it.

Alternate Designs

None

Possible Drawbacks

None

Verification Process

Verify that setting categories sends the correct data to Sophi both with Yoast installed and with it not. Try setting one category, multiple categories and no categories.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.

@dkotter dkotter self-assigned this Nov 10, 2022
@jeffpaul jeffpaul added this to the 1.3.1 milestone Nov 10, 2022
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dkotter
Copy link
Contributor Author

dkotter commented Nov 10, 2022

@jeffpaul @Sidsector9 This PR should fix the issues where we can end up with either [null] or [''] being sent to the tracker.

One thing I noticed that may have already been discussed: since we are relying on Yoast here to set the primary category, and Yoast does this using post meta and the block editor saves post meta in a separate request from saving the post itself, we end up with two requests being sent to the tracker. The first may or may not have the proper category set, since the post meta will not have been saved at that time.

Not sure how these duplicate tracking events impact things, if at all, but figured I'd mention it

@jeffpaul
Copy link
Contributor

As long as the last sync for the update includes the correct category(ies), then the content sync to Sophi will result in the "right" data being available for Sophi to process; so I think we're ok on this.

@jeffpaul jeffpaul merged commit 5fd1dec into develop Nov 10, 2022
@jeffpaul jeffpaul deleted the fix/primary-category branch November 10, 2022 18:47
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.

2 participants