<!--
RSS generated by JIRA (5.2.7#850-sha1:b2af0c8dc8537b36121c6a579fabbdf79fc919e5) at Mon May 20 08:36:59 UTC 2013

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary add field=key&field=summary to the URL of your request.
For example:
http://www.doctrine-project.org/jira/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=project+%3D+DC+AND+resolution+%3D+Unresolved+AND+component+%3D+Sluggable+ORDER+BY+priority+DESC&tempMax=1000&field=key&field=summary
-->
<!-- If you wish to do custom client-side styling of RSS, uncomment this:
<?xml-stylesheet href="http://www.doctrine-project.org/jira/styles/jiraxml2html.xsl" type="text/xsl"?>
-->
<rss version="0.92">
    <channel>
        <title>Doctrine Project</title>
        <link>http://www.doctrine-project.org/jira/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+DC+AND+resolution+%3D+Unresolved+AND+component+%3D+Sluggable+ORDER+BY+priority+DESC</link>
        <description>An XML representation of a search request</description>
                <language>en-us</language>
                        <issue start="0" end="3" total="3"/>
                <build-info>
            <version>5.2.7</version>
            <build-number>850</build-number>
            <build-date>21-02-2013</build-date>
        </build-info>
<item>
            <title>[DC-640] Slugs aren&apos;t created when inserting/updating a table row</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-640</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;Basically the slug column doesn&apos;t get updated in spite of all fields being added correctly, as far as i can tell.&lt;br/&gt;
It seems to be related to additional options because when i don&apos;t have either of the uniqueBy or canUpdate options specified, it just works.&lt;/p&gt;

&lt;p&gt;What&apos;s been missing is the &apos;slug&apos; column value in the sql statements (providing 3 examples):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;2400 Query INSERT INTO `custom_category` (`block_id`, `name`) VALUES (&apos;1&apos;, &apos;slug test&apos;)
2526 Query INSERT INTO `custom_category` (`name`, `block_id`) VALUES (&apos;please &lt;span class=&quot;code-keyword&quot;&gt;do&lt;/span&gt; work..&apos;, &apos;1&apos;)
2560 Query UPDATE `custom_category` SET `name` = &apos;still not ok&apos; WHERE `id` = &apos;12&apos;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The generated schema.sql includes the correct create table statement (it&apos;s also correctly inserted in the db):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;CREATE TABLE `custom_category` (
  `id` INT UNSIGNED AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  `block_id` INT UNSIGNED NOT NULL,
  `slug` VARCHAR(255),
  UNIQUE INDEX `custom_category_sluggable_idx` (`slug`, `block_id`, `name`),
  INDEX `block_id_idx` (`block_id`),
  PRIMARY KEY(`id`)
) ENGINE = INNODB;
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The schema.yml entry is the following:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;CustomCategory:
  connection: removed
  tableName: custom_category
  actAs:
    Sluggable:
      fields: [name]
      uniqueBy: [block_id, name]
      canUpdate: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  columns:
    id:
      type: integer(4)
      unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      primary: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      autoincrement: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    name:
      type: string(255)
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
    block_id:
      type: integer(4)
      unsigned: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
      notnull: &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;
  relations:
    Products:
      class: Product
      foreignAlias: CustomCategories
      refClass: ProductCustomCategory
    Block:
      class: Block
      local: block_id
      foreign: id
      foreignType: many
      foreignAlias: CustomCategories
      type: one
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And finally the appropriate auto generated base class (removed doc block):&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&amp;lt;?php
&lt;span class=&quot;code-comment&quot;&gt;// Connection Component Binding
&lt;/span&gt;Doctrine_Manager::getInstance()-&amp;gt;bindComponent(&apos;CustomCategory&apos;, &apos;removed&apos;);

&lt;span class=&quot;code-keyword&quot;&gt;abstract&lt;/span&gt; class BaseCustomCategory &lt;span class=&quot;code-keyword&quot;&gt;extends&lt;/span&gt; aaDoctrineRecord
{
    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setTableDefinition()
    {
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;setTableName(&apos;custom_category&apos;);
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;id&apos;, &apos;integer&apos;, 4, array(
             &apos;type&apos; =&amp;gt; &apos;integer&apos;,
             &apos;unsigned&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             &apos;primary&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             &apos;autoincrement&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             &apos;length&apos; =&amp;gt; &apos;4&apos;,
             ));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;name&apos;, &apos;string&apos;, 255, array(
             &apos;type&apos; =&amp;gt; &apos;string&apos;,
             &apos;notnull&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             &apos;length&apos; =&amp;gt; &apos;255&apos;,
             ));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasColumn(&apos;block_id&apos;, &apos;integer&apos;, 4, array(
             &apos;type&apos; =&amp;gt; &apos;integer&apos;,
             &apos;unsigned&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             &apos;notnull&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             &apos;length&apos; =&amp;gt; &apos;4&apos;,
             ));
    }

    &lt;span class=&quot;code-keyword&quot;&gt;public&lt;/span&gt; function setUp()
    {
        parent::setUp();
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasMany(&apos;Product as Products&apos;, array(
             &apos;refClass&apos; =&amp;gt; &apos;ProductCustomCategory&apos;,
             &apos;local&apos; =&amp;gt; &apos;custom_category_id&apos;,
             &apos;foreign&apos; =&amp;gt; &apos;product_id&apos;));

        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;hasOne(&apos;Block&apos;, array(
             &apos;local&apos; =&amp;gt; &apos;block_id&apos;,
             &apos;foreign&apos; =&amp;gt; &apos;id&apos;));

        $sluggable0 = &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; Doctrine_Template_Sluggable(array(
             &apos;fields&apos; =&amp;gt;
             array(
              0 =&amp;gt; &apos;name&apos;,
             ),
             &apos;uniqueBy&apos; =&amp;gt;
             array(
              0 =&amp;gt; &apos;block_id&apos;,
              1 =&amp;gt; &apos;name&apos;,
             ),
             &apos;canUpdate&apos; =&amp;gt; &lt;span class=&quot;code-keyword&quot;&gt;true&lt;/span&gt;,
             ));
        $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;actAs($sluggable0);
    }
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment>Using Symfony 1.4 form svn:&lt;br/&gt;
&lt;br/&gt;
URL: &lt;a href=&quot;http://svn.symfony-project.com/branches/1.4&quot;&gt;http://svn.symfony-project.com/branches/1.4&lt;/a&gt;&lt;br/&gt;
Revision: 29223&lt;br/&gt;
Last Changed Rev: 29218&lt;br/&gt;
Last Changed Date: 2010-04-20 08:04:09 +0200 (Di, 20 Apr 2010) </environment>
            <key id="11251">DC-640</key>
            <summary>Slugs aren&apos;t created when inserting/updating a table row</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="perplexa">Daniel K&#246;nig</reporter>
                        <labels>
                    </labels>
                <created>Wed, 21 Apr 2010 03:59:16 +0000</created>
                <updated>Mon, 3 May 2010 08:31:15 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Sluggable</component>
                        <due></due>
                    <votes>0</votes>
                        <watches>0</watches>
                        <comments>
                    <comment id="12817" author="caponica" created="Sat, 1 May 2010 14:00:57 +0000"  >&lt;p&gt;What is the code that you&apos;re using to generate the INSERT query?&lt;/p&gt;</comment>
                    <comment id="12820" author="perplexa" created="Mon, 3 May 2010 08:31:15 +0000"  >&lt;p&gt;just instantiating the object, calling the setters, followed by a save().&lt;/p&gt;

&lt;p&gt;it&apos;s related to the uniqueBy and canUpdate options, though - it works like a charm without these two.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-623] Impossible to create non-unique slugs</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-623</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;I want to create a non-unique slug of a title field from my table.&lt;/p&gt;

&lt;p&gt;But I&apos;ve found that when I change unique from &apos;true&apos; to &apos;false&apos; the slugs were not created or updated&lt;/p&gt;

&lt;p&gt;In lib\Doctrine\Template\Listener\Sluggable.php inside preUpdate() function the first if() statement disables the unique (false) option.&lt;/p&gt;</description>
                <environment></environment>
            <key id="11193">DC-623</key>
            <summary>Impossible to create non-unique slugs</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="adwise">Adwise Internetmarketing</reporter>
                        <labels>
                    </labels>
                <created>Fri, 9 Apr 2010 08:28:02 +0000</created>
                <updated>Tue, 31 Aug 2010 11:51:12 +0000</updated>
                                    <version>1.2.2</version>
                                                <component>Sluggable</component>
                        <due></due>
                    <votes>2</votes>
                        <watches>2</watches>
                        <comments>
                    <comment id="14176" author="jmather" created="Mon, 30 Aug 2010 16:44:12 +0000"  >&lt;p&gt;Theoretically this should clear up the issue. Sorry for not having the time for a complete test at the moment,&lt;/p&gt;</comment>
                    <comment id="14178" author="webpragmatist" created="Mon, 30 Aug 2010 16:59:52 +0000"  >&lt;p&gt;The patch by Jacob doesn&apos;t work. The reason for the unique check is to bypass appending a numeric value to the end of a slug in the even two exist.&lt;/p&gt;

&lt;p&gt;It just needs to somehow be directly sent to the urlize function.&lt;/p&gt;</comment>
                    <comment id="14196" author="jmather" created="Tue, 31 Aug 2010 11:51:12 +0000"  >&lt;p&gt;I would just like to post an update after I&apos;ve been able to test:&lt;/p&gt;

&lt;p&gt;The only functionality that i found actually broken was updating a slug with unique set to false.&lt;/p&gt;

&lt;p&gt;The reason was the wrapped if.&lt;/p&gt;

&lt;p&gt;If you set unique to false, slugs will still fail to update as canUpdate must also be set to true.&lt;/p&gt;

&lt;p&gt;The patch, so far as I can determine, does correct the underlying issue if a slug failing to update when unique is false and canUpdate is true.&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                    <attachment id="10750" name="dc-623.patch" size="1661" author="jmather" created="Mon, 30 Aug 2010 16:44:12 +0000" />
                </attachments>
            <subtasks>
        </subtasks>
        </item>

<item>
            <title>[DC-728] Updating slug in I18N behaviour yields non-unique slug</title>
                <link>http://www.doctrine-project.org/jira/browse/DC-728</link>
                <project id="10031" key="DC">Doctrine 1</project>
                        <description>&lt;p&gt;There seems to be a bug in the way, doctrine tries to find a unique slug for a table that is I18N-enabled and has a slug in it.&lt;/p&gt;

&lt;p&gt;Following example:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;Problem:
  actAs:
    I18n:
      fields: [name]
      actAs:
        Sluggable: { fields: [name], uniqueBy: [lang, name], canUpdate: true }
  columns:
    name: { type: string(255), notnull: true }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Now, if we insert a new entry, the slug get&apos;s created as expected. If we now insert another entry that would yield the same slug, the slug is made unique by adding the postfix as expected - all well so far.&lt;/p&gt;

&lt;p&gt;Now, if we try to update the entry with the slug with the postfix, what i think is an error happens (Excerpt from Sluggable.php, lib/Doctrine/Template/Listener/Sluggable.php):&lt;/p&gt;

&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
public function getUniqueSlug($record, $slugFromFields)
...
if ($record-&amp;gt;exists()) {
            $identifier = $record-&amp;gt;identifier();
            $whereString .= &apos; AND r.&apos; . implode(&apos; != ? AND r.&apos;, $table-&amp;gt;getIdentifierColumnNames()) . &apos; != ?&apos;;
            $whereParams = array_merge($whereParams, array_values($identifier));
        }

        foreach ($this-&amp;gt;_options[&apos;uniqueBy&apos;] as $uniqueBy) {
            if (is_null($record-&amp;gt;$uniqueBy)) {
                $whereString .= &apos; AND r.&apos;.$uniqueBy.&apos; IS NULL&apos;;
            } else {
                $whereString .= &apos; AND r.&apos;.$uniqueBy.&apos; = ?&apos;;
                $value = $record-&amp;gt;$uniqueBy;
                if ($value instanceof Doctrine_Record) {
                    $value = current((array) $value-&amp;gt;identifier());
                }
                $whereParams[] = $value;
            }
        }
...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;So, the $record-&amp;gt;exists() check evaluates to true and $table-&amp;gt;getIdentifierColumnNames() yields the fields id and lang, so the whereString is something like&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
AND r.id != ? AND r.lang != ?
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;Now for the problematic part:&lt;br/&gt;
uniqueBy is lang and name; so the code adds to the whereString:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
AND r.lang = ? AND r.name = ?
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 

&lt;p&gt;So the resulting whereString has something like&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt; 
r.lang != ? AND r.lang = ?
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt; 
&lt;p&gt;which will never yield a result in my eyes, thus, the postfix is never incremented and the slug defaults to the the slug of name without postfix.&lt;/p&gt;</description>
                <environment>Symfony 1.4.5&lt;br/&gt;
Doctrine ORM</environment>
            <key id="11474">DC-728</key>
            <summary>Updating slug in I18N behaviour yields non-unique slug</summary>
                <type id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/issuetypes/bug.png">Bug</type>
                                <priority id="3" iconUrl="http://www.doctrine-project.org/jira/images/icons/priorities/major.png">Major</priority>
                    <status id="1" iconUrl="http://www.doctrine-project.org/jira/images/icons/statuses/open.png">Open</status>
                    <resolution id="-1">Unresolved</resolution>
                                <assignee username="jwage">Jonathan H. Wage</assignee>
                                <reporter username="vsknight">Florian Aschenbrenner</reporter>
                        <labels>
                    </labels>
                <created>Fri, 11 Jun 2010 05:35:43 +0000</created>
                <updated>Tue, 5 Oct 2010 11:28:43 +0000</updated>
                                    <version>1.2.0</version>
                <version>1.2.1</version>
                <version>1.2.2</version>
                                                <component>I18n</component>
                <component>Sluggable</component>
                        <due></due>
                    <votes>5</votes>
                        <watches>5</watches>
                        <comments>
                    <comment id="13408" author="rodrigobb" created="Thu, 24 Jun 2010 13:11:47 +0000"  >&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;We&apos;ve also found this problem and make a temporal workaround. But maybe our workaround can give someone an idea on how to fix the bug so I&apos;m pasting the changed code here&lt;/p&gt;

&lt;p&gt;In file &lt;em&gt;sfDoctrinePlugin\lib\vendor\doctrine\Doctrine\Template\Listener\Sluggable.php&lt;/em&gt; (getUniqueSlug method)&lt;/p&gt;

&lt;p&gt;Replace&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($record-&amp;gt;exists()) {
  $identifier = $record-&amp;gt;identifier();
  $whereString .= &apos; AND r.&apos; . implode(&apos; != ? AND r.&apos;, $table-&amp;gt;getIdentifierColumnNames()) . &apos; != ?&apos;;
  $whereParams = array_merge($whereParams, array_values($identifier));
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($record-&amp;gt;exists()) {
  $identifier = $record-&amp;gt;identifier();
  $commonFields = array_uintersect($table-&amp;gt;getIdentifierColumnNames(), $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_options[&apos;uniqueBy&apos;], &lt;span class=&quot;code-quote&quot;&gt;&quot;strcasecmp&quot;&lt;/span&gt;);
  foreach ($commonFields as $key =&amp;gt; $value)
    unset ($identifier[$value]);
  
  $whereFields = array_diff($table-&amp;gt;getIdentifierColumnNames(), $&lt;span class=&quot;code-keyword&quot;&gt;this&lt;/span&gt;-&amp;gt;_options[&apos;uniqueBy&apos;]);
  $whereString .= &apos; AND r.&apos; . implode(&apos; != ? AND r.&apos;, $whereFields) . &apos; != ?&apos;;
  $whereParams = array_merge($whereParams, array_values($identifier));
}
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</comment>
                    <comment id="14532" author="caponica" created="Tue, 5 Oct 2010 11:28:43 +0000"  >&lt;p&gt;Rodrigo, I think the solution is simpler than you might expect...&lt;/p&gt;

&lt;p&gt;The problem is that it is doing an AND where it should be doing an OR to find records other than the current one.&lt;/p&gt;

&lt;p&gt;So, you just need to replace this part of Sluggable::getUniqueSlug():&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-style: solid;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-style: solid;&quot;&gt;&lt;b&gt;Sluggable::getUniqueSlug()&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;...
        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($record-&amp;gt;exists()) {
            $identifier = $record-&amp;gt;identifier();
            $whereString .= &apos; AND r.&apos; . implode(&apos; != ? AND r.&apos;, $table-&amp;gt;getIdentifierColumnNames()) . &apos; != ?&apos;;
            $whereParams = array_merge($whereParams, array_values($identifier));
        }
...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;With this code (the 3rd line has extra brackets and OR instead of AND):&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-style: solid;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeHeader panelHeader&quot; style=&quot;border-bottom-width: 1px;border-bottom-style: solid;&quot;&gt;&lt;b&gt;Sluggable::getUniqueSlug() (modified)&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;        &lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; ($record-&amp;gt;exists()) {
            $identifier = $record-&amp;gt;identifier();
            $whereString .= &apos; AND (r.&apos; . implode(&apos; != ? OR r.&apos;, $table-&amp;gt;getIdentifierColumnNames()) . &apos; != ?)&apos;;
            $whereParams = array_merge($whereParams, array_values($identifier));
        }
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;In more detail, the WHERE clause being built up is saying: &lt;br/&gt;
&quot;find me records WHERE (the slug begins with the same string) AND (it&apos;s not the same record) AND (the other key uniqueBy values are the same)&quot;&lt;/p&gt;

&lt;p&gt;However, to check that it&apos;s not the same record you just need one of the key values to be different (not all of them) so the check should be something like:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;... AND (p.id != &apos;2&apos; OR p.lang != &apos;en&apos;) ...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;instead of:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;... AND p.id != &apos;2&apos; AND p.lang != &apos;en&apos; ...
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The modification to the code as stated above generates queries that look like this, which I&apos;m pretty sure is correct:&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;... WHERE (p.url LIKE &apos;foo%&apos; AND (p.id != &apos;2&apos; OR p.lang != &apos;en&apos;) AND p.lang = &apos;en&apos; AND p.other_uniqueby_field = &apos;1&apos;)
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;


&lt;p&gt;C&lt;/p&gt;</comment>
                </comments>
                    <attachments>
                </attachments>
            <subtasks>
        </subtasks>
        </item>
</channel>
</rss>