Fixed [E_WARNING] Attempt to read property "result_count" on null

You can suppress the Health Check warnings about changed content using this addon:

 
You can suppress the Health Check warnings about changed content using this addon:

Since this is going to be officially patched by XenForo, a better solution in this case is to update the hash in hashes.json. That way you don't lose file integrity checks.

Or just wait--it's safe to ignore the health check warning if you've deliberately modified the files with hash mismatches.
 
Thank you Xenforo!!

@Kirby - I'm having an issue though...



TL;DR
src/XF/Pub/Controller/Search.php

Insert
PHP:
if (!is_object($search)) {
 return $this->message(\XF::phrase('no_results_found'));
}
after line 149.

OK, so after applying the patch I removed the fix's code, and cleared all the server errors.

But new errors are showing, and the file (search.php) still draws an error even if I removed the code.

142c4682ee1e5d8466e066d776b81d57.pnge065f461640d72da97860e8f41d921be.png

What could I have done wrong? Here's the code around line 149:

Code:
            if ($visitor->user_id)
            {
                // always re-run search for logged-in users
                return $this->runSearch($query, $constraints);
            }
            else if ($search && $search->search_query && $search->search_query !== $this->filter('q', 'str'))
            {
                return $this->notFound();
            }
        }

       
        $page = $this->filterPage();
        $perPage = $this->options()->searchResultsPerPage;

        $this->assertValidPage($page, $perPage, $search->result_count, 'search', $search);

Is there a bad space somewhere? I should have kept a copy of the original, dang it...

Help?

Andre
 
Hmmm... anyone applied the patch?

I am still getting errors. I thought it was my doing, but I'm not so sure. Anyone? I am re-applying the server errors fix for now.


7f7c0636abee0579b5dac6e25c7456ad.png
 
Applied their update (I left the workaround fix in Search.php there before updating). It still listed 1 file with unexpected contents initially, so I had it re-check, and that cleared the unexpected contents warning. No more errors so far, almost 2 hours later.

Hmmm... anyone applied the patch?

I am still getting errors. I thought it was my doing, but I'm not so sure. Anyone? I am re-applying the server errors fix for now.
Did you try to edit the file to remove the workaround fix after applying the update, maybe? If so, you might have overwritten the fix provided by the update. Otherwise, I have no idea.
 
Applied their update (I left the workaround fix in Search.php there before updating). It still listed 1 file with unexpected contents initially, so I had it re-check, and that cleared the unexpected contents warning. No more errors so far, almost 2 hours later.


Did you try to edit the file to remove the workaround fix after applying the update, maybe? If so, you might have overwritten the fix provided by the update. Otherwise, I have no idea.

I applied the patch via my admin panel, and only removed the code AFTER applying the patch. That's what you did too, yes?

I will try re-uploading the patch manually this time.

EDIT: I downloaded the patch manually and used the "search.php" file in it and overwrote the old one via FTP.

Then I re-ran the health check and it worked! :) So far so good!


fce0d705b44de07b5f3d098bd0db30de.webp
 
Last edited:
I applied the patch via my admin panel, and only removed the code AFTER applying the patch. That's what you did too, yes?

I will try re-uploading the patch manually this time.
No, no. Their update replaced the file entirely. If you saved changes to the file after that, you overwrote the file with your version. Like Brogan said on the last page, there was no need to try to remove the workaround.

EDIT:
Even if there had been a reason to remove the workaround fix, you would absolutely want to do that BEFORE running the official update, NOT after. But again, there was no need.
 
No, no. Their update replaced the file entirely. If you saved changes to the file after that, you overwrote the file with your version. Like Brogan said on the last page, there was no need to try to remove the workaround.

Oh I didn't catch that part. So basically by uploading the new Search file manually, it cleared my mistake. Thanks!
 
Applied the update. File Health check OK. Have yet to see the error return, keeping fingers crossed! Thank you for the patch, XenForo Dev Team!
 
I would have preferred to wait weeks/months rather than have the errors of the health check nag. So yes, in future I will probably wait a few days
This is another reason why you need a third party off site backup system in place when things go awry.
 
I am now getting this again after updating to 2.2.11:

Code:
Server error log
ErrorException: [E_WARNING] Attempt to read property "result_count" on null src/XF/Pub/Controller/Search.php:153
Generated by: Unknown account Oct 13, 2022 at 11:48 AM
Stack trace
#0 src/XF/Pub/Controller/Search.php(153): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/caf/publi...', 153)
#1 src/XF/Mvc/Dispatcher.php(352): XF\Pub\Controller\Search->actionResults(Object(XF\Mvc\ParameterBag))
#2 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF\\Pub\\Controll...', 'Results', Object(XF\Mvc\RouteMatch), Object(LiteSpeedCache\XF\Pub\Controller\Search), Object(XF\Mvc\Reply\Reroute))
#3 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(LiteSpeedCache\XF\Pub\Controller\Search), Object(XF\Mvc\Reply\Reroute))
#4 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#5 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#6 src/XF.php(524): XF\App->run()
#7 index.php(20): XF::runApp('XF\\Pub\\App')
#8 {main}
Request state
array(4) {
  ["url"] => string(38) "/search/114592/?q=beginner&o=relevance"
  ["referrer"] => bool(false)
  ["_GET"] => array(2) {
    ["q"] => string(8) "beginner"
    ["o"] => string(9) "relevance"
  }
  ["_POST"] => array(0) {
  }
}

Can anyone please help?
 
I am now getting this again after updating to 2.2.11:

Code:
Server error log
ErrorException: [E_WARNING] Attempt to read property "result_count" on null src/XF/Pub/Controller/Search.php:153
Generated by: Unknown account Oct 13, 2022 at 11:48 AM
Stack trace
#0 src/XF/Pub/Controller/Search.php(153): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/caf/publi...', 153)
#1 src/XF/Mvc/Dispatcher.php(352): XF\Pub\Controller\Search->actionResults(Object(XF\Mvc\ParameterBag))
#2 src/XF/Mvc/Dispatcher.php(259): XF\Mvc\Dispatcher->dispatchClass('XF\\Pub\\Controll...', 'Results', Object(XF\Mvc\RouteMatch), Object(LiteSpeedCache\XF\Pub\Controller\Search), Object(XF\Mvc\Reply\Reroute))
#3 src/XF/Mvc/Dispatcher.php(115): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(LiteSpeedCache\XF\Pub\Controller\Search), Object(XF\Mvc\Reply\Reroute))
#4 src/XF/Mvc/Dispatcher.php(57): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#5 src/XF/App.php(2353): XF\Mvc\Dispatcher->run()
#6 src/XF.php(524): XF\App->run()
#7 index.php(20): XF::runApp('XF\\Pub\\App')
#8 {main}
Request state
array(4) {
  ["url"] => string(38) "/search/114592/?q=beginner&o=relevance"
  ["referrer"] => bool(false)
  ["_GET"] => array(2) {
    ["q"] => string(8) "beginner"
    ["o"] => string(9) "relevance"
  }
  ["_POST"] => array(0) {
  }
}

Can anyone please help?
Re-download the 2.2.11 update, the build was buggy and they replaced the zip after about an hour or so after the initial release.
 
Top Bottom