I find the "fun" problems. I have a site that is using token paths for content. Not all the paths are correct. This is a symptom of a deeper problem that I am still looking for, but it is causing its own trouble in the mean time. The url pattern should be [field_category]/[title] and I have constructed a mysql query to identify ones that do not follow this pattern.
SELECT r.redirect, r.source, a.alias, s.field_category_value FROM redirect r LEFT JOIN url_alias a ON r.redirect = a.source LEFT JOIN node n ON r.redirect LIKE CONCAT( 'node/', n.nid) LEFT JOIN field_data_field_category s ON s.entity_id = n.nid WHERE a.alias NOT LIKE CONCAT(LOWER(LEFT(s.field_category_value, 2)), '%');
Examples of field_category_value are
Aquariums & Zoos and
RV Site. I did not want to bother with converting the space after RV to a dash so I am using
LEFT(x, 2) to trim it there.
Currently, this query is returning 14 results from the 8000 listings, so not a high ratio but still something that should never happen. Especially when I just manually deleted the 300 that were discovered as wrong last week, and then used the bulk alias updater to replace them. These incorrect urls are being indexed by solr, compounding my problem. I am not even sure what I am asking. The biggest question is why is this happening, but I dont expect anyone out there to know that.
If you have a programmatic way to find these, I can hook_cron something to repair them until the actual cause is found.
- Path (path)
- Pathologic (pathologic)
- Pathauto (pathauto)
- Global Redirect (globalredirect)
- Redirect (redirect) with PATCH