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

Suboptimal number of query complexity in phpbb_notification_manager::get_global_subscriptions()

    Details

    • Type: Bug
    • Status: Unverified Fix
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-dev
    • Fix Version/s: 3.1.0-RC1
    • Component/s: Notification System
    • Labels:
      None

      Description

      Query in a two-dimensional loop. This already accounts for 1/2 of the queries on https://area51.phpbb.com/phpBB/ucp.php?i=ucp_notifications&mode=notification_options and scales poorly when new notification methods or types are added.

      		foreach ($this->get_subscription_types() as $group_name => $types)
      		{
      			foreach ($types as $id => $type)
      			{
      				$sql = 'SELECT method, notify
      					FROM ' . $this->user_notifications_table . '
      					WHERE user_id = ' . (int) $user_id . "
      						AND item_type = '" . $this->db->sql_escape($id) . "'
      						AND item_id = 0";
      				$result = $this->db->sql_query($sql);
      

        Activity

        Hide
        EXreaction EXreaction [X] (Inactive) added a comment -

        Should just select the whole table for the user, I'm not sure why I did it this way originally.

        Show
        EXreaction EXreaction [X] (Inactive) added a comment - Should just select the whole table for the user, I'm not sure why I did it this way originally.
        Hide
        bantu Andreas Fischer added a comment -

        I am pretty sure what you want to do is doable in a single query that is still pretty simple. Please make sure phpbb_notification_manager::get_global_subscriptions() has code coverage so we can safely rewrite the query.

        Show
        bantu Andreas Fischer added a comment - I am pretty sure what you want to do is doable in a single query that is still pretty simple. Please make sure phpbb_notification_manager::get_global_subscriptions() has code coverage so we can safely rewrite the query.
        Hide
        bantu Andreas Fischer added a comment -

        There is some coverage from test_subscriptions() but it's not very clear from the tests what get_global_subscriptions() is supposed to return and what not.

        Show
        bantu Andreas Fischer added a comment - There is some coverage from test_subscriptions() but it's not very clear from the tests what get_global_subscriptions() is supposed to return and what not.

          People

          • Assignee:
            dhruv.goel92 Dhruv Goel
            Reporter:
            bantu Andreas Fischer
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development