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

Fix mcp_change_poster_after event

    XMLWordPrintable

Details

    Description

      Assume the following code in an extension:

      public function mcp_change_poster_after($event)
      {
          $userdata = $event['userdata'];
          $post_info = $event['post_info'];
       
          $sql = 'UPDATE ' . USERS_TABLE . '
              SET user_column = user_column - 1
              WHERE user_id = ' . (int) $post_info['user_id'];
          $this->db->sql_query($sql);
       
          $sql = 'UPDATE ' . USERS_TABLE . '
              SET user_column = user_column + 1
              WHERE user_id = ' . (int) $userdata['user_id'];
          $this->db->sql_query($sql);
      }
      

      The mcp_change_poster_after event occurs AFTER this line:

      $post_info = phpbb_get_post_data(array($post_id), false, true);
      

      This causes an undesirable affect on the event - userdata and post_info are now the same. You can see this by var_dumping the arrays and comparing. So, we need to move the event (otherwise, it's useless).

      Attachments

        Activity

          People

            Marc Marc
            kinerity Kailey Truscott [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: