Answers.Body: <p>Tracked down the cause. It was some 'bad' (non-numeric?) values in civicrm_custom_group.extends_entity_column_value, such as 'media_info', 'Funder' &amp; 'Elected_Info_Ind'. Perhaps a legacy from an old module or extension? Deleted these, errors disappeared &amp; performance excellent.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-28T02:08:17.417Z
Answers.LastActivityDate: 2017-07-28T02:08:17.417Z
Answers.UserDisplayName: Bryan
Answers.Body: <p>I had a similar but different issue creating indices for contact_id case_id in that table. Had to remove before rerunning. Sadly no "IF NOT EXISTS" is available for CREATE INDEX.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-28T14:25:04.103Z
Answers.LastActivityDate: 2017-07-28T14:25:04.103Z
Answers.UserDisplayName: JohnFF
Answers.Body: <p>I had this same issue when an organisation was being stored as an individual. So the main contact type was set to individual. This meant that the organisation contact sub type did not match the correct set of sub types for individual.</p>
  <p>I changed the contact type in the database directly for that organisation (civicrm_contact).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-15T13:33:56.130Z
Answers.LastActivityDate: 2021-12-15T13:33:56.130Z
Answers.UserDisplayName: Ben
Answers.Body: <p>From the error, it seems you have double entry for <code>path, domain_id</code> combo in <code>civicrm_menu</code> table. This need to be unique as it has an index created over it.</p>
  
  <p>Try deleting the one row from <code>civicrm_menu</code> table that contains a duplicate values for <code>path and domain_id</code>.</p>
  
  <p>Eg. Run this query</p>
  
  <pre><code>SELECT id, path, domain_id 
  FROM civicrm_menu
  WHERE path = 'civicrm/contact/view/note';
  </code></pre>
  
  <p>If this contains two rows with same domain_id - delete one of them -> rebuild menu and check if this fixes the issue for you. </p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-26T05:40:30.850Z
Answers.Text: Thank you for your help. The query returns: MySQL returned an empty result set (i.e. zero rows). (Query took 0.0001 seconds.)
  SELECT id, path, domain_id FROM civicrm_menu WHERE path = 'civicrm/contact/view/note-1'
Answers.UserDisplayName: Bryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-26T06:35:54.940Z
Answers.Text: And by sorting the table and eyeballing I can see no duplicate for this path…
Answers.UserDisplayName: Bryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-26T07:35:42.233Z
Answers.Text: Not sure if it's of relevance but the value in the table is 'civicrm/contact/view/note' not 'civicrm/contact/view/note-1'. Is there something going on the code to account for duplicates?
Answers.UserDisplayName: Bryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-26T09:51:56.817Z
Answers.Text: Yes, the value need to be `civicrm/contact/view/note` and not note-1, 1 is the domain_id. I've updated the answer, but seems you've already checked for duplicate values in this table. I mentioned because this is what the error message in the backtrace meant to be. Not sure if it is related to the exect issue you're seeing.
Answers.UserDisplayName: jitendra - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-26T22:57:40.330Z
Answers.Text: What about the log message about 'Invalid Filter'? It appears to relate dto custom groups, of which I have many. Not sure how this relates to the backtrace, but the error occurs in the log with every menu action. Also, not sure if I made it plain, all the actions/page loads succeed, very slowly but without a visible error unless debugging switched on.
Answers.UserDisplayName: Bryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-07-26T04:25:35.417Z
Answers.LastActivityDate: 2017-07-26T09:50:22.180Z
Answers.LastEditDate: 2017-07-26T09:50:22.180Z
Answers.UserDisplayName: jitendra - fuzion
Body: <p>Things have come to a virtual standstill on a CiviCRM/Drupal7 installation. CiviCRM page loads (and reloads) are taking a minute or more, but do eventually load. Another two installations on the same server are unaffected.</p>
  
  <p>Perhaps related, I had just upgraded the mosaico extension from the beta to the release version and the mosaico menus are absent from 'Mailings'.</p>
  
  <p>I have tried clearing the caches and rebuilding the menus.</p>
  
  <p>Advice and insights would be gratefully received.</p>
  
  <p>The log shows:</p>
  
  <pre><code>CRM_Core_Exception: Invalid Filter in CRM_Core_BAO_CustomGroup::validateSubTypeByEntity() 
  (line 689 of /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/BAO/CustomGroup.php).
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>$backTrace = 
    #0 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Error.php(229): CRM_Core_Error::backtrace("backTrace", TRUE) 
    #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error)) 
    #2 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error)) 
    #3 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB.php(985): PEAR_Error-&gt;__construct("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #4 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/PEAR.php(575): DB_Error-&gt;__construct(-5, 16, (Array:2), "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #5 [internal function](): PEAR-&gt;_raiseError(Object(DB_mysqli), NULL, -5, NULL, NULL, "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...", "DB_Error", TRUE) 
    #6 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8)) 
    #7 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR-&gt;__call("raiseError", (Array:7)) 
    #8 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR-&gt;raiseError(NULL, -5, NULL, NULL, "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...", "DB_Error", TRUE) 
    #9 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common-&gt;raiseError(-5, NULL, NULL, NULL, "1062 ** Duplicate entry 'civicrm/contact/view/note-1' for key 'UI_path_domain...") 
    #10 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli-&gt;mysqliRaiseError() 
    #11 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli-&gt;simpleQuery("INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #12 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/DataObject.php(2446): DB_common-&gt;query("INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #13 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/DataObject.php(1068): DB_DataObject-&gt;_query("INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #14 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/DAO.php(495): DB_DataObject-&gt;insert() 
    #15 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Menu.php(309): CRM_Core_DAO-&gt;save() 
    #16 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(185): CRM_Core_Menu::store(FALSE) 
    #17 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(83): CRM_Core_Invoke::getItem((Array:2)) 
    #18 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:2)) 
    #19 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:2)) 
    #20 [internal function](): civicrm_invoke("admin") 
    #21 /var/www/clients/client4/web5/web/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:1)) 
    #22 /var/www/clients/client4/web5/web/index.php(21): menu_execute_active_handler() 
    #23 {main}
    SEVERITY  
  </code></pre>
  
Tags: <error><4.7>
Title: "Invalid Filter in CRM_Core_BAO_CustomGroup" error
ThreadText: # "Invalid Filter in CRM_Core_BAO_CustomGroup" error
  
  (Asked by: username_0 on 2017-07-26)
  
  Things have come to a virtual standstill on a CiviCRM/Drupal7 installation. CiviCRM page loads (and reloads) are taking a minute or more, but do eventually load. Another two installations on the same server are unaffected.
  Perhaps related, I had just upgraded the mosaico extension from the beta to the release version and the mosaico menus are absent from 'Mailings'.
  I have tried clearing the caches and rebuilding the menus.
  Advice and insights would be gratefully received.
  The log shows:
  CRM_Core_Exception: Invalid Filter in CRM_Core_BAO_CustomGroup::validateSubTypeByEntity() 
  (line 689 of /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/BAO/CustomGroup.php).
  
  and:
  $backTrace = 
    #0 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Error.php(229): CRM_Core_Error::backtrace("backTrace", TRUE) 
    #1 [internal function](): CRM_Core_Error::handle(Object(DB_Error)) 
    #2 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/PEAR.php(921): call_user_func((Array:2), Object(DB_Error)) 
    #3 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: already exists", -5, 16, (Array:2), "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #4 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/PEAR.php(575): DB_Error->__construct(-5, 16, (Array:2), "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #5 [internal function](): PEAR->_raiseError(Object(DB_mysqli), NULL, -5, NULL, NULL, "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...", "DB_Error", TRUE) 
    #6 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/PEAR.php(224): call_user_func_array((Array:2), (Array:8)) 
    #7 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7)) 
    #8 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/common.php(1905): PEAR->raiseError(NULL, -5, NULL, NULL, "INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...", "DB_Error", TRUE) 
    #9 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-5, NULL, NULL, NULL, "1062 ** Duplicate entry 'civicrm/contact/view/note-1' for key 'UI_path_domain...") 
    #10 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError() 
    #11 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #12 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/DataObject.php(2446): DB_common->query("INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #13 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/packages/DB/DataObject.php(1068): DB_DataObject->_query("INSERT INTO civicrm_menu (domain_id , path , path_arguments , title , access_...") 
    #14 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/DAO.php(495): DB_DataObject->insert() 
    #15 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Menu.php(309): CRM_Core_DAO->save() 
    #16 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(185): CRM_Core_Menu::store(FALSE) 
    #17 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(83): CRM_Core_Invoke::getItem((Array:2)) 
    #18 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:2)) 
    #19 /var/www/clients/client4/web5/web/sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:2)) 
    #20 [internal function](): civicrm_invoke("admin") 
    #21 /var/www/clients/client4/web5/web/includes/menu.inc(527): call_user_func_array("civicrm_invoke", (Array:1)) 
    #22 /var/www/clients/client4/web5/web/index.php(21): menu_execute_active_handler() 
    #23 {main}
    SEVERITY
  
  **Tags:** error, 4.7
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2017-07-28. Score: 2
  
  Tracked down the cause. It was some 'bad' (non-numeric?) values in civicrm\_custom\_group.extends\_entity\_column\_value, such as 'media\_info', 'Funder' & 'Elected\_Info\_Ind'. Perhaps a legacy from an old module or extension? Deleted these, errors disappeared & performance excellent.
  
  
  ---
  
  ### Answer by username_1 on 2017-07-28. Score: 0
  
  I had a similar but different issue creating indices for contact\_id case\_id in that table. Had to remove before rerunning. Sadly no "IF NOT EXISTS" is available for CREATE INDEX.
  
  
  ---
  
  ### Answer by username_2 on 2021-12-15. Score: 0
  
  I had this same issue when an organisation was being stored as an individual. So the main contact type was set to individual. This meant that the organisation contact sub type did not match the correct set of sub types for individual.
  
  I changed the contact type in the database directly for that organisation (civicrm\_contact).
  
  
  ---
  
  ### Answer by username_3 on 2017-07-26. Score: 0
  
  From the error, it seems you have double entry for path, domain_id combo in civicrm_menu table. This need to be unique as it has an index created over it.
  Try deleting the one row from civicrm_menu table that contains a duplicate values for path and domain_id.
  Eg. Run this query
  SELECT id, path, domain_id 
  FROM civicrm_menu
  WHERE path = 'civicrm/contact/view/note';
  
  If this contains two rows with same domain_id - delete one of them -> rebuild menu and check if this fixes the issue for you.
  
  > **Comments:**
  > **username_0**: Thank you for your help. The query returns: MySQL returned an empty result set (i.e. zero rows). (Query took 0.0001 seconds.) SELECT id, path, domain_id FROM civicrm_menu WHERE path = 'civicrm/contact/view/note-1'  
  > **username_0**: And by sorting the table and eyeballing I can see no duplicate for this path…  
  > **username_0**: Not sure if it's of relevance but the value in the table is 'civicrm/contact/view/note' not 'civicrm/contact/view/note-1'. Is there something going on the code to account for duplicates?  
  > **username_3**: Yes, the value need to be `civicrm/contact/view/note` and not note-1, 1 is the domain_id. I've updated the answer, but seems you've already checked for duplicate values in this table. I mentioned because this is what the error message in the backtrace meant to be. Not sure if it is related to the exect issue you're seeing.  
  > **username_0**: What about the log message about 'Invalid Filter'? It appears to relate dto custom groups, of which I have many. Not sure how this relates to the backtrace, but the error occurs in the log with every menu action. Also, not sure if I made it plain, all the actions/page loads succeed, very slowly but without a visible error unless debugging switched on.  
  
  ---
  
  