woodscreative
woodscreative

Reputation: 1031

CakePHP Inflector slug issue

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.

Upvotes: 3

Views: 1628

Answers (2)

woodscreative
woodscreative

Reputation: 1031

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;
}

Upvotes: 2

dogmatic69
dogmatic69

Reputation: 7585

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

Upvotes: 4

Related Questions