"Unable to find SugarController::" Error

Test Server: SuiteCRM 7.10.6, MySQL 5.5.59, CentOS 6.9
My Local Computer: SuiteCRM 7.10.6, MySQL 5.6.38, macOS Sierra 10.12.3, Google Chrome V66

TLDR; Checked Permissions, did a Quick Repair and Rebuild, site_url, host_name are all correct, custom view won’t load.

I have created my own view in Opportunities called ‘PreSaleCheck’.

You can view the code here in this post:
Custom View Missing Form Data

This works perfectly fine on my local copy running MAMP. However, when I pull the files down from GitHub into our testing environment, and attempt to access this new view, I just get a blank screen. There are no PHP errors other than some irrelevant notices and deprecation warnings.

I turned on Debugging in SuiteCRM and did a Quick Repair and Rebuild, this did not fix the issue and upon inspection of the logs I noticed this error:
[FATAL] ERROR: rmdir_recursive(): argument is not a file or a dir when referring to cache/themes/SuiteP/modules

I read the link above and made sure permissions and ownership were correct, to be clear, they are exactly what they’ve always been.

I then repeated clearing the cache on local copy and observed that when I accessed this custom view, a file was created in cache/themes/SuiteP/modules/Opportunities/PreSaleCheck.tpl

This same file was not being created in the test environment.

I went back to my view.preSaleCheck.php file and attempted to do something simple in the display() function such as "echo ‘test’; " and got no output. I decided that this was likely because the view wasn’t being accessed. Upon further investigation I discovered this error in the SuiteCRM Logs:

Tue Jun 12 18:25:10 2018 [13191][-none-][DEBUG] Unable to find SugarController:: preCheck

and further down in the logs:

Tue Jun 12 18:25:10 2018 [13191][1][DEBUG] Performing action: action_precheck MODULE: Opportunities

I looked and found that this error comes from include/MVC/Controller/SugarController.php on line 302

/**
     * Allows action to be pass XSS protection check provide that the action exists in the SugarController
     *
     * @param string $action
     */
    protected function allowAction($action)
    {
        if ($this->hasFunction($this->getActionMethodName())) {
            $GLOBALS['sugar_config']['http_referer']['actions'][] = $action;
        } else {
            $GLOBALS['log']->debug("Unable to find SugarController:: $action");
        }
    }

Any help? I can’t figure out whats wrong.

  1. Check Apache/PHP error log

  2. What commands did you execute?

  3. Did you check that permissions were correct after issuing that command?

  4. Try:
    . https://github.com/amariussi/chperms
    . then quick repair and rebuild as well as all the javascript rebuilds
    . run again the chperms.php script (if you are oatint you may run it between each repair
    . exit SuiteCRM
    . rerun chperms
    . login
    . clear browser cache (Ctr+F5 should be enough)

  1. Only PHP errors I get are (I excluded a few deprecation warnings) but these don’t seem relevant to the problem:
[Wed Jun 13 13:59:31.822731 2018] [:error] [pid 4607]  PHP Warning:  Invalid argument supplied for foreach() in include/MVC/View/SugarView.php on line 728, referer: index.php?module=Opportunities&action=index&parentTab=Opportunities
[Wed Jun 13 13:59:31.854515 2018] [:error] [pid 4607] ] PHP Warning:  Invalid argument supplied for foreach() in include/MVC/View/SugarView.php on line 763, referer: index.php?module=Opportunities&action=index&parentTab=Opportunities
  1. According to the SuiteCRM Documentation, I set the permissions too:
    (www-data was replaced with the owner for my server)
sudo chown -R www-data:www-data .
sudo chmod -R 755 .
sudo chmod -R 775 cache custom modules themes data upload
sudo chmod -R 775 config_override.php 2>/dev/null
  1. I inspected the folders and files and found they were indeed changed and reflect the commands I issued.

  2. I cleared my browser cache, logged out, ran the script, did a quick repair and rebuild, then ran the script again, then checked and this did not fix the problem.

Are you sure that this command is correct?:

sudo chown -R www-data:www-data .

Maybe on CentOS there is a different owner/group pair.

I found a few articles googling around that say that on CentOS it should be:

chown apache:apache -R /var/www/html

https://community.sugarcrm.com/thread/21628
and:
https://community.spiceworks.com/how_to/111812-how-to-install-sugarcrm-6-5-20-on-centos-7-red-hat-7-fedora-21

Be very careful before you issue these commands because you may spoil your system.

SOLUTION:

So, I found out the problem:

Apparently, macOS is a case insensitive file system, but linux is a case sensitive file system.

The name of my actual file was ‘view.preSaleCheck.php’ and even though that was the name of the view, the ViewFactory actually brings the view name all to lower case and then uses that to find the view. On my mac, it still found the file and didn’t care about the case, but on the test server which is CentOS, it did care and couldn’t find the file because it expected ‘view.presalecheck.php’ literally.

Renaming all to lowercase solved the issue. Lesson Learned.