Browse Source

! Lots of bugfixes related to previous commit

Signed-off-by: Michael Eshom <[email protected]>
Michael Eshom 11 năm trước cách đây
mục cha
commit
31fdf9112d

+ 7 - 7
Sources/PersonalMessage.php

@@ -2673,10 +2673,10 @@ function MessageActionsApply()
 				$inserts = array();
 				foreach($labels_to_add AS $label)
 				{
-					$inserts[] = "($row[id_pm], $label)";
+					$inserts[] = array($row['id_pm'], $label);
 				}
 				
-				$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm', 'id_label'), $inserts, array());
+				$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm' => 'int', 'id_label' => 'int'), $inserts, array());
 			}
 		}
 		$smcFunc['db_free_result']($request);
@@ -3196,10 +3196,10 @@ function ManageLabels()
 			$inserts = array();
 			foreach($labels_to_add AS $label)
 			{
-				$inserts[] = '($label, $user_info[id]}';
+				$inserts[] = array($label, $user_info['id']);
 			}
 			
-			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member', 'name'), $inserts, array());
+			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array());
 		}
 		
 		// Update existing labels as needed
@@ -3910,12 +3910,12 @@ function ApplyRules($all_messages = false)
 
 			$inserts = array();
 			// Now we insert the label info
-			foreach($realLabels AS $a_label)
+			foreach($realLabels as $a_label)
 			{
-				$inserts[] = "($user_info[id], $pm, $label)";
+				$inserts[] = array($user_info['id'], $pm, $label);
 			}
 
-			$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm', 'id_label'), $inserts, array());
+			$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm' => 'int', 'id_label' => 'int'), $inserts, array());
 		}
 	}
 }

+ 15 - 12
other/upgrade_2-1_mysql.sql

@@ -531,8 +531,8 @@ $request = upgrade_query("
 			INSERT INTO {$db_prefix}permissions
 				(id_group, permission, add_deny)
 			VALUES
-				" . implode(',', $inserts));
-		}
+				" . implode(',', $inserts)
+		);
 	}
 ---}
 ---#
@@ -563,7 +563,8 @@ $request = upgrade_query("
 			INSERT INTO {$db_prefix}permissions
 				(id_group, permission, add_deny)
 			VALUES
-				" . implode(',', $inserts));
+				" . implode(',', $inserts)
+			);
 	}
 ---}
 ---#
@@ -596,8 +597,8 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 ---# Moving label info to new tables and updating rules...
 ---{
 	// First see if we still have a message_labels column
-	$results = $smcFunc['db_list_columns']('{db_prefix}_members', false);
-	if (array_key_exists('message_labels', $results))
+	$results = $smcFunc['db_list_columns']('{db_prefix}members');
+	if (in_array('message_labels', $results))
 	{
 		// They've still got it, so pull the label info
 		$get_labels = $smcFunc['db_query']('', '
@@ -621,7 +622,7 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 			{
 				// Keep track of the index of this label - we'll need that in a bit...
 				$label_info[$row['id_member']][$label] = $index;
-				$inserts[] = "($row[id_member], $label)";
+				$inserts[] = array($row['id_member'], $label);
 			}
 		}
 
@@ -629,12 +630,12 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 
 		if (!empty($inserts))
 		{
-			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member', 'name'), $inserts, array());
+			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array());
 		}
 
 		// This is the easy part - update the inbox stuff
 		$smcFunc['db_query']('', '
-			UPDATE TABLE {db_prefix}pm_recipients
+			UPDATE {db_prefix}pm_recipients
 			SET in_inbox = {int:in_inbox}
 			WHERE FIND_IN_SET({int:minusone}, message_labels)',
 			array(
@@ -683,21 +684,22 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 				if ($a_label == '-1')
 					continue;
 
-				$inserts[] = "($row[id_pm], $label_info_2[$row[id_member]][$a_label])"; 
+				$new_label_info = $label_info_2[$row['id_member']][$a_label];
+				$inserts[] = array($row['id_pm'], $new_label_info);
 			}
 		}
 
 		$smcFunc['db_free_result']($get_pm_labels);
 
 		// Insert the new data
-		$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm', 'id_label'), $inserts, array());
+		$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm' => 'int', 'id_label' => 'int'), $inserts, array());
 
 		// Final step of this ridiculously massive process
 		$get_pm_rules = $smcFunc['db_query']('', '
 			SELECT id_member, id_rule, actions
 			FROM {db_prefix}pm_rules',
 			array(
-			),
+			)
 		);
 
 		// Go through the rules, unserialize the actions, then figure out if there's anything we can use
@@ -736,4 +738,5 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 		$smcFunc['db_remove_column']('{db_prefix}members', 'message_labels');
 		$smcFunc['db_remove_column']('{db_prefix}pm_recipients', 'labels');
 	}
-}
+---}
+---#

+ 11 - 9
other/upgrade_2-1_postgresql.sql

@@ -641,7 +641,8 @@ $request = upgrade_query("
 				INSERT INTO {$db_prefix}permissions
 					(id_group, permission, add_deny)
 				VALUES
-					" . $insert);
+					" . $insert
+			);
 		}
 	}
 ---}
@@ -679,8 +680,8 @@ ADD COLUMN in_inbox smallint NOT NULL default '0';
 ---# Moving label info to new tables and updating rules...
 ---{
 	// First see if we still have a message_labels column
-	$results = $smcFunc['db_list_columns']('{db_prefix}_members', false);
-	if (array_key_exists('message_labels', $results))
+	$results = $smcFunc['db_list_columns']('{db_prefix}members', false);
+	if (in_array('message_labels', $results))
 	{
 		// They've still got it, so pull the label info
 		$get_labels = $smcFunc['db_query']('', '
@@ -712,17 +713,17 @@ ADD COLUMN in_inbox smallint NOT NULL default '0';
 
 		if (!empty($inserts))
 		{
-			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member', 'name'), $inserts, array());
+			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'string-30'), $inserts, array());
 		}
 
 		// This is the easy part - update the inbox stuff
 		$smcFunc['db_query']('', '
-			UPDATE TABLE {db_prefix}pm_recipients
+			UPDATE {db_prefix}pm_recipients
 			SET in_inbox = {int:in_inbox}
-			WHERE FIND_IN_SET({int:minusone}, message_labels)',
+			WHERE FIND_IN_SET({int:minus_one}, message_labels)',
 			array(
 				'in_inbox' => 1,
-				'minusone' => -1,
+				'minus_one' => -1,
 			)
 		);
 
@@ -766,14 +767,15 @@ ADD COLUMN in_inbox smallint NOT NULL default '0';
 				if ($a_label == '-1')
 					continue;
 
-				$inserts[] = "($row[id_pm], $label_info_2[$row[id_member]][$a_label])"; 
+				$new_label_info = $label_info_2[$row['id_member']][$a_label];
+				$inserts[] = array($row['id_pm'], $new_label_info); 
 			}
 		}
 
 		$smcFunc['db_free_result']($get_pm_labels);
 
 		// Insert the new data
-		$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm', 'id_label'), $inserts, array());
+		$smcFunc['db_insert']('', '{db_prefix}pm_labeled_messages', array('id_pm' => 'int', 'id_label' => 'int'), $inserts, array());
 
 		// Final step of this ridiculously massive process
 		$get_pm_rules = $smcFunc['db_query']('', '

+ 9 - 8
other/upgrade_2-1_sqlite.sql

@@ -657,8 +657,8 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 ---# Moving label info to new tables and updating rules...
 ---{
 	// First see if we still have a message_labels column
-	$results = $smcFunc['db_list_columns']('{db_prefix}_members', false);
-	if (array_key_exists('message_labels', $results))
+	$results = $smcFunc['db_list_columns']('{db_prefix}members');
+	if (in_array('message_labels', $results))
 	{
 		// They've still got it, so pull the label info
 		$get_labels = $smcFunc['db_query']('', '
@@ -682,7 +682,7 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 			{
 				// Keep track of the index of this label - we'll need that in a bit...
 				$label_info[$row['id_member']][$label] = $index;
-				$inserts[] = "($row[id_member], $label)";
+				$inserts[] = array($row['id_member'], $label);
 			}
 		}
 
@@ -690,17 +690,17 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 
 		if (!empty($inserts))
 		{
-			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member', 'name'), $inserts, array());
+			$smcFunc['db_insert']('', '{db_prefix}pm_labels', array('id_member' => 'int', 'name' => 'int'), $inserts, array());
 		}
 
 		// This is the easy part - update the inbox stuff
 		$smcFunc['db_query']('', '
-			UPDATE TABLE {db_prefix}pm_recipients
+			UPDATE {db_prefix}pm_recipients
 			SET in_inbox = {int:in_inbox}
-			WHERE FIND_IN_SET({int:minusone}, message_labels)',
+			WHERE FIND_IN_SET({int:minus_one}, message_labels)',
 			array(
 				'in_inbox' => 1,
-				'minusone' => -1,
+				'minus_one' => -1,
 			)
 		);
 
@@ -744,7 +744,8 @@ ADD COLUMN in_inbox tinyint(3) NOT NULL default '0';
 				if ($a_label == '-1')
 					continue;
 
-				$inserts[] = "($row[id_pm], $label_info_2[$row[id_member]][$a_label])"; 
+				$new_label_info = $label_info_2[$row['id_member']][$a_label];
+				$inserts[] = array($row['id_pm'], $new_label_info); 
 			}
 		}