Hello,

I'm not sure if I needed to post this in the xmlsitemap issue queue or the termstatus one.

When using the termstatus module unpublished terms get indexed and should not. I believe it should work like nodes: unpublished ones don't get indexed.

Cheers,
D

Comments

dansanjou created an issue. See original summary.

varo90’s picture

StatusFileSize
new1.83 KB

Hi!

When generating taxonomy terms links xmlsitemap does not check if terms are published or not (This funcionnality is added by Taxonomy Term Status module).
I added this compatibility:

Replaced the original taxonomy query for a dinamic one to be able to add the published term condition when termstatus module is enabled.

So far IT ONLY WORKS WHEN EXECUTING DRUSH AND CRON... It doesn't work from the administration panel as for some reason it goes through a different logic.

Old query:

db_query_range("SELECT t.tid FROM {taxonomy_term_data} t INNER JOIN {taxonomy_vocabulary} tv USING (vid) LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy_term' AND t.tid = x.id WHERE x.id IS NULL AND tv.machine_name IN (:bundles) ORDER BY t.tid DESC", 0, $limit, array(':bundles' => $bundles))

New query:

        $query = db_select('taxonomy_term_data', 't');
        $query->fields('t', array('tid'));
        $query->innerjoin('taxonomy_vocabulary', 'tv', 'tv.vid = t.vid');
        $query->leftjoin('xmlsitemap', 'x', 'x.type = :type AND t.tid = x.id', array(':type' => 'taxonomy_term'));
        $query->condition('tv.machine_name',($bundles), 'IN')
            ->isNull('x.id');
        $query->orderBy('t.tid', 'DESC')->range(0,$limit);

        // Add Term status compatibility.
        if(module_exists('termstatus')) {
            $query->innerjoin('termstatus', 'ts', 'ts.tid = t.tid');
            $query->condition('ts.status', 1);
        }

Have a nice day! And if someone finds out why this isn't working from de admin panel we'd be very thankful for sharing the info! ;)

adrien.felipe’s picture

Title: Unpublished taxonomy terms get indexed when using module termstatus » Add compatibility with Taxonomy term status module
Category: Bug report » Feature request
tbpixel’s picture

StatusFileSize
new994 bytes

Hey dansanjou,

I've created a patch that integrates Taxonomy Term Status support into XML Sitemap. The patch ensures that the termstatus module is enabled before making any changes, so users without termstatus installed will notice no difference.

avpaderno’s picture

Status: Active » Needs review
dave reid’s picture

Status: Needs review » Needs work

I don't think this currently applies and is not the right area to fix. We want the rebuild to index everything regardless of status. I believe what should be patched is this portion of xmlsitemap_taxonomy_create_link(): https://git.drupalcode.org/project/xmlsitemap/-/blob/7.x-2.x/xmlsitemap_...