Browse Source

! Fix invalid thumbnail sizes (per #1294)

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 years ago
parent
commit
5f3ffe0bf0
3 changed files with 93 additions and 0 deletions
  1. 31 0
      other/upgrade_2-1_mysql.sql
  2. 31 0
      other/upgrade_2-1_postgresql.sql
  3. 31 0
      other/upgrade_2-1_sqlite.sql

+ 31 - 0
other/upgrade_2-1_mysql.sql

@@ -177,6 +177,37 @@ unset($_GET['a']);
 ---}
 ---#
 
+---# Fixing invalid sizes on attachments
+---{
+$attachs = array();
+// If id_member = 0, then it's not an avatar
+// If attachment_type = 0, then it's also not a thumbnail
+// Theory says there shouldn't be *that* many of these
+$request = $smcFunc['db_query']('', '
+	SELECT id_attach, mime_type, width, height
+	FROM {db_prefix}attachments
+	WHERE id_member = 0
+		AND attachment_type = 0');
+while ($row = $smcFunc['db_fetch_assoc']($request))
+{
+	if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
+		$attachs[] = $row['id_attach'];
+}
+$smcFunc['db_free_result']($request);
+
+if (!empty($attachs))
+	$smcFunc['db_query']('', '
+		UPDATE {db_prefix}attachments
+		SET width = 0,
+			height = 0
+		WHERE id_attach IN ({array_int:attachs})',
+		array(
+			'attachs' => $attachs,
+		)
+	);
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for IPv6...
 /******************************************************************************/

+ 31 - 0
other/upgrade_2-1_postgresql.sql

@@ -179,6 +179,37 @@ unset($_GET['a']);
 ---}
 ---#
 
+---# Fixing invalid sizes on attachments
+---{
+$attachs = array();
+// If id_member = 0, then it's not an avatar
+// If attachment_type = 0, then it's also not a thumbnail
+// Theory says there shouldn't be *that* many of these
+$request = $smcFunc['db_query']('', '
+	SELECT id_attach, mime_type, width, height
+	FROM {db_prefix}attachments
+	WHERE id_member = 0
+		AND attachment_type = 0');
+while ($row = $smcFunc['db_fetch_assoc']($request))
+{
+	if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
+		$attachs[] = $row['id_attach'];
+}
+$smcFunc['db_free_result']($request);
+
+if (!empty($attachs))
+	$smcFunc['db_query']('', '
+		UPDATE {db_prefix}attachments
+		SET width = 0,
+			height = 0
+		WHERE id_attach IN ({array_int:attachs})',
+		array(
+			'attachs' => $attachs,
+		)
+	);
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for IPv6...
 /******************************************************************************/

+ 31 - 0
other/upgrade_2-1_sqlite.sql

@@ -177,6 +177,37 @@ unset($_GET['a']);
 ---}
 ---#
 
+---# Fixing invalid sizes on attachments
+---{
+$attachs = array();
+// If id_member = 0, then it's not an avatar
+// If attachment_type = 0, then it's also not a thumbnail
+// Theory says there shouldn't be *that* many of these
+$request = $smcFunc['db_query']('', '
+	SELECT id_attach, mime_type, width, height
+	FROM {db_prefix}attachments
+	WHERE id_member = 0
+		AND attachment_type = 0');
+while ($row = $smcFunc['db_fetch_assoc']($request))
+{
+	if (($row['width'] > 0 || $row['height'] > 0) && strpos($row['mime_type'], 'image') !== 0)
+		$attachs[] = $row['id_attach'];
+}
+$smcFunc['db_free_result']($request);
+
+if (!empty($attachs))
+	$smcFunc['db_query']('', '
+		UPDATE {db_prefix}attachments
+		SET width = 0,
+			height = 0
+		WHERE id_attach IN ({array_int:attachs})',
+		array(
+			'attachs' => $attachs,
+		)
+	);
+---}
+---#
+
 /******************************************************************************/
 --- Adding support for IPv6...
 /******************************************************************************/