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

Blob content in xf_option table

Discussion in 'XenForo Development Discussions' started by AndyB, May 6, 2016.

  1. AndyB

    AndyB Well-Known Member

    Hello,

    An admin I'm helping indicated my Register Email add-on was throwing an error during registration. What I found was the option_value field is different between his table and my test forum:

    In his database the requireLocation is not present
    pic001.jpg

    On my database the requireLocation is present
    pic002.jpg
     
    Last edited: May 6, 2016
  2. AndyB

    AndyB Well-Known Member

    Looks like the requireLocation is not going to be present unless that field in the Options page is selected at least once. So even if it's deselected it will remain in the option_value.
     
  3. AndyB

    AndyB Well-Known Member

    Th problem is in my Register Email add-on I have the following code:

    PHP:
    $requireLocation XenForo_Application::get('options')->registrationSetup['requireLocation'];
    So if the Require Location checkbox in the User Registration Options page has never been checked, the above PHP code throws an error due to the value not having been set yet. How can I prevent the server error? Do I need to do a database query directly on the xf_option table?
     
    Last edited: May 6, 2016
  4. Chris D

    Chris D XenForo Developer Staff Member

    Use isset() or empty() to check if an array key has been set or if it is empty.
     
  5. AndyB

    AndyB Well-Known Member

    Like this?

    PHP:
    if (!empty(XenForo_Application::get('options')->registrationSetup['requireLocation']))
    {
        
    $requireLocation XenForo_Application::get('options')->registrationSetup['requireLocation'];
    }
     
    Last edited: May 6, 2016
  6. Chris D

    Chris D XenForo Developer Staff Member

    Yeah
     
    AndyB likes this.
  7. AndyB

    AndyB Well-Known Member

    Thank you, Chris.
     

Share This Page