summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-06-12 13:05:40 -0700
committerBharat Mediratta <bharat@menalto.com>2010-06-12 13:05:40 -0700
commita4586bc0c01fac6e86163fd119aaa64d95fb5e8e (patch)
treef337d79809bcbf0f803b27fb6a22ae1a69aae5ba
parentcb01f4017d70a7d73273052b424e8b78b794bc1c (diff)
Revert "Fix for ticket #1118. The item validation was flagging duplicate slugs as errors. There was already code in the item save to insure that any"
This introduces a bug where you can create two items with the same slug. This reverts commit cb01f4017d70a7d73273052b424e8b78b794bc1c.
-rw-r--r--modules/gallery/models/item.php7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/gallery/models/item.php b/modules/gallery/models/item.php
index a4f264bb..009457c1 100644
--- a/modules/gallery/models/item.php
+++ b/modules/gallery/models/item.php
@@ -767,6 +767,13 @@ class Item_Model extends ORM_MPTT {
public function valid_slug(Validation $v, $field) {
if (preg_match("/[^A-Za-z0-9-_]/", $this->slug)) {
$v->add_error("slug", "not_url_safe");
+ } else if (db::build()
+ ->from("items")
+ ->where("parent_id", "=", $this->parent_id)
+ ->where("id", "<>", $this->id)
+ ->where("slug", "=", $this->slug)
+ ->count_records()) {
+ $v->add_error("slug", "conflict");
}
}