• Resolved Scott Trsar

    (@scotttrsar)


    Documentation for this class is out-of-date and shows working version prior to v6.2.9 changes… Reporting this bug here since this file is contained within the public calendar plugin and not in a premium add-on plugin.

    Issue
    Additional term arguments?$params[args]?for select2 taxonomy dropdowns breaks at?v6.2.9?to current version. was working prior and the last working version was?v6.2.8.2.
    (e.g. passing exclude, parent etc. as additional arguments is no longer parsed and ignored in ajax response)

    • Example: ajax post will?NOT?exclude term_id 69, but should:
      action=tribe_dropdown&source=search_terms&search%5B_type%5D=query&search%5Bterm%5D=&args%5Btaxonomy%5D=tribe_events_cat&args%5Borderby%5D=name&args%5Bexclude%5D%5B%5D=69
    • Example: ajax post will?NOT?only show children of term_id 69, but should:
      action=tribe_dropdown&source=search_terms&search%5B_type%5D=query&search%5Bterm%5D=&args%5Btaxonomy%5D=tribe_events_cat&args%5Borderby%5D=name&args%5Bparent%5D%5B%5D=69

    Where
    Issue found in class?Tribe__Ajax__Dropdown?in file:?the-events-calendar/common/src/Tribe/Ajax/Dropdown.php
    A change to function parse_params($params) as of?v6.2.9?is breaking the ability to pass any additional arguments to?get_terms().

    Specifically, the issue is on?line 251?as the default value ignores any additional params passed with the ajax post. Instead there’s 2 conditionals for the args array only checking for taxonomy and post_type preventing any additional term args to be parsed…

    Quick fix
    line 251:?'args'? => [ 'post_status' => 'publish' ], a quick fix would be to change this line to:?'args'? => $params['args'] ?? [ 'post_status' => 'publish' ],

    - 'args'? => [ 'post_status' => 'publish' ],
    + 'args'? => $params['args'] ?? [ 'post_status' => 'publish' ],

    v6.3.6 parse_params()
    Recommendation: Adjust whitelist to include all allowed term arguments accepted by get_terms()

    /**
     * Parses the Params coming from Select2 Search box.
     *
     * @since 4.6
     * @since 5.1.17 Added an allow list of params to restrict the shape of the database queries.
     *
     * @param array<string|mixed> $params Params to overwrite the defaults.
     *
     * @return object
     */
    public function parse_params( $params ) {
     $allowed_params = [
      'search' => $params['search'] ?? null,
      'page'  => $params['page'] ?? 0,
      'source' => $params['source'] ?? null,
      'args'  => [ 'post_status' => 'publish' ],
     ];
    
     if ( isset( $params['args']['taxonomy'] ) ) {
      $allowed_params['args']['taxonomy'] = $params['args']['taxonomy'];
     }
     if ( isset( $params['args']['post_type'] ) ) {
      $allowed_params['args']['post_type'] = $params['args']['post_type'];
     }
    
     // Return Object just for the sake of making it simpler to read.
     return (object) $allowed_params;
    }

    v6.2.8.2 parse_params()
    Passing additional term arguments for additional get_terms() filter is working properly.

    /**
     * Parses the Params coming from Select2 Search box
     *
     * @since 4.6
     *
     * @param array<string|mixed> $params Params to overwrite the defaults
     *
     * @return object
     */
    public function parse_params( $params ) {
     $defaults = [
      'search' => null,
      'page'  => 0,
      'args'  => [],
      'source' => null,
     ];
    
     $arguments = wp_parse_args( $params, $defaults );
    
     // Return Object just for the sake of making it simpler to read
     return (object) $arguments;
    }

    Please this fix this,
    Thanks!

    – Scott Trsar

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Scott,

    Thanks for reporting this issue. Let me share this with the team for review.

    We’ll follow up with any updates.

    Best,
    Rob

    Plugin Support Darian

    (@d0153)

    Hi @scotttrsar

    Thank you for taking the time to notify us of the issue you have encountered. I would like to inform you that I have created an internal ticket with the reference number [BTRIA-2347] to address this issue. Your findings have been included in the ticket to ensure that our team is informed of all the necessary details. We appreciate your assistance in helping us improve our system.

    We prioritize bugs by taking into consideration the number of users impacted as well as how the bug impacts one’s ability to run an event/sell tickets. I don’t have a specific timeline as to when this issue will be resolved, but trust that our team is aware. Our team communicates updates and bug fixes in our newsletter and via our changelog.

    I’m happy to help if any other questions are coming up around this topic, otherwise I’ll go ahead and close this ticket.

    Thanks again for reporting this issue and for using The Events Calendar! Have a great day.

    Internal Bug Ticket Reference: BTRIA-2347

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Additional term arguments ignored in class Tribe__Ajax__Dropdown since v6.2.9’ is closed to new replies.