Posted by giorgio79 on May 23, 2008 at 1:46pm
| Project: | Pathauto |
| Version: | 7.x-1.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Dave Reid |
| Status: | closed (fixed) |
Issue Summary
Hi,
I may have some urls aliases that are longer then 128 (slightly more)
Having read this http://drupal.org/node/54481 I was wondering if I alter the underlying table structure to allow for 255, there is still the pathauto limit.
Has anyone removed the 128 limit yet in pathauto?
Cheers,
G
Comments
#1
I believe that if you search the code for 128 you'll find the places to change this. Of course, then you'll be using a modified version of Pathauto which means more work every time you upgrade Pathauto.
I hope you don't mind me changing this to a feature request. I don't plan on providing more support for this, but if someone wanted to modify Pathauto so that it would figure out the underlying table structure and set a higher limit based on that I would accept the patch.
#2
Hm. Wouldn't this be possible using the Schema API? It would be interesting to play with for 6.x-2.x... :) (It would also be great if it was somehow possible to assign issues to 6.x-2.x-dev - is this possible, Greg? I'm pretty sure "7.x" was listed for core before 6.x was branched out/development opened, but...)
#3
While it's possible, I don't want to be messing with the core tables. If someone else wants to do that on their site, that's fine. There was an instance in the past where Pathauto increased the size of the system table, but...that was a change that core had in a newer version already and which was causing a bug with CCK (which makes it hard to ignore).
For a feature request, though, I don't think we should be modifying a core table.
#4
Ah, but I'm not suggesting we alter any tables. :) I looked into the database functions yesternight and didn't find what I wanted, so perhaps it isn't as I hoped, but what I wanted was for Pathauto to use something like
$alias_length = get_schema('url_alias'); $alias_length = $alias_length['fields']['dst']['length'];and then use$alias_lengthto determine our max length of the alias table. Thus, we'll be ready to follow core if they change, and it's one less worry for people who need to alter it themselves.#5
I see what Freso means. Patch attached for review that will allow pathauto to be ported a little easier to future Drupal versions when the {url_alias}.dst length changes.
#6
I haven't tested the patch, but the code looks fabulous! Thank you, Dave. =)
#7
I need to re-roll for 6.x-1.x
#8
Re-rolled for 6.x-1.x.
#9
Tested and committed to 7.x-1.x and 6.x-2.x.
http://drupal.org/cvs?commit=330054
http://drupal.org/cvs?commit=330058
Should we apply this to 6.x-1.x as well?
#10
The last submitted patch, 261944-schema-maxlength-D6-2.patch, failed testing.
#11
Even added a unit test for this in 7.x-2.x and 6.x-2.x.
#12
Revised patch for 6.x-1.x. Does change some of the help text translation.
#13
Here's the non-string change version.
#14
Committed to 6.x-1.x.
http://drupal.org/cvs?commit=331190
http://drupal.org/cvs?commit=331192
#15
Hi Dave, I'm still new in this system please correct me if I'm doing wrong. You've suggested me to follow-up my issue in this thread instead in If node title contains only ignore words, it results to a blank alias thread. Here's the issue for Drupal 7:
In line 214 of pathauto.inc is hard coded with 128 maximum length (per component) it prevents the alias to reach the length specified in {url_alias} table (alias field) which is now set to 255 in drupal 7. For example in admin/config/search/path/pathauto if the user set his Default path pattern (applies to all node types with blank patterns below) field to [node:title] only, all nodes' alias will still have the maximum length of 128 because the line 214 of pathauto.inc enforced it:
$maxlength = min(variable_get('pathauto_max_component_length', 100), 128);Suggestion is:
- $maxlength = min(variable_get('pathauto_max_component_length', 100), 128);+ $maxlength = min(variable_get('pathauto_max_component_length', 100), _pathauto_get_schema_alias_maxlength());
#16
@arpeggio (great name btw!): Thanks for catching that. I committed that fix to all three branches.
http://drupal.org/cvs?commit=334898
http://drupal.org/cvs?commit=334900
http://drupal.org/cvs?commit=334902
#17
Thank you :) and thanks Dave for the quick respond to the fix.
#18
Automatically closed -- issue fixed for 2 weeks with no activity.
#19
Hi Dave,
Quick question: Does the Schema API only apply to the default (core installation) state of the schema?
We recently upgraded PathAuto to 6.x-1.x-dev, and it seems
_pathauto_get_schema_alias_maxlength()is always returning 128 even though we've manually updated the url_alias table "dst" column to varchar(255). I suspect from comments #4 and #5 that the only way for _pathauto_get_schema_alias_maxlength() to return 255 is if the underlying schema is modified in some future upgrade, and that in the meantime, any manual change to the "dst" column of the url_alias table is ignored. Am I correct?
If this is true, then is it true that the only way to set a higher alias max would be to hard-code _pathauto_get_schema_alias_maxlength() to return 255 until a future upgrade changes the underlying schema so that $alias_length['fields']['dst']['length'] is increased from 128 to 255?
Thanks!
#20
You can implement this in your own module:
<?php/**
* Implementation of hook_schema_alter().
*/
function mymodule_schema_alter(&$schema) {
$schema['url_alias']['fields']['dst']['length'] = 255;
}
?>
#21
Thanks Dave, that solution worked rather nicely =) I'm assuming that my assumptions from my initial post were correct then =)
Thanks!