SIT-3022: fix/ Rogers-crossposting: update utils.php with client code for cross posting #218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
Please inspect this updated code as received by client and advise us if there will be any breaking changes introduced.
Notes from client:
It's an issue if the function is called multiple times, the functions in those lines are in a function, which declares those functions every time the function is called.
Removing those functions from the containers functions fixes the problem.
This is a problem if you do multiple post inserts in the same script, which is the case on News because we crossposts some posts through our different sites.
The issue as actually happening because we do multiple wp_insert_posts in the same PHP script. Maybe I misspoke the right term, but basically, since we have a loop that create multiple posts, in one go, and that this function called get_post_categories has function declarations in it, there is a Fatal error in PHP since you can't declare two functions with the same name.
We crosspost stories from one site to multiple sites when the story is relevant for the other sites, most likely when the story is national.
The crossposting functionality duplicate the post on another site, and links them, so when the "parent" article gets an update, the "children" articles get the same updates
Personally, I would suggest not having named functions or not have function declarations in a function.