ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

URL Title collision from SAEF entries

August 08, 2012 2:44pm

Subscribe [2]
  • #1 / Aug 08, 2012 2:44pm

    Spurlock

    14 posts

    Using EE 1.6.8.

    A user is trying to submit an entry to the site via SAEF, and getting the error message “An entry already exists with this URL title. URL titles must be unique”. This SAEF does not attempt to set the url_title on the client side (there’s no url_title field at all), instead allowing it to be figured out on the server. As I understand it, in cases where the default URL title already exists, EE should assign a number and append it to the end to create the unique url_title.

    From what I’ve read online, this should work up to 50 entries, at which point the above message is to be expected. On my site though, there are less than 20 entries sharing a version of this url_title, so EE shouldn’t be giving up on generating a unique suffix. Stranger still, the numbers that have been appended (presumably automatically) to the existing entries aren’t sequential integers, but seemingly random numbers up to over 11,000.

    My only concern is getting EE to accept up to 50 entries like it’s supposed to, I don’t really mind the random-large-number behavior (I mention it only because it seems likely to be related and helpful). Upgrading EE isn’t really an option, but I don’t see anything in the EE1 changelogs that looks relevant anyway (the only changes listed for url_title deal with very long titles, which this one isn’t). I know I can probably band-aid the problem by deleting some of the old entries (which have expired anyway), but I’d rather find a way to fix it going forward. Any suggestions or insight would be much appreciated!

  • #2 / Aug 09, 2012 3:39pm

    Shane Eckert

    7174 posts

    Hello Spurlock,

    I am sorry to hear you are running into this problem.

    I would like to log in and take a look. Please be on the lookout for an email from EllisLab.

    Thank you,

  • #3 / Aug 14, 2012 11:56am

    Robin Sowell

    13255 posts

    Hi Spurlock,

    Replying here as it may be relevant for others.

    EE currently uses some clever mysql to figure out how to handle duplicate url titles.  Here’s an example of the query used to figure out the suffix when an initial query reveals that an entry already exists with the url_title being submitted:

    SELECT url_title, MID(url_title, 17) + 1 AS next_suffix FROM exp_weblog_titles WHERE weblog_id = '8' AND url_title REGEXP('general\-example[0-9]*$') AND weblog_id = '8' ORDER BY next_suffix DESC LIMIT 1

    Er- more or less.  I tweaked it.  Anyway- it looks for url_titles of ‘general_example’ followed by digits, orders them by the digit- grabs the highest digit- and then it will use as a suffix that digit plus 1.

    There’s a limit- because of how long the column is.  But the limit is

    if ($query->row['next_suffix'] > 99999)

    So- way higher than 50.

    EXCEPT- it’s not trying every possible number.  It’s grabbing the highest existing number.  And for some reason?  You’ve got some url_titles in there with large numbers tacked on the end.

    So if I just run that query?  It comes back with a url_title like general-example222121.  And 222121 is bigger than 99999- so it can’t make any more.  Even though you’ve only got about 18 url_titles that are general-examplex.

    So that’s why you’re hitting the limit, despite not having 50 or 99999 ‘duplicates’ in there.  You’ve got one with a really large number tacked on the end.

    I can noodle around with the issue a bit and we would like to work around the current 99999 limit- but for 1.x, that code won’t change.  You might tweak the existing entry to be general-example-222121 or something along those lines.  And you’ve a few others that just randomly have numbers appended to them that do not look like what I’d expect from the unique url_title code.  But yes- I’m thinking this is one where you may need to tweak on a case-by-case basis so you aren’t having url_titles that will be interpreted as a unique suffix.

    Make sense what’s going on there?

  • #4 / Aug 14, 2012 2:00pm

    Spurlock

    14 posts

    Thanks Robin, makes perfect sense: Somehow or another some stupid high numbers got in there, and EE is trying to increment from the highest one and hitting a ceiling.

    I’ll reply back if I figure out how those suffixes got in there to begin with (I sort of suspect that our third-party entry cloning extension will be the culprit), but this definitely solves the issue for now. Thanks again.

  • #5 / Aug 14, 2012 2:40pm

    Robin Sowell

    13255 posts

    Exactly.  Glad we’ve got the base issue identified.  And yes- it does sort of have the look of something done automatically, but… the numbers aren’t really in a sequence.  So mostly it’s just kind of odd.  😉

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases