Gentoo Archives: gentoo-commits

From: "Tom Knight (tomk)" <tomk@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-projects commit in forums/htdocs: search.php
Date: Tue, 01 Jul 2008 20:33:59
Message-Id: E1KDmXx-0000f6-LR@stork.gentoo.org
1 tomk 08/07/01 20:33:53
2
3 Modified: search.php
4 Log:
5 Prevent searches hitting the php memory limit
6
7 Revision Changes Path
8 1.23 forums/htdocs/search.php
9
10 file : http://sources.gentoo.org/viewcvs.py/gentoo-projects/forums/htdocs/search.php?rev=1.23&view=markup
11 plain: http://sources.gentoo.org/viewcvs.py/gentoo-projects/forums/htdocs/search.php?rev=1.23&content-type=text/plain
12 diff : http://sources.gentoo.org/viewcvs.py/gentoo-projects/forums/htdocs/search.php?r1=1.22&r2=1.23
13
14 Index: search.php
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo-projects/forums/htdocs/search.php,v
17 retrieving revision 1.22
18 retrieving revision 1.23
19 diff -u -r1.22 -r1.23
20 --- search.php 19 Aug 2007 13:20:17 -0000 1.22
21 +++ search.php 1 Jul 2008 20:33:53 -0000 1.23
22 @@ -6,7 +6,7 @@
23 * copyright : (C) 2001 The phpBB Group
24 * email : support@×××××.com
25 *
26 - * $Id: search.php,v 1.22 2007/08/19 13:20:17 tomk Exp $
27 + * $Id: search.php,v 1.23 2008/07/01 20:33:53 tomk Exp $
28 *
29 *
30 ***************************************************************************/
31 @@ -636,31 +636,16 @@
32 // Finish building query (for all combinations)
33 // and run it ...
34 //
35 - $sql = "SELECT session_id
36 - FROM " . SESSIONS_TABLE;
37 - if ( $result = $db->sql_query($sql) )
38 - {
39 - $delete_search_ids = array();
40 - while( $row = $db->sql_fetchrow($result) )
41 - {
42 - $delete_search_ids[] = "'" . $row['session_id'] . "'";
43 - }
44
45 - if ( count($delete_search_ids) )
46 - {
47 - $sql = "DELETE FROM " . SEARCH_TABLE . "
48 - WHERE session_id NOT IN (" . phpbb_implode(", ", $delete_search_ids) . ")";
49 - if ( !$result = $db->sql_query($sql) )
50 - {
51 - message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql);
52 - }
53 -
54 - // 2007-08-19 tomk - these vars aren't used any more so free up some memory
55 - unset($delete_search_ids);
56 - unset($sql);
57 - }
58 + // 2008-07-01 tomk - use subquery to prevent hitting memory limit
59 + $sql = "DELETE FROM " . SEARCH_TABLE . "
60 + WHERE session_id NOT IN (SELECT session_id FROM " . SESSIONS_TABLE . ")";
61 + if ( !$result = $db->sql_query($sql) )
62 + {
63 + message_die(GENERAL_ERROR, 'Could not delete old search id sessions', '', __LINE__, __FILE__, $sql);
64 + }
65 + }
66 }
67 -
68 //
69 // Store new result data
70 //
71
72
73
74 --
75 gentoo-commits@l.g.o mailing list