Skip to content

Commit a577e6a

Browse files
committed
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).
1 parent c2e2913 commit a577e6a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

class-wxr-importer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2319,18 +2319,18 @@ protected function term_exists( $data ) {
23192319

23202320
// Constant-time lookup if we prefilled
23212321
if ( $this->options['prefill_existing_terms'] ) {
2322-
return isset( $this->exists['term'][ $exists_key ] ) ? $this->exists['term'][ $exists_key ] : false;
2322+
return isset( $this->exists['term'][ $exists_key ] ) ? (int) $this->exists['term'][ $exists_key ] : false;
23232323
}
23242324

23252325
// No prefilling, but might have already handled it
23262326
if ( isset( $this->exists['term'][ $exists_key ] ) ) {
2327-
return $this->exists['term'][ $exists_key ];
2327+
return (int) $this->exists['term'][ $exists_key ];
23282328
}
23292329

23302330
// Still nothing, try WP's term_exists, and cache it.
23312331
$exists = term_exists( $data['slug'], $data['taxonomy'] );
23322332
if ( is_array( $exists ) ) {
2333-
$exists = $exists['term_id'];
2333+
$exists = (int) $exists['term_id'];
23342334
}
23352335

23362336
$this->exists['term'][ $exists_key ] = $exists;

0 commit comments

Comments
 (0)