Making WordPress.org


Ignore:
Timestamp:
04/12/2019 07:09:13 AM (6 years ago)
Author:
dd32
Message:

Support Forums: Fix a fatal error which could be encountered in [8620] under some rare conditions.

See #4342.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r8620 r8634  
    294294            if ( ! $this->term && $this->get_object( $this->slug() ) ) {
    295295                $term = wp_insert_term( $this->slug(), $this->taxonomy() );
    296                 $this->term = get_term( $term['term_id'] );
     296
     297                // Term exists already? Race-condition, or get_term_by() couldn't find $slug..
     298                if ( is_wp_error( $term ) && $term->get_error_data( 'term_exists' ) ) {
     299                    $this->term = get_term( $term->get_error_data( 'term_exists' ) );
     300                } elseif ( isset( $term['term_id'] ) ) {
     301                    $this->term = get_term( $term['term_id'] );
     302                }
    297303            }
    298304
     
    749755
    750756        $term_subscription = '';
    751         if ( ! $this->term && $this->get_object( $this->slug() ) ) {
    752             // New compats won't have any support topics or reviews, so will
    753             // not yet exist as a compat term.
    754             $term = wp_insert_term( $this->slug(), $this->taxonomy() );
    755             $this->term = get_term( $term['term_id'] );
    756         }
    757757        if ( $this->term ) {
    758758            $subscribe = $unsubscribe = '';
Note: See TracChangeset for help on using the changeset viewer.