Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant, maybe unnecessary, term caching. #130

Open
dcavins opened this issue Jun 22, 2017 · 0 comments
Open

Redundant, maybe unnecessary, term caching. #130

dcavins opened this issue Jun 22, 2017 · 0 comments

Comments

@dcavins
Copy link
Contributor

dcavins commented Jun 22, 2017

Hi all-

in WXR_Importer, there are two arrays that are used to cache terms:
(The $mapping_key is calculated as sha1( taxonomy:slug ) in every case below.)
$this->mapping['term'][ $mapping_key ] = $term_id entries are created as terms are created.

$this->exists['term'][ $mapping_key ] = $term_id entries are populated at the start with all existing terms if prefill_existing_terms is true. Entries also need to be added as new terms are created.

There's also an array that maps the old term ID to the new term ID.
$this->mapping['term_id'][ $original_id ] = $term_id

In looking at WP export files it seems that all terms are referred to by their taxonomy and slug:
Example term description:
<wp:term><wp:term_id>1420</wp:term_id><wp:term_taxonomy>geographies</wp:term_taxonomy><wp:term_slug>alaska-state</wp:term_slug><wp:term_parent>united-states</wp:term_parent><wp:term_name><![CDATA[Alaska]]></wp:term_name><wp:term_description><![CDATA[04000US02]]></wp:term_description></wp:term>
Note that the parent term is given as a slug, too.

Terms are referenced in post output as slugs:
<category domain="goals" nicename="healthy-child"><![CDATA[Healthy Child]]></category>

Since the taxonomy/slug pair is used as a unique key, I'm wondering if we could get away with using the $exists array only for terms. I'm not able to think of any examples where the old ID would need to be mapped to the new ID, and the slug wouldn't get the job done.

I'd be happy to submit a PR simplifying the term code if you agree.

Thanks again for all the work on this new plugin.

-David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant