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

Small improvement for query against sessions table in acp_users.php

    Details

    • Type: Improvement
    • Status: Unverified Fix
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.0.7-PL1
    • Fix Version/s: 3.0.8-RC1
    • Component/s: ACP
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: