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

No controller response error message

AndyB

Well-known member
#1
I'm getting the following error message in my Server Error Logs:

XenForo_Exception: No controller response from Andy_SimilarThreads_ControllerPublic_Abstract::actionIndex - library/XenForo/FrontController.php:455

In my Similar Threads add-on I have an option to show similar threads when a new thread is being created. If this feature is disabled (un-checked) the code bypasses the main part of the function. Here's a link to the code:

http://xenforo.com/community/threads/similar-threads-v1-4.62374/#post-661591

In this situation I can't just add the following code:

PHP:
//option not set return parent action
return parent::actionIndex();
because there's no actionIndex() parent in the default ControllerPublic_Abstract file.

What is the correct code to avoid the error message?

Thank you.
 

AndyB

Well-known member
#2
I was able to resolve this problem by changing the code so that it always runs. The template just returns nothing when the option is disabled.
 

Jeremy

Well-known member
#3
This is why you are supposed to extend pre-defined controllers unless you are defining a new section of the website.
 

AndyB

Well-known member
#4
This is why you are supposed to extend pre-defined controllers unless you are defining a new section of the website.
Thank you for looking at this, Jeremy.

I extended XenForo_ControllerPublic_Forum instead of XenForo_ControllerPublic_Abstract but it didn't solve the problem. I still get an error message in my server error logs if I try to bypass my code (option deselected).

If I add the following code after bypassing my main code:

PHP:
} else {
// run the original save() function
return parent::actionIndex();
the AJAX routine will display the forum list in place of where the similar threads results would normally be shown.
 
Last edited:

AndyB

Well-known member
#5
Here's the code as I have it now:

PHP:
<?php

class Andy_SimilarThreads_ControllerPublic_Forum extends XFCP_XenForo_ControllerPublic_Forum
{
    public function actionIndex()
    {
        // call parent function
        parent::actionIndex();
       
        // declare variables
        $currentNodeId = '';
        $currentThreadId = '';
        $similarThreads = array();
        $searchWords = array();
        $searchWord1 = '';
        $searchWord2 = '';           
        $safeSearchWord1 = '';
        $safeSearchWord2 = '';
       
        // get options from Admin CP -> Options -> Similar Threads -> Show Create Thread
        $showCreateThread = XenForo_Application::get('options')->showCreateThread;
       
        if ($showCreateThread == 1)
        {
            // get newTitle
            $newTitle = $this->_request->getParam('title');
   
            // put into array
            $newTitle = explode(' ', $newTitle);
           
            // get options from Admin CP -> Options -> Similar Threads -> Common Words 
            $commonWords = XenForo_Application::get('options')->commonWords;
           
            // convert to lowercase
            $commonWords = strtolower($commonWords);
           
            // put $commonWordsLower into an array
            $commonWords = explode(' ', $commonWords);
           
            // remove any common words from array
            foreach($newTitle as $var)
            {
                if (!in_array(strtolower($var), $commonWords))
                {
                    // get options from Admin CP -> Options -> Similar Threads -> Miniumum Common Word Length   
                    $minimumCommonWordLength = XenForo_Application::get('options')->minimumCommonWordLength;                   
                   
                    if (strlen($var) >= $minimumCommonWordLength)
                    {
                        $searchWords[] = $var;
                    }
                }
            }
           
            $count = count($searchWords);
           
            // only continue if we have a search word
            if ($count > 0)
            {               
                // get first search word
                $searchWord1 = $searchWords[0];
               
                // make safe for query
                $safeSearchWord1 = addslashes($searchWords[0]);
               
                if ($count > 1)
                {   
                    // get second search word
                    $searchWord2 = $searchWords[1];   
                           
                    // make safe for query
                    $safeSearchWord2 = addslashes($searchWords[1]);   
                }           
            }
           
            // run query only if we have a search and option is selected
            if ($safeSearchWord1 != '' AND $showCreateThread == 1)
            {
                // run query in model   
                $similarThreads = $this->getModelFromCache('Andy_SimilarThreads_Model')->getThreads($safeSearchWord1,$safeSearchWord2,$currentNodeId,$currentThreadId);   
            }
           
            // prepare $viewParams for template
            $viewParams = array(
                'similarThreads' => $similarThreads,
                'searchWord1' => $searchWord1,
                'searchWord2' => $searchWord2,
            );
           
            // send to template
            return $this->responseView('Andy_SimilarThreads_ViewPublic_SimilarThreads', 'andy_similarthreads_create_thread', $viewParams);
        }
    }
}

?>
 
Last edited:

AndyB

Well-known member
#6
Si if the $showCreateThread == 1 I bypass my code. All is fine but I get the following error messages in the server error log:

No controller response from Andy_SimilarThreads_ControllerPublic_Forum::actionIndex - library/XenForo/FrontController.php:455
 

AndyB

Well-known member
#8

AndyB

Well-known member
#10
It breaks your AJAX how?
As soon as I start typing into the thread title input box, I get an error message. This is the error message:

An exception occurred: Cannot load class using XFCP. Load the class using the correct loader first. in /home/southbay/www/forums/library/XenForo/Autoloader.php on line 108
 

AndyB

Well-known member
#13
Listener.php

PHP:
<?php

class Andy_SimilarThreads_Listener
{
    public static function Thread($class, array &$extend)
    {
        $extend[] = 'Andy_SimilarThreads_ControllerPublic_Thread';
    }    
    
    public static function Forum($class, array &$extend)
    {
        $extend[] = 'Andy_SimilarThreads_ControllerPublic_Forum';
    }    
}

?>
 

Daniel Hood

Well-known member
#16
You started the file with
PHP:
class Andy_SimilarThreads_ControllerPublic_Forum extends XFCP_Andy_SimilarThreads_ControllerPublic_Forum
right?
 

AndyB

Well-known member
#18
You started the file with
PHP:
class Andy_SimilarThreads_ControllerPublic_Forum extends XFCP_Andy_SimilarThreads_ControllerPublic_Forum
right?
Hi Daniel,

That's correct.

Sorry I did a copy paste. When I was doing my test I indeed had XFCP in the class.
 

Chris D

XenForo developer
Staff member
#20
Ah sorry. I missed the error at first.

If you have any other add-ons where you've not used the class proxy system, this could be an expected behaviour.