Aliases ignored of already existing user entries in xmlsitemap_user table
| Project: | XML sitemap |
| Version: | 5.x-1.7 |
| Component: | xmlsitemap_user.module |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Hi,
on cron run, the pid of already existing user entries in xmlsitemap_user table won't get updated. As a result, the xml sitemap shows the original path of these entries instead of their alias (e.g. 'user/23' instead of 'users/michael').
The reason for this behavior is the if-clause at the beginning of the function xmlsitemap_user_cron(): The insert and update queries will only be executed if the uid column of an entry is NULL. That is the reason why in the case I described above (-->entry already exists with an uid but a wrong pid), the entries will never be updated with the alias pid.
In the patch attached to this post, I simply removed the last condition of the WHERE clause ("AND xu.uid IS NULL"). I think there are no side effects because the query directly following the if-clause includes this condition as well.
I tested it and the sitemap as well as the xmlsitemap_user table looks fine now.
| Attachment | Size |
|---|---|
| xmlsitemap_user.module_cron_query.diff | 618 bytes |

#1
This will cause a full table of users to be reviewed with each execution. The xu.uid IS NULL filter is needed to limit the rows to only those that need created or updated. You need to look for a way to add a OR condition to the query.
#2
Hi earnie,
thanks for your reply.
I changed the query now to "WHERE u.uid <> 0 AND (xu.uid IS NULL OR xu.pid IS NULL)". Now the filter will also include those rows with a NULL value in the pid column. Is this ok?
Thanks,
Oliver
#3
Dave, can you review this please.
#4
I think this needs work. If we have an existing record in {xmlsitemap_user} that does not have an alias (xu.pid is NULL), this is going to pick up this record. But then later we use drupal_write_record() assuming this is always an insert and never an update.