Login!
Register as a new user Lost password?
 

MODx Bug/Feature Tracker and Feature Requests

Welcome to the MODx CMS Tracker. Please choose the appropriate project from the drop down menu and provide as much information as possible regarding your server environment and browser. Thanks!

FS#1006 — Automatic Alias produces Duplicates

Attached to Project — MODx
Opened by Kuno Floez-Mausegatt (kuno) - Tuesday, 29 January 2008, 08:06AM
Last edited by Ryan Thrash (rthrash) - Tuesday, 29 January 2008, 08:32AM
Task Type Bug Report
Category Core Distribution
Status Waiting on User
Assigned To No-one
Operating System All
Severity Low
Priority Normal
Reported Version 0.9.6.1
Due in Version 0.9.6.2
Due Date Undecided
Percent Complete 20%

Details

When "duplicate aliases" is set to NO, in save_content.processor.php it is checked, wether the alias already exists. If so, you append a number to the alias to create a new one.

// check if alias already exists. if yes then append $cnt to alias
$cnt = $modx->db->getValue("SELECT count(*) FROM " . $tblsc . " WHERE id<>'$id' AND alias ='$alias'");
if ($cnt > 0)
$alias .= $cnt;
}

But if Alias is Unique (no duplicates), count(*) will always get 1 and there will be one page called "xy" and many pages called "xy1". Which is not further checked :-(

Instead you should check for
WHERE id<>'$id' AND alias LIKE '$alias%'");
so the number will be increased to more than 1... and there will be "xy", "xy1", "xy2"...
This task depends upon

This task blocks these from closing
Comment by Ryan Thrash (rthrash) - Tuesday, 29 January 2008, 08:31AM
  • Field changed: Due Date (Undecided → Undecided)
Is this not a duplicate of  FS#940  which is committed in the current SVN trunk?

Comment by Matthew Pietz (sirlancelot) - Friday, 22 February 2008, 12:04PM
The problem with selecting LIKE is if a user has documents where aliases are alike to begin with:

news-all
news-new
news-tagged

When a new documents is created with an alias of "news", it will become "news3" even though there is no document already named "news". I don't have a solution in mind, just a thought on what would happen in certain scenarios.