Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-9536

Small improvement for query against sessions table in acp_users.php

    XMLWordPrintable

Details

    • Improvement
    • Status: Unverified Fix (View Workflow)
    • Trivial
    • Resolution: Fixed
    • 3.0.7-PL1
    • 3.0.8-RC1
    • ACP
    • None

    Description

      In includes/acp/acp_users.php there is this query (twice).

      		// Generate content for all modes
      		$sql = 'SELECT u.*, s.*
      			FROM ' . USERS_TABLE . ' u
      				LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id)
      			WHERE u.user_id = ' . $user_id . '
      			ORDER BY s.session_time DESC';
      		$result = $db->sql_query($sql);
      		$user_row = $db->sql_fetchrow($result);
      		$db->sql_freeresult($result);
      

      Note that only row is being fetched.

      If it is guaranteed that only one row matches the query criteria, the ORDER BY can be omitted.
      If there can be more than one row, $db->sql_query_limit($sql, 1); can be used.

      Attachments

        Activity

          People

            bantu Andreas Fischer
            bantu Andreas Fischer
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: