[pLog-svn] r4621 - plog/branches/lifetype-1.1.5/class/dao
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Mon Jan 29 21:52:05 EST 2007
Author: jondaley
Date: 2007-01-29 21:52:05 -0500 (Mon, 29 Jan 2007)
New Revision: 4621
Modified:
plog/branches/lifetype-1.1.5/class/dao/articles.class.php
Log:
make sure to ignore ourselves when searching for a unique slug. fixes: http://forums.lifetype.net/viewtopic.php?t=5801
Modified: plog/branches/lifetype-1.1.5/class/dao/articles.class.php
===================================================================
--- plog/branches/lifetype-1.1.5/class/dao/articles.class.php 2007-01-29 23:28:32 UTC (rev 4620)
+++ plog/branches/lifetype-1.1.5/class/dao/articles.class.php 2007-01-30 02:52:05 UTC (rev 4621)
@@ -767,7 +767,7 @@
{
$slug = $newArticle->getPostSlug();
$i = 1;
- // check if there already is a blog with the same mangled name
+ // check if there already is an article with the same mangled name
while($this->getBlogArticleByTitle($slug,
$newArticle->getBlog()))
{
@@ -927,14 +927,18 @@
{
$slug = $article->getPostSlug();
$i = 1;
- // check if there already is a blog with the same mangled name
- while($this->getBlogArticleByTitle($slug,
- $article->getBlog()))
+ // check if there already is an article with the same mangled name
+ while($existingArticle = $this->getBlogArticleByTitle($slug,
+ $article->getBlog()))
{
- $i++;
- // and if so, assign a new one
+ // if we found ourselves, it is okay to keep using this name
+ if($existingArticle->getId() == $article->getId())
+ break;
+
+ // found a match, so assign a new one
// if we already tried with slug+"i" we have
// to strip "i" before adding it again!
+ $i++;
$slug = substr($slug, 0,
($i > 2) ? strlen($slug)-strlen($i-1) : strlen($slug)).$i;
}
More information about the pLog-svn
mailing list