Fixed Contact us error XF 2.0.3

Affected version
2.0.3

Robru

Well-known member
Code:
Server error log
ErrorException: [E_WARNING] count(): Parameter must be an array or an object that implements Countable src/XF/Service/Contact.php:139
Generated by: Unknown account Mar 16, 2018 at 7:47 AM

Stack trace
#0 [internal function]: XF::handlePhpError(2, '[E_WARNING] cou...', '/var/www/html/c...', 139, Array)
#1 src/XF/Service/Contact.php(139): count(NULL)
#2 src/XF/Pub/Controller/Misc.php(66): XF\Service\Contact->validate(NULL)
#3 src/XF/Mvc/Dispatcher.php(249): XF\Pub\Controller\Misc->actionContact(Object(XF\Mvc\ParameterBag))
#4 src/XF/Mvc/Dispatcher.php(88): XF\Mvc\Dispatcher->dispatchClass('XF:Misc', 'Contact', 'json', Object(XF\Mvc\ParameterBag), '', Object(XF\Pub\Controller\Misc), NULL)
#5 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#6 src/XF/App.php(1891): XF\Mvc\Dispatcher->run()
#7 src/XF.php(328): XF\App->run()
#8 index.php(13): XF::runApp('XF\\Pub\\App')
#9 {main}

Request state
array(4) {
  ["url"] => string(23) "/community/misc/contact"
  ["referrer"] => string(36) "https://www.caviaforum.nl/community/"
  ["_GET"] => array(0) {
  }
  ["_POST"] => array(10) {
    ["username"] => string(6) "Ronald"
    ["email"] => string(16) "roger@minemail.com"
    ["g-recaptcha-response"] => string(356) "03ANcjosqsklyJTnKzl_dFhrDMKPjvWPwVdVbcT"
    ["subject"] => string(17) "Contact formulier"
    ["message"] => string(18) "Dit is een test :)"
    ["_xfRedirect"] => string(36) "https://www.caviaforum.nl/community/"
    ["_xfToken"] => string(8) "********"
    ["_xfRequestUri"] => string(11) "/community/"
    ["_xfWithData"] => string(1) "1"
    ["_xfResponseType"] => string(4) "json"
  }
}
 
Last edited:

Chris D

XenForo developer
Staff member
Thanks we've sorted this now. Not sure how this one escaped me but it happened when I changed the code slightly in the last release.

To restore it to its former glory you would edit the file src/XF/Service/Contact.php and above:
PHP:
if (!$this->validated)
Add:
PHP:
$errors = [];
 

Chris D

XenForo developer
Staff member
I'm not totally sure how, unless you have warnings suppressed on your installation. Definitely nothing logged in the server error log?
 

Robru

Well-known member
Thanks we've sorted this now. Not sure how this one escaped me but it happened when I changed the code slightly in the last release.

To restore it to its former glory you would edit the file src/XF/Service/Contact.php and above:
PHP:
if (!$this->validated)
Add:
PHP:
$errors = [];
Thank you Chris :)
Solved!

I'am using PHP7.2.3
 
Top