With this, the generated slug always looses the name's last three characters (eg "Un long voyage" would become "un-long-voy") whatever the name's length is. I found that the generated limitSlugSize method is the culprit here:
/**
* Make sure the slug is short enough to accommodate the column size
*
* @param string $slug the slug to check
*
* @return string the truncated slug
*/
protected static function limitSlugSize($slug, $incrementReservedSpace = 3)
{
// check length, as suffix could put it over maximum
if (strlen($slug) > ( - $incrementReservedSpace)) {
$slug = substr($slug, 0, - $incrementReservedSpace);
}
return $slug;
}
Because the used column has no size, the size is not inserted when this method is generated and the three last characters are always trimed out.
I've fixed my issue by converting the column to VARCHAR with a length of 256, but I thought it might be nice to have a warning or an error when using a column without size to store a slug.
Adding Propel to a legacy project with an existing database, I've noticed that sluggable behavior might sometimes generate truncated slugs.
Here is my sluggable behavior config:
and the
url
column that already existed:With this, the generated slug always looses the
name
's last three characters (eg "Un long voyage" would become "un-long-voy") whatever thename
's length is. I found that the generatedlimitSlugSize
method is the culprit here:Because the used column has no size, the size is not inserted when this method is generated and the three last characters are always trimed out.
I've fixed my issue by converting the column to
VARCHAR
with a length of 256, but I thought it might be nice to have a warning or an error when using a column without size to store a slug.