salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.44k stars 2.08k forks source link

7.11.4 Global Search by ES ERROR #7281

Open cekowu opened 5 years ago

cekowu commented 5 years ago

Issue

Expected Behavior

Actual Behavior

Possible Fix

Steps to Reproduce

  1. Config es server
  2. Config SuiteCRM search enigine by ES
  3. Search "_type:Accounts" 4.Response "Error Contact an administrator if the problem persists. More information available in the logs." debug log: `Mon May 13 08:52:21 2019 [9526][1][FATAL] [ERROR] [SearchThrowableHandler] Mon May 13 08:52:21 2019 [9526][1][FATAL] [ERROR] [SearchThrowableHandler] SuiteCRM\Exception\Exception: [SuiteCRM] Error retrieveing bean: Accounts [86ee02b3-97d3-47b3-bd6d-9e1035daff3a] in /data/www/html/SuiteCRM/7.11/lib/Search/SearchResults.php:131 Stack trace:

    0 /data/www/html/SuiteCRM/7.11/lib/Search/UI/SearchResultsController.php(122): SuiteCRM\Search\SearchResults->getHitsAsBeans()

    1 /data/www/html/SuiteCRM/7.11/lib/Search/SearchEngine.php(65): SuiteCRM\Search\UI\SearchResultsController->display()

    2 /data/www/html/SuiteCRM/7.11/lib/Search/SearchEngine.php(41): SuiteCRM\Search\SearchEngine->displayResults(Object(SuiteCRM\Search\SearchQuery), Object(SuiteCRM\Search\SearchResults))

    3 /data/www/html/SuiteCRM/7.11/lib/Search/SearchWrapper.php(77): SuiteCRM\Search\SearchEngine->searchAndDisplay(Object(SuiteCRM\Search\SearchQuery))

    4 /data/www/html/SuiteCRM/7.11/modules/Home/Search.php(50): SuiteCRM\Search\SearchWrapper::searchAndDisplay(Object(SuiteCRM\Search\SearchQuery))

    5 /data/www/html/SuiteCRM/7.11/include/MVC/View/SugarView.php(834): include_once('/data/www/html/...')

    6 /data/www/html/SuiteCRM/7.11/include/MVC/View/views/view.classic.php(72): SugarView->includeClassicFile('modules/Home/Se...')

    7 /data/www/html/SuiteCRM/7.11/include/MVC/View/SugarView.php(226): ViewClassic->display()

    8 /data/www/html/SuiteCRM/7.11/include/MVC/Controller/SugarController.php(435): SugarView->process()

    9 /data/www/html/SuiteCRM/7.11/include/MVC/Controller/SugarController.php(375): SugarController->processView()

    10 /data/www/html/SuiteCRM/7.11/include/MVC/SugarApplication.php(113): SugarController->execute()

    11 /data/www/html/SuiteCRM/7.11/index.php(52): SugarApplication->execute()

    12 {main}

    `

Context

Your Environment

cekowu commented 5 years ago

rebuild the index and try again to get bean, but it seem rebuild faild in ES, it leads this issue public function getHitsAsBeans() { $hits = $this->hits; $parsed = [];

    foreach ($hits as $module => $beans) {
        foreach ((array)$beans as $bean) {
            $obj = BeanFactory::getBean($module, $bean);

            // if a search found a bean but suitecrm does not, it could happens
            // maybe the bean is deleted but elsasticsearch is not re-indexing yet.
            // so at this point we trying to rebuild the index and try again to get bean:
            if (!$obj) {
                ElasticSearch\ElasticSearchIndexer::repairElasticsearchIndex();
                $obj = BeanFactory::getBean($module, $bean);
            }
            if (!$obj) {
                throw new Exception('Error retrieveing bean: ' . $module . ' [' . $bean . ']');
            }
            $obj->load_relationships();
            $fieldDefs = $obj->getFieldDefinitions();
            $objUpdatedLinks = $this->updateFieldDefLinks($obj, $fieldDefs);
            $parsed[$module][] = $objUpdatedLinks;
        }
    }

    return $parsed;
}
oc666 commented 4 years ago

After adding continue; inside the 2nd if(!$obj) - the issue fixed.