Woocommerce WPML RankMath PHP Error

#34983
  • Resolved DJ
    Rank Math free

    Using the latest version of WordPress, Woocommerce, WPML and RankMath. Also running PHP 7.3 and I am getting the following error. Please could you ask your dev team to take a look at this error in the Woocommerce Module of RankMath:

    Undefined variable: original_link
    wp-content/plugins/seo-by-rank-math/includes/modules/woocommerce/class-woocommerce.php:188

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for getting in touch with us and sorry for the inconvenience.

    Unfortunately I am unable to replicate this on my end. Would you mind sharing some temporary admin + FTP access to your site?

    Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    DJ
    Rank Math free

    Hi Michael.

    Please can you pass on my ticket to the developers as they will immediately understand the issue. This is a PHP error in the plugin. I will provide a further explanation for you.

    The below line means that the variable $original_link is being used on line 188 in class-woocommerce.php before it has been defined and given a value.

    Undefined variable: original_link
    wp-content/plugins/seo-by-rank-math/includes/modules/woocommerce/class-woocommerce.php:188

    Here is the whole function:

    /**
     * Replace category permalink according to settings.
     *
     * @param string $link     Term link URL.
     * @param object $term     Term object.
     * @param string $taxonomy Taxonomy slug.
     *
     * @return string
     */
    public function product_term_link( $link, $term, $taxonomy ) {
      if ( $this->can_change_link( 'product_cat', $taxonomy ) ) {
        return $link;
      }
    
      $permalink_structure  = wc_get_permalink_structure();
      $category_base        = trailingslashit( $permalink_structure['category_rewrite_slug'] );
      $is_language_switcher = ( class_exists( 'Sitepress' ) && strpos( $original_link, 'lang=' ) );
    
      if ( $this->remove_category_base ) {
        $link          = str_replace( $category_base, '', $link );
        $category_base = '';
      }
    
      if ( $this->remove_parent_slugs && ! $is_language_switcher ) {
        $link = home_url( trailingslashit( $category_base . $term->slug ) );
      }
    
      return $link;
    }

    Please forward this to developers so it can be fixed in the next update. Thank you.

    Attention: @pratik-d @toddmts

    Hello,

    Thank you for letting us know the issue. I was able to reproduce this issue on my setup and I have added it to our bug lists. For now, please change the code on line 188 with:

    $is_language_switcher = ( class_exists( 'Sitepress' ) && strpos( $link, 'lang=' ) );

    I hope that helps. Please let us know if there is anything else.

    Thank you.

    DJ
    Rank Math free

    @pratik-d

    Thanks for you reply. I see the latest update of RankMath today didn’t add the fix, so I had to tweak that line again. I assume it will make it into the next version update. Have a good weekend :-).

    Todd
    Rank Math free

    Hi DJ,

    Yes, we will add it in the next version as we didn’t have sufficient time to include it in 5th March’s update.

    Appreciate your patience in this matter.

Viewing 5 replies - 1 through 5 (of 5 total)

The ticket ‘Woocommerce WPML RankMath PHP Error’ is closed to new replies.