Uploaded image for project: 'phpBB'
  1. phpBB
  2. PHPBB-14170

Fix mcp_change_poster_after event

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1.7-RC1
    • 3.1.6
    • Events, Extensions
    • None

      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).

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

              Created:
              Updated:
              Resolved: