1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Fixed _getRegistrationInputData()

Discussion in 'Resolved Bug Reports' started by Jeremy P, Sep 16, 2014.

  1. Jeremy P

    Jeremy P Well-Known Member

    In XenForo_ControllerPublic_Register the _getRegistrationInputData() method unsets some $_POST data, making it impossible for the method to be run twice properly.

    The code comments seem to acknowledge it's a bit hacky ;)

    In an add-on, I ended up doing something like this so that I could run the method without messing up when XenForo runs it the 2nd time:

    protected $_inputData = array();

    protected function 
        if (!empty(
    $this->_inputData)) {
    $this->_inputData parent::_getRegistrationInputData();

    Seems like a simple fix and it would be nice to see in core :)
  2. Mike

    Mike XenForo Developer Staff Member

    I suppose there is a situation where caching like that could interfere with something an add-on is doing. I guess that could be worked around by doing the caching in a separate function and calling that.

    I'm curious why you'd ever call the function twice in a single request though.
  3. Jeremy P

    Jeremy P Well-Known Member

    If you're extending actionRegister() with an add-on, for example, and your custom code needs access to the input data, it's really convenient to be able to call it and have access to everything.

    Then later when the custom code is done and calls the parent, XenForo calls the method again but is unable to get the password input because the honeypot fields have been unset to prevent them from being captured in logs.

    Unless you can think of a different way of going about it in the add-on?
  4. Jeremy P

    Jeremy P Well-Known Member

    Can't edit the OP but the conditional should, of course, be if (empty($this->_inputData)) { ...
  5. Nobita.Kun

    Nobita.Kun Well-Known Member

    I dont know your purpose but if want to get password I will extend to DataWriter rather that :)
  6. Jeremy P

    Jeremy P Well-Known Member

    I don't want the password. For my purposes I just need the POST data for the registration, and in an extension of the controller.

    The method does something with the password data that prevents this method from being run more than once, but the password isn't relevant to my needs.
  7. Mike

    Mike XenForo Developer Staff Member

    I have fixed this now. Just to note that it was done via a new function, _getRegistrationInputDataSafe. This ensures that if anyone has already extended _getRegistrationInputData, their values will still be written into the cache value. You should change your add-on to call the new function.
    Jeremy P likes this.
  8. Liam W

    Liam W Well-Known Member

    This happened to me, and caused a bug with one of my addons not letting people login/register because of it...

    Thanks for changing :)
    Jeremy P likes this.

Share This Page