Skip to content

Commit

Permalink
Merge branch 'master' of github.com:vanillaforums/Garden
Browse files Browse the repository at this point in the history
  • Loading branch information
linc committed Sep 16, 2011
2 parents ff6510b + 0cd83e0 commit 9c3ef43
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 7 deletions.
34 changes: 33 additions & 1 deletion applications/dashboard/settings/structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion applications/dashboard/views/authentication/choose.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 11 additions & 4 deletions library/database/class.dataset.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public static function Index($Data, $Columns, $Options = array()) {
* - <b>prefix</b>: The name of the prefix to give the columns. Can't be used with <b>column</b>.
* @param array $Options An array of extra options.
* - <b>sql</b>: A Gdn_SQLDriver with the child query.
* - <b>type</b>: The join type, either JOIN_INNER, JOIN_LEFT. This defaults to JOIN_INNER.
* - <b>type</b>: 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);
Expand Down Expand Up @@ -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'.");
}
Expand All @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion library/database/class.mysqldriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down

0 comments on commit 9c3ef43

Please sign in to comment.