0

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.

Modules installed:

  • Path (path)
  • Pathologic (pathologic)
  • Pathauto (pathauto)
  • Global Redirect (globalredirect)
  • Redirect (redirect) with PATCH
3
  • Is bulk update generating incorrect aliases? Commented Dec 31, 2015 at 20:26
  • As @Patrick Ryan mentioned, you could use the Bulk Update tab to update all url aliases. Like in my answer over here
    – No Sssweat
    Commented Jan 1, 2016 at 0:26
  • I did not test extensively, but I ran the bulk updater once and it did not remove the bad ones. I then used the overview page to search for and delete the ones that my query revealed. After that, the bulk update created new aliases for those nodes that were correct. Is that not the expected behaviour? Commented Jan 5, 2016 at 19:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.