3

When I use:

Inflector::slug("My Lovely & long slug");

On my local server I get:

My_Lovely_long_slug

When I use it on my server I get:

Lo_l_lo_lu

What gives? This issue is also affecting all my cache names which I assume are using the Inflector class. Any help appreciated.

woodscreative
  • 1,011
  • 8
  • 26

2 Answers2

4

looks like to different versions of cake? ive seen this reported before but dont have any references for you. Tested on my server for ~ 1.3.6/7 and it works as expected.

if the versions of cake are the same try and do a 'git bisect' which will give you an answer pretty quick

update:

seems to do with your PCRE libraries installed on the server that are older etc. give them an update and all should be fine

dogmatic69
  • 7,574
  • 4
  • 31
  • 49
2

So I made my own slug for now.

function permalink ($string = '',$length = false)
{
    $string = strtolower($string); // All lowercase
    $string = preg_replace('/[^%a-z0-9]/',' ', $string); // Remove garbage
    $string = preg_replace('/\s+/','_', $string);
    $string = preg_replace('|-+|','_', $string);
    if ($length) $string = substr($string,0,$length); // Limit string length?
    $parsed = trim($string,'_'); // Trim pre and post trailing delims
    return $parsed;
}
woodscreative
  • 1,011
  • 8
  • 26