mjda
Well-known member
I have hundreds of threads, from a conversion, that have no posts with them. They don't even have the original post data associated with them. These are causing errors with the enhanced search, among other things.
So, I want to delete all those threads. What I'm thinking about doing is creating a script that will grab all threads with 0 replies, check to see if it has any associated posts and, if not, use
My question is, would this be the appropriate way to handle this to be sure that all stats are updated correctly? Will it still work correctly, even though there is missing post data?
Just for more info, here is an error that I get several times per day:
Pretty much any time one of these orphaned thread titles is found to be one of the matches in the auto-complete search results, the entire thing fails. So, I noticed, as one example here, that a search through my database for posts with
I used this query to search for more orphaned threads:
Turns out there are 1,588 of these in my database, with the most recent one being posted in 2014. So, at least it's not something that's still going on. Again, I'm pretty sure this all comes from the old database, and something happened during the conversion to XF. Maybe threads shouldn't be converted if they have no posts? Anyways, I just need to get it fixed now.
So, I want to delete all those threads. What I'm thinking about doing is creating a script that will grab all threads with 0 replies, check to see if it has any associated posts and, if not, use
$thread->delete();
.My question is, would this be the appropriate way to handle this to be sure that all stats are updated correctly? Will it still work correctly, even though there is missing post data?
Just for more info, here is an error that I get several times per day:
Code:
ErrorException: [E_WARNING] Attempt to read property "message" on null src/XF/Search/Data/Thread.php:111
Generated by: mjda Sep 4, 2024 at 8:02 AM
Code:
#0 src/XF/Search/Data/Thread.php(111): XF::handlePhpError(2, '[E_WARNING] Att...', '/home/mydirectory...', 111)
#1 src/XF/Search/Search.php(299): XF\Search\Data\Thread->getAutoCompleteResult(Object(XFMG\XF\Entity\Thread), Array)
#2 src/XF/ResultSet.php(129): XF\Search\Search->XF\Search\{closure}(Object(XFMG\XF\Entity\Thread), 'thread', 381)
#3 src/XF/Search/Search.php(285): XF\ResultSet->getResultsDataCallback(Object(Closure))
#4 src/XF/Pub/Controller/SearchController.php(123): XF\Search\Search->getAutoCompleteResults(Object(XF\ResultSet), Array)
#5 src/XF/Mvc/Dispatcher.php(362): XF\Pub\Controller\SearchController->actionAutoComplete(Object(XF\Mvc\ParameterBag))
#6 src/XF/Mvc/Dispatcher.php(264): XF\Mvc\Dispatcher->dispatchClass('XF:Search', 'AutoComplete', Object(XF\Mvc\RouteMatch), Object(XFES\XF\Pub\Controller\Search), NULL)
#7 src/XF/Mvc/Dispatcher.php(121): XF\Mvc\Dispatcher->dispatchFromMatch(Object(XF\Mvc\RouteMatch), Object(XFES\XF\Pub\Controller\Search), NULL)
#8 src/XF/Mvc/Dispatcher.php(63): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#9 src/XF/App.php(2813): XF\Mvc\Dispatcher->run()
#10 src/XF.php(802): XF\App->run()
#11 index.php(23): XF::runApp('XF\\Pub\\App')
#12 {main}
Pretty much any time one of these orphaned thread titles is found to be one of the matches in the auto-complete search results, the entire thing fails. So, I noticed, as one example here, that a search through my database for posts with
thread_id = 381
returns 0 results.I used this query to search for more orphaned threads:
Code:
SELECT t.thread_id, t.title, p.post_id FROM xf_thread as t
left join xf_post as p on (p.thread_id = t.thread_id)
where p.post_id is null;
Turns out there are 1,588 of these in my database, with the most recent one being posted in 2014. So, at least it's not something that's still going on. Again, I'm pretty sure this all comes from the old database, and something happened during the conversion to XF. Maybe threads shouldn't be converted if they have no posts? Anyways, I just need to get it fixed now.
Last edited: