diff --git a/applications/dashboard/settings/structure.php b/applications/dashboard/settings/structure.php
index 0f7d89c8aee..694b5b9724a 100755
--- a/applications/dashboard/settings/structure.php
+++ b/applications/dashboard/settings/structure.php
@@ -440,9 +440,41 @@
$Construct->Table('User')->DropColumn('PhotoID');
}
+// This is a fix for erroneos unique constraint.
+if ($Construct->TableExists('Tag')) {
+ $Db = Gdn::Database();
+ $Px = Gdn::Database()->DatabasePrefix;
+
+ $DupTags = Gdn::SQL()
+ ->Select('Name')
+ ->Select('TagID', 'min', 'TagID')
+ ->Select('TagID', 'count', 'CountTags')
+ ->From('Tag')
+ ->GroupBy('Name')
+ ->Having('CountTags >', 1)
+ ->Get()->ResultArray();
+
+ foreach ($DupTags as $Row) {
+ $Name = $Row['Name'];
+ $TagID = $Row['TagID'];
+ // Get the tags that need to be deleted.
+ $DeleteTags = Gdn::SQL()->GetWhere('Tag', array('Name' => $Name, 'TagID <> ' => $TagID))->ResultArray();
+ foreach ($DeleteTags as $DRow) {
+ // Update all of the discussions to the new tag.
+ Gdn::SQL()->Options('Ignore', TRUE)->Put(
+ 'TagDiscussion',
+ array('TagID' => $TagID),
+ array('TagID' => $DRow['TagID']));
+
+ // Delete the tag.
+ Gdn::SQL()->Delete('Tag', array('TagID' => $DRow['TagID']));
+ }
+ }
+}
+
$Construct->Table('Tag')
->PrimaryKey('TagID')
- ->Column('Name', 'varchar(255)', 'unique')
+ ->Column('Name', 'varchar(255)', FALSE, 'unique')
->Column('Type', 'varchar(10)', NULL, 'index')
->Column('InsertUserID', 'int', TRUE, 'key')
->Column('DateInserted', 'datetime')
diff --git a/applications/dashboard/views/authentication/choose.php b/applications/dashboard/views/authentication/choose.php
index d32d47f1173..32e3dc6531f 100644
--- a/applications/dashboard/views/authentication/choose.php
+++ b/applications/dashboard/views/authentication/choose.php
@@ -61,7 +61,7 @@
$('select#Form_Garden-dot-Authentication-dot-Chooser').bind('change',function(e){
var Chooser = $(e.target);
var SliceElement = $('div.AuthenticationConfigure');
- var SliceObj = SliceElement.attr('Slice');
+ var SliceObj = SliceElement.prop('Slice');
var ChooserVal = Chooser.val();
var ChosenURL = (ConfigureList[ChooserVal]) ? ConfigureList[ChooserVal] : ((ConfigureList[ChooserVal] != 'undefined') ? '/dashboard/authentication/configure/'+ChooserVal : false);
diff --git a/library/database/class.dataset.php b/library/database/class.dataset.php
index 25ecd1c2a9b..5d2862e2228 100755
--- a/library/database/class.dataset.php
+++ b/library/database/class.dataset.php
@@ -250,7 +250,7 @@ public static function Index($Data, $Columns, $Options = array()) {
* - prefix: The name of the prefix to give the columns. Can't be used with column.
* @param array $Options An array of extra options.
* - sql: A Gdn_SQLDriver with the child query.
- * - type: The join type, either JOIN_INNER, JOIN_LEFT. This defaults to JOIN_INNER.
+ * - type: The join type, either JOIN_INNER, JOIN_LEFT. This defaults to JOIN_LEFT.
*/
public static function Join(&$Data, $Columns, $Options = array()) {
$Options = array_change_key_case($Options);
@@ -321,7 +321,7 @@ public static function Join(&$Data, $Columns, $Options = array()) {
if (isset($ChildColumn))
$ParentColumn = $ChildColumn;
elseif (isset($Table))
- $ChildColumn = $Table.'ID';
+ $ParentColumn = $Table.'ID';
else
throw Exception("Gdn_DataSet::Join(): Missing 'parent' argument'.");
}
@@ -348,11 +348,18 @@ public static function Join(&$Data, $Columns, $Options = array()) {
$Sql->Select("$TableAlias.$ChildColumn");
// Get the IDs to generate an in clause with.
- $IDs = ConsolidateArrayValuesByKey($Data, $ParentColumn);
+ $IDs = array();
+ foreach ($Data as $Row) {
+ $Value = GetValue($ParentColumn, $Row);
+ if ($Value)
+ $IDs[$Value] = TRUE;
+ }
+
+ $IDs = array_keys($IDs);
$Sql->WhereIn($ChildColumn, $IDs);
$ChildData = $Sql->Get()->ResultArray();
- $ChildData = self::Index($ChildData, $ChildColumn, array('unique' => isset($ColumnPrefix)));
+ $ChildData = self::Index($ChildData, $ChildColumn, array('unique' => GetValue('unique', $Options, isset($ColumnPrefix))));
$NotFound = array();
diff --git a/library/database/class.mysqldriver.php b/library/database/class.mysqldriver.php
index bbd347be483..8a0775c4c68 100644
--- a/library/database/class.mysqldriver.php
+++ b/library/database/class.mysqldriver.php
@@ -306,7 +306,7 @@ public function GetUpdate($Tables, $Data, $Where) {
$Sets[] = $Field." = ".$Value;
}
- $sql = 'update '.$this->_FromTables($Tables);
+ $sql = 'update '.($this->Options('Ignore') ? 'ignore ' : '').$this->_FromTables($Tables);
if (count($this->_Joins) > 0) {
$sql .= "\n";