• Resolved An, Hyeong-woo

    (@mytory)


    I have been enjoying using your plugin — thank you for the great work.

    Issue:

    However, since updating to WordPress 6.4, it seems there has been a conflict. When I go to edit a post, there’s an issue that the categories get reset.

    Code Analysis:

    As shown in the photo I’ve linked, the conflict occurs on line 788 of class-wp-term-query.php in WordPress 6.4.2. The relevant code involves the $args call where the fields are ‘ids‘, and it passes all the items through the intval function using array_map.

    if ( 'ids' === $_fields ) {
        $cache = array_map( 'intval', $cache );
    }

    The error occurs because the actual value is not an integer but a WP_Term Object.

    When the plugin is deactivated, the $_fields is set to ‘all‘, not ‘ids‘. When the plugin is activated, the $_fields value changes to ‘ids‘.

    I would love to continue using your plugin, so I would greatly appreciate it if you could fix this issue.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • krijj

    (@krijj)

    I have the same problem with WordPress 6.4.2 :

    • category are reset if i edit a post
    • here is the notice I get when editing a post with wp_debug=true :

    Notice: Object of class WP_Term could not be converted to int in /wp-includes/class-wp-term-query.php on line 788

    Thanks for your help.

    Hi, please look at this.

    Thread Starter An, Hyeong-woo

    (@mytory)

    As the developer seems to be busy, I’ve fixed the issue myself. The solution is to comment out line 48 (by adding // at the beginning) and modify line 51 in the file wp-content/plugins/anything-order-by-terms/modules/taxonomy/class.php. Change line 51 to $orderby = 'ORDER BY COALESCE(CAST(ant_tm.meta_value AS UNSIGNED), ~0) ASC';. This results in the following changes. Below are lines 48-51 after the modification:

    // $pieces['fields'] .= ', CAST(ant_tm.meta_value AS UNSIGNED) AS term_order_int';
    $pieces['join']   .= " LEFT JOIN {$wpdb->termmeta} AS ant_tm ON (t.term_id = ant_tm.term_id AND ant_tm.meta_key = '_order_{$taxonomy}') ";
    
    $orderby = 'ORDER BY COALESCE(CAST(ant_tm.meta_value AS UNSIGNED), ~0) ASC';

    With these changes, the plugin works without issues in WordPress 6.5. The download link below is for the patch file. You can apply it by running the command patch -p1 < anything-order-by-terms-for-wp-6.4.patch in the terminal.

    https://drive.google.com/file/d/1uGy0tL690RBu3mSrN08QpHR0cEgwwRie/view?usp=drive_link

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.