Browse Source

Merge pull request #1136 from Arantor/release-2.1

Soft ordering is so much more reliable than hard ordering
Arantor 11 years ago
parent
commit
4ab1e19fd3

+ 7 - 41
Sources/ManageSearchEngines.php

@@ -428,10 +428,8 @@ function EditSpider()
 				array('id_spider')
 			);
 
-		// Order by user agent length.
-		sortSpiderTable();
 
-		cache_put_data('spider_search', null, 300);
+		cache_put_data('spider_search', null);
 		recacheSpiderNames();
 
 		redirectexit('action=admin;area=sengines;sa=spiders');
@@ -483,12 +481,13 @@ function SpiderCheck()
 		unset($_SESSION['id_robot']);
 	$_SESSION['robot_check'] = time();
 
-	// We cache the spider data for five minutes if we can.
-	if (($spider_data = cache_get_data('spider_search', 300)) === null)
+	// We cache the spider data for ten minutes if we can.
+	if (($spider_data = cache_get_data('spider_search', 600)) === null)
 	{
-		$request = $smcFunc['db_query']('spider_check', '
+		$request = $smcFunc['db_query']('', '
 			SELECT id_spider, user_agent, ip_info
-			FROM {db_prefix}spiders',
+			FROM {db_prefix}spiders
+			ORDER BY LENGTH(user_agent) DESC',
 			array(
 			)
 		);
@@ -497,7 +496,7 @@ function SpiderCheck()
 			$spider_data[] = $row;
 		$smcFunc['db_free_result']($request);
 
-		cache_put_data('spider_search', $spider_data, 300);
+		cache_put_data('spider_search', $spider_data, 600);
 	}
 
 	if (empty($spider_data))
@@ -1103,37 +1102,4 @@ function recacheSpiderNames()
 	updateSettings(array('spider_name_cache' => serialize($spiders)));
 }
 
-/**
- * Sort the search engine table by user agent name to avoid misidentification of engine.
- */
-function sortSpiderTable()
-{
-	global $smcFunc;
-
-	db_extend('packages');
-
-	// Add a sorting column.
-	$smcFunc['db_add_column']('{db_prefix}spiders', array('name' => 'temp_order', 'size' => 8, 'type' => 'mediumint', 'null' => false));
-
-	// Set the contents of this column.
-	$smcFunc['db_query']('set_spider_order', '
-		UPDATE {db_prefix}spiders
-		SET temp_order = LENGTH(user_agent)',
-		array(
-		)
-	);
-
-	// Order the table by this column.
-	$smcFunc['db_query']('alter_table_spiders', '
-		ALTER TABLE {db_prefix}spiders
-		ORDER BY temp_order DESC',
-		array(
-			'db_error_skip' => true,
-		)
-	);
-
-	// Remove the sorting column.
-	$smcFunc['db_remove_column']('{db_prefix}spiders', 'temp_order');
-}
-
 ?>

+ 4 - 11
Sources/ManageSmileys.php

@@ -1708,7 +1708,8 @@ function EditMessageIcons()
 		SELECT m.id_icon, m.title, m.filename, m.icon_order, m.id_board, b.name AS board_name
 		FROM {db_prefix}message_icons AS m
 			LEFT JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
-		WHERE ({query_see_board} OR b.id_board IS NULL)',
+		WHERE ({query_see_board} OR b.id_board IS NULL)
+		ORDER BY m.icon_order',
 		array(
 		)
 	);
@@ -1829,15 +1830,6 @@ function EditMessageIcons()
 			}
 		}
 
-		// Sort by order, so it is quicker :)
-		$smcFunc['db_query']('alter_table_icons', '
-			ALTER TABLE {db_prefix}message_icons
-			ORDER BY icon_order',
-			array(
-				'db_error_skip' => true,
-			)
-		);
-
 		// Unless we're adding a new thing, we'll escape
 		if (!isset($_POST['add']))
 			redirectexit('action=admin;area=smileys;sa=editicons');
@@ -1980,7 +1972,8 @@ function list_getMessageIcons($start, $items_per_page, $sort)
 		SELECT m.id_icon, m.title, m.filename, m.icon_order, m.id_board, b.name AS board_name
 		FROM {db_prefix}message_icons AS m
 			LEFT JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
-		WHERE ({query_see_board} OR b.id_board IS NULL)',
+		WHERE ({query_see_board} OR b.id_board IS NULL)
+		ORDER BY m.icon_order',
 		array(
 		)
 	);

+ 1 - 1
Sources/ScheduledTasks.php

@@ -1199,7 +1199,7 @@ function loadEssentialThemeData()
 			AND id_theme IN (1, {int:theme_guests})',
 		array(
 			'no_member' => 0,
-			'theme_guests' => $modSettings['theme_guests'],
+			'theme_guests' => !empty($modSettings['theme_guests']) ? $modSettings['theme_guests'] : 1,
 		)
 	);
 	while ($row = $smcFunc['db_fetch_assoc']($result))

+ 0 - 9
Sources/Subs-Db-postgresql.php

@@ -276,12 +276,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'alter_table_boards' => array(
 			'~(.+)~' => '',
 		),
-		'alter_table_icons' => array(
-			'~(.+)~' => '',
-		),
-		'alter_table_spiders' => array(
-			'~(.+)~' => '',
-		),
 		'ban_suggest_error_ips' => array(
 			'~RLIKE~' => '~',
 			'~\\.~' => '\.',
@@ -333,9 +327,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'order_by_board_order' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),
-		'spider_check' => array(
-			'~(.)$~' => '$1 ORDER BY LENGTH(user_agent) DESC',
-		),
 		'unread_replies' => array(
 			'~SELECT\\s+DISTINCT\\s+t.id_topic~' => 'SELECT t.id_topic, {raw:sort}',
 		),

+ 0 - 3
Sources/Subs-Db-sqlite.php

@@ -320,9 +320,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'order_by_board_order' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),
-		'spider_check' => array(
-			'~(.)$~' => '$1 ORDER BY LENGTH(user_agent) DESC',
-		),
 	);
 
 	if (isset($replacements[$identifier]))

+ 0 - 3
Sources/Subs-Db-sqlite3.php

@@ -360,9 +360,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'order_by_board_order' => array(
 			'~(.)$~' => '$1 ORDER BY b.board_order',
 		),
-		'spider_check' => array(
-			'~(.)$~' => '$1 ORDER BY LENGTH(user_agent) DESC',
-		),
 	);
 
 	if (isset($replacements[$identifier]))

+ 2 - 1
Sources/Subs-Editor.php

@@ -1403,7 +1403,8 @@ function getMessageIcons($board_id)
 			$request = $smcFunc['db_query']('select_message_icons', '
 				SELECT title, filename
 				FROM {db_prefix}message_icons
-				WHERE id_board IN (0, {int:board_id})',
+				WHERE id_board IN (0, {int:board_id})
+				ORDER BY icon_order',
 				array(
 					'board_id' => $board_id,
 				)

+ 1 - 1
Themes/default/ManageSmileys.template.php

@@ -470,7 +470,7 @@ function template_editicon()
 							<strong><label for="icon_filename">', $txt['smileys_filename'], '</label>: </strong><br /><span class="smalltext">', $txt['icons_filename_all_png'], '</span>
 						</dt>
 						<dd>
-							<input type="text" name="icon_filename" id="icon_filename" value="', !empty($context['icon']['filename']) ? $context['icon']['filename'] . '.gif' : '', '" class="input_text" />
+							<input type="text" name="icon_filename" id="icon_filename" value="', !empty($context['icon']['filename']) ? $context['icon']['filename'] . '.png' : '', '" class="input_text" />
 						</dd>
 						<dt>
 							<strong><label for="icon_description">', $txt['smileys_description'], '</label>: </strong>