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

core.posting_modify_template_vars pass some variables to listeners

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1.0-b3
    • 3.1.0-b2
    • Events

      Originally posted here: https://area51.phpbb.com/phpBB/viewtopic.php?f=111&t=45379

      In posting.php the event dispatcher is called directly triggering the core.posting_modify_template_vars event, but the event doesn't have any data, so it's impossible to modify the template array within the event listener.

      Instead the array should be assigned to a variable and then the event should be triggered with the variable.

      The flow has changed such that the template variables are assigned to an array first, which is then passed to the event listener, ofter that the template array is assigned to the template object.

      Around line 1477 in the beta:
      Replace:

      $template->assign_vars(array( ... ));
      $phpbb_dispatcher->dispatch('core.posting_modify_template_vars');
      

      With:

      $template_array = array(...);
      $vars = array('template_array');
      extract($phpbb_dispatcher->trigger_event('core.posting_modify_template_vars', compact($vars)));
      $template->assign_vars(array( ... ));
      

      Not shown, but if possible please send the current forum and topic info to the event handler. Basically, I need to know what the current forum is, and whether or not the template is displaying a new post form, or edit the first post of a topic (not a reply).

            nickvergessen Joas Schilling
            joelk2 joelk2 [X] (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: