From a577e6a410ad4f9d64f22a0a7c22eb282b4f342a Mon Sep 17 00:00:00 2001 From: David Cavins Date: Mon, 26 Jun 2017 12:12:28 -0500 Subject: [PATCH] Always cast term_ids as integers. Passing term IDs to WP as strings results in WP making new terms. For existing terms, always cast the ID as an integer to avoid this issue (and to ensure a match). --- class-wxr-importer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/class-wxr-importer.php b/class-wxr-importer.php index 9a5f637..7df6773 100644 --- a/class-wxr-importer.php +++ b/class-wxr-importer.php @@ -2319,18 +2319,18 @@ protected function term_exists( $data ) { // Constant-time lookup if we prefilled if ( $this->options['prefill_existing_terms'] ) { - return isset( $this->exists['term'][ $exists_key ] ) ? $this->exists['term'][ $exists_key ] : false; + return isset( $this->exists['term'][ $exists_key ] ) ? (int) $this->exists['term'][ $exists_key ] : false; } // No prefilling, but might have already handled it if ( isset( $this->exists['term'][ $exists_key ] ) ) { - return $this->exists['term'][ $exists_key ]; + return (int) $this->exists['term'][ $exists_key ]; } // Still nothing, try WP's term_exists, and cache it. $exists = term_exists( $data['slug'], $data['taxonomy'] ); if ( is_array( $exists ) ) { - $exists = $exists['term_id']; + $exists = (int) $exists['term_id']; } $this->exists['term'][ $exists_key ] = $exists;