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

M18.12 - Fix tribe_get_linked_posts_by_post_type() ordering #2138

Merged
merged 12 commits into from
Aug 15, 2018

Conversation

cliffordp
Copy link
Contributor

https://central.tri.be/issues/105116

Start by reverting the reverts from #2105
Then will fix from there.

@cliffordp cliffordp self-assigned this Aug 7, 2018
it's a few lines above already
@cliffordp cliffordp added the hold Status: on hold–do not proceed with other status items. label Aug 7, 2018
- Added `$return_all_if_none` parameter to `get_linked_post_info()`
- So that `$my_linked_posts` from `saved_linked_post_dropdown()` can use that method (getting all if none) and the `tribe_get_linked_posts_by_post_type()` function returns none if none are linked, as expected.
- Open to alternative solutions...
@cliffordp cliffordp added code review Status: requires a code review. and removed hold Status: on hold–do not proceed with other status items. labels Aug 7, 2018
@jesseeproductions
Copy link
Contributor

Cliff could you continue these changes in branch and then we can merge after it gets a QA pass?

@cliffordp cliffordp requested a review from borkweb August 9, 2018 02:43
@cliffordp
Copy link
Contributor Author

@jesseeproductions Continue what changes? It's ready for code review as-is. Alexis said @borkweb would do it on Monday when he's back.

If you're referring to the TODOs, I added those for deprecated things.

@jesseeproductions
Copy link
Contributor

The double revert made it seem like you were reverting not adding back coding, my bad.

Copy link
Member

@borkweb borkweb left a comment

Choose a reason for hiding this comment

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

@cliffordp - this is really great. Nice work on this one! There's just one ultra-minor tweak that I'd like to see happen and once that's done I'd say this is ready for QA-ing in the branch! (we'll merge after QA has completed)

💯


$linked_ids_order_key = $this->get_order_meta_key( $post_type );

if ( $linked_ids_order_key ) {
Copy link
Member

Choose a reason for hiding this comment

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

Let's invert this to avoid nesting desired logic:

if ( ! $linked_ids_order_key ) {
  return;
}

update_post_meta( $target_post_id, $linked_ids_order_key, $current_order );

*
* @return array
*/
public function get_linked_post_info( $linked_post_type, $args = array(), $linked_post_ids = null ) {
public function get_linked_post_info( $linked_post_type, $args = array(), $linked_post_ids = null, $return_all_if_none = false ) {
Copy link
Member

@borkweb borkweb Aug 14, 2018

Choose a reason for hiding this comment

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

If we want to avoid using an extra parameter here, you could feasibly just add a filter instead:

/**
 * blah blah
 */
$return_all_if_none = apply_filters( 'tribe_events_return_all_linked_posts_if_none', false, $linked_post_type, $args, $linked_post_ids );

Then when you call this method for that one case where you want that to be true, just do:

add_filter( 'tribe_events_return_all_linked_posts_if_none', '__return_true' );
// do the call
remove_filter( 'tribe_events_return_all_linked_posts_if_none', '__return_true' );

- remove the parameter added to `get_linked_post_info()`
- implement as a filter instead
- fix typo in docblock for the existing `$linked_post_ids` param
- tweak readme to mention new filter and clarify other things
@tr1b0t
Copy link
Contributor

tr1b0t commented Aug 14, 2018

Status Message Line
⚠️ Comment refers to a TODO task Linked_Posts.php:179
⚠️ Comment refers to a TODO task Linked_Posts.php:685
⚠️ Comment refers to a TODO task organizer.php:71

via jenkins/codesniffer-phpcs

@cliffordp
Copy link
Contributor Author

@borkweb please re-review

Copy link
Member

@borkweb borkweb left a comment

Choose a reason for hiding this comment

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

Nice work, @cliffordp! 🥇

@borkweb borkweb added merge Status: ready to merge. in-qa Status: requires QA before merging. and removed code review Status: requires a code review. merge Status: ready to merge. labels Aug 15, 2018
@borkweb
Copy link
Member

borkweb commented Aug 15, 2018

Let's QA this in the branch before merging

@cliffordp
Copy link
Contributor Author

QA passed so merging now :)

@cliffordp cliffordp merged commit c2efbfb into release/M18.12 Aug 15, 2018
@cliffordp cliffordp deleted the fix/105116-for-18-12 branch August 15, 2018 16:36
@cliffordp cliffordp added merge Status: ready to merge. and removed in-qa Status: requires QA before merging. labels Aug 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge Status: ready to merge.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants