Browse Source

! There's no need to sort the spider table either.

Signed-off-by: Peter Spicer <sleeping@myperch.org>
Peter Spicer 11 years ago
parent
commit
dd0a33d06d

+ 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');
-}
-
 ?>

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

@@ -279,9 +279,6 @@ function smf_db_query($identifier, $db_string, $db_values = array(), $connection
 		'alter_table_icons' => array(
 			'~(.+)~' => '',
 		),
-		'alter_table_spiders' => array(
-			'~(.+)~' => '',
-		),
 		'ban_suggest_error_ips' => array(
 			'~RLIKE~' => '~',
 			'~\\.~' => '\.',
@@ -333,9 +330,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]))