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

XF 1.1 Zend Validate fails on XF 1.1.3

Discussion in 'Troubleshooting and Problems' started by Bitwix, Feb 16, 2015.

  1. Bitwix

    Bitwix Member

    XF 1.1.3 worked really well, so I never needed to upgrade. Then I moved to a new server (still on Windows) and the problems started.

    I'm now getting a Zend_Validate_Exception showing up in the server logs:

    Zend_Validate_Exception: Validate class not found from basename 'EmailAddress' - library\Zend\Validate.php:252

    I can use the validation successfully from my own PHP. Any ideas why it fails from inside XF?

    Here's the full stack trace:

    Zend_Validate_Exception: Validate class not found from basename 'EmailAddress' - library\Zend\Validate.php:252

    Generated By: Unknown Account, A moment ago

    Stack Trace
    #0 C:\Xenforo\LandlordForum\library\XenForo\DataWriter\User.php(573): Zend_Validate::is('[removed]', 'EmailAddress')
    #1 [internal function]: XenForo_DataWriter_User->_verifyEmail('[removed]', Object(XenForo_DataWriter_User), 'email', Array)
    #2 C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php(965): call_user_func_array(Array, Array)
    #3 C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php(720): XenForo_DataWriter->_runVerificationCallback(Array, 'ajc1516@bitwix....', Array, 'email')
    #4 C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php(638): XenForo_DataWriter->_isFieldValueValid('email', Array, 'ajc1516@bitwix....', Array)
    #5 C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php(978): XenForo_DataWriter->set('email', 'ajc1516@bitwix....', '', NULL)
    #6 C:\Xenforo\LandlordForum\library\XenForo\ControllerPublic\Register.php(195): XenForo_DataWriter->bulkSet(Array)
    #7 C:\Xenforo\LandlordForum\library\XenForo\FrontController.php(310): XenForo_ControllerPublic_Register->actionRegister()
    #8 C:\Xenforo\LandlordForum\library\XenForo\FrontController.php(132): XenForo_FrontController->dispatch(Object(XenForo_RouteMatch))
    #9 C:\Xenforo\LandlordForum\index.php(13): XenForo_FrontController->run()
    #10 {main}
     
  2. Andrej

    Andrej Well-Known Member

    Run the file health check in the ACP.
     
    Last edited: Feb 16, 2015
  3. Bitwix

    Bitwix Member

    Thanks for the suggestion. I have:

    File Health Check
    All 1,064 checked files are present and correct.
     
  4. Mike

    Mike XenForo Developer Staff Member

    Well, something significant here is that the line number generating the error isn't actually the line number from the Zend Framework file in XF. It seems like that implies that something is different with your ZF. Have you changed the ZF files? Are you doing anything with an include_path that might contain ZF?

    Note that the library/Zend files aren't actually included in the file health check.
     
  5. Bitwix

    Bitwix Member

    I had put in a few comments, so the line numbers could have changed. I have now returned them to the originals (I think) - causing the User.php line number to change to 572 (was 573 above). Is that the line number that looked wrong to you?

    The include path in PHP.ini was blank. I have just set it to include . and the XenForo library folder. No change.

    I have a test page at http://www.propertyhawk.co.uk/ajcutils/EmailProblem160215.php which shows the include path and successful calls to
    Zend_Validate::is

    Does any of this help?

    Validate class not found from basename 'EmailAddress'
    Zend_Validate::is() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter\User.php at line 572
    XenForo_DataWriter_User->_verifyEmail()
    call_user_func_array() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 965
    XenForo_DataWriter->_runVerificationCallback() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 720
    XenForo_DataWriter->_isFieldValueValid() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 638
    XenForo_DataWriter->set() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 978
    XenForo_DataWriter->bulkSet() in C:\Xenforo\LandlordForum\library\XenForo\ControllerAdmin\User.php at line 468
    XenForo_ControllerAdmin_User->actionSave() in C:\Xenforo\LandlordForum\library\XenForo\FrontController.php at line 310
    XenForo_FrontController->dispatch() in C:\Xenforo\LandlordForum\library\XenForo\FrontController.php at line 132
    XenForo_FrontController->run() in C:\Xenforo\LandlordForum\admin.php at line 13
     
  6. Mike

    Mike XenForo Developer Staff Member

    It's possible there's actually another issue at play here. In library/Zend/Validate.php, find:
    Code:
    // fallthrough and continue for missing validation classes
    After it, add:
    Code:
    throw $e;
    Is the error logged different?
     
  7. Bitwix

    Bitwix Member

    Yes, the error shows up as "Use of iconv.internal_encoding is deprecated (see below)". Commenting out a couple of lines in hostname.php allows email addresses to be edited. So that's good. Unless there's a problem with removing the line.

    There are 21 uses of inconv_set_encoding (see below). Do you think I should comment them all out? It seems likely that Format and StringLength may be in use, Audioscrobbler and Technorati may not be relevant.

    Thanks for all this help. Much appreciated!

    Search "iconv_set_encoding" (21 hits in 6 files)
    c:\xenforo\landlordforum\library\Zend\Locale\Format.php (11 hits)
    Line 311: iconv_set_encoding('internal_encoding', 'UTF-8');
    Line 346: iconv_set_encoding('internal_encoding', $oenc);
    Line 472: iconv_set_encoding('internal_encoding', $oenc);
    Line 782: iconv_set_encoding('internal_encoding', 'UTF-8');
    Line 847: iconv_set_encoding('internal_encoding', $oenc);
    Line 867: iconv_set_encoding('internal_encoding', $oenc);
    Line 973: iconv_set_encoding('internal_encoding', $oenc);
    Line 989: iconv_set_encoding('internal_encoding', $oenc);
    Line 1005: iconv_set_encoding('internal_encoding', $oenc);
    Line 1021: iconv_set_encoding('internal_encoding', $oenc);
    Line 1048: iconv_set_encoding('internal_encoding', $oenc);
    c:\xenforo\landlordforum\library\Zend\Service\Audioscrobbler.php (3 hits)
    Line 72: iconv_set_encoding('output_encoding', 'UTF-8');
    Line 73: iconv_set_encoding('input_encoding', 'UTF-8');
    Line 74: iconv_set_encoding('internal_encoding', 'UTF-8');
    c:\xenforo\landlordforum\library\Zend\Service\Technorati.php (3 hits)
    Line 87: iconv_set_encoding('output_encoding', 'UTF-8');
    Line 88: iconv_set_encoding('input_encoding', 'UTF-8');
    Line 89: iconv_set_encoding('internal_encoding', 'UTF-8');
    c:\xenforo\landlordforum\library\Zend\Validate\Hostname.php (2 hits)
    Line 521: // iconv_set_encoding('internal_encoding', 'UTF-8'); // removed ajc 22/02/2015
    Line 617: //iconv_set_encoding('internal_encoding', $origenc); // removed ajc 22/02/2015
    c:\xenforo\landlordforum\library\Zend\Validate\StringLength.php (2 hits)
    Line 203: $result = iconv_set_encoding('internal_encoding', $encoding);
    Line 209: iconv_set_encoding('internal_encoding', $orig);

    The following error occurred:

    iconv_set_encoding(): Use of iconv.internal_encoding is deprecated
    XenForo_Application::handlePhpError()
    iconv_set_encoding() in C:\Xenforo\LandlordForum\library\Zend\Validate\Hostname.php at line 521
    Zend_Validate_Hostname->isValid() in C:\Xenforo\LandlordForum\library\Zend\Validate\EmailAddress.php at line 487
    Zend_Validate_EmailAddress->_validateHostnamePart() in C:\Xenforo\LandlordForum\library\Zend\Validate\EmailAddress.php at line 546
    Zend_Validate_EmailAddress->isValid() in C:\Xenforo\LandlordForum\library\Zend\Validate.php at line 234
    Zend_Validate::is() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter\User.php at line 572
    XenForo_DataWriter_User->_verifyEmail()
    call_user_func_array() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 965
    XenForo_DataWriter->_runVerificationCallback() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 720
    XenForo_DataWriter->_isFieldValueValid() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 638
    XenForo_DataWriter->set() in C:\Xenforo\LandlordForum\library\XenForo\DataWriter.php at line 978
    XenForo_DataWriter->bulkSet() in C:\Xenforo\LandlordForum\library\XenForo\ControllerAdmin\User.php at line 468
    XenForo_ControllerAdmin_User->actionSave() in C:\Xenforo\LandlordForum\library\XenForo\FrontController.php at line 310
    XenForo_FrontController->dispatch() in C:\Xenforo\LandlordForum\library\XenForo\FrontController.php at line 132
    XenForo_FrontController->run() in C:\Xenforo\LandlordForum\admin.php at line 13
     
  8. Mike

    Mike XenForo Developer Staff Member

    Ahh, that's specifically related to the version of XF you're running then. This is something that has been subsequently fixed (though I don't remember the specific version, I believe it's fixed in the latest 1.3 release). They're not commented out; they're actually changed to use the new default_charset ini setting.
     
  9. Bitwix

    Bitwix Member

    So a better change would be:

    $origdc = iconv_get_encoding('default_charset') ; // had been 'internal_encoding');
    iconv_set_encoding('default_charset', 'UTF-8'); // had been 'internal_encoding'

    If that is better, it's not a scary change. Please confirm.

    Sorry for wanting to keep such an old forum alive - it is used actively!
     
  10. Mike

    Mike XenForo Developer Staff Member

    You can probably use the Zend Framework stuff from the latest version of XF without issue. I would test that though.

    The general change is along these lines:
    Code:
                if (PHP_VERSION_ID < 50600) {
                    iconv_set_encoding('internal_encoding', 'UTF-8');
                } else {
                    @ini_set('default_charset', 'UTF-8');
                }
    
     
  11. Bitwix

    Bitwix Member

Share This Page