Closed (duplicate)
Project:
Drupal core
Version:
7.x-dev
Component:
path.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Jan 2011 at 20:07 UTC
Updated:
21 Feb 2011 at 23:27 UTC
In #979090: Node path 'cas' overrides CAS module 'cas' path, a user manually added a path 'cas' to a node which broke the functionality of the CAS login feature.
To prevent such errors, it would be convenient of path.module added a hook_path_validate() where a potential path alias could be validated by modules. The API might be something like
/**
* Allow modules to validate to a path being created or updated.
*
* @param $path
* An associative array containing the following keys:
* - source: The internal system path.
* - alias: The URL alias.
* - pid: Unique path alias identifier.
* - language: The language of the alias.
* @param $errors
* An array of human readable error messages.
*
* @see path_save()
*/
function hook_path_validate($path, &$errors) {
if ($path['alias'] == 'user') {
$errors[] = t('The path alias %path is reserved for %module.', array('%path' => 'user', '%module' => 'user.module));
}
}
Or maybe something more like the field validation functionality (which is more complicated). I can't say I've thought about it very much... responses appreciated.
Comments
Comment #1
dave reidI agree. I'm merging this into #121362: Require dedicated permission(s) to set aliases pointing to existing or reserved paths as likely it would be a path_validate + hook_path_validate() that helps implement it.