Body: <p>I'm using Wordpress 5.8 and civicrm 5.39.0.</p>
  <p>I think i found a bug. I get an error when i want to view the smart groups on a contact card. The error is:
  INSERT IGNORE INTO civicrm_tmp_e_gccache_e272cc7d39a4f55ebaea6f3ecbb56684 (group_id, contact_id) SELECT 113 AS group_id, contact_a.id as id FROM civicrm_contact contact_a WHERE ( ( contact_a.modified_date &lt; '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = 113 ) [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '; '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT ...' at line 1]</p>
  <p>I copied the &quot;SELECT&quot; statemant and run it from the command line, but i dident get any error's. After searching and print the $sql varaiable from the code in &quot;CRM/Contact/BAO/GroupContactCache.php&quot; (around line 820), i saw that the '&lt;' is really a '&amp;lt;'. And i fixed it temporary with &quot;$sql = str_replace('&amp;lt;', '&lt;', $sql);&quot;.</p>
  <p>Can someone reproduce this error?
  And i can't see where it gose wrong, can someone find out where the real problem comes from? (and possible a fix)</p>
  <p>The full error is:</p>
  <p>Fout Veld   Foutwaarde
  Type    DB_Error
  Code    -2
  Message DB Error: syntax error
  Mode    16
  UserInfo    INSERT IGNORE INTO civicrm_tmp_e_gccache_c626e96b4b2c3d1ef1860608883c1550 (group_id, contact_id) SELECT 113 AS group_id, contact_a.id as id FROM civicrm_contact contact_a WHERE ( ( contact_a.modified_date &lt; '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = 113 ) [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '; '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT ...' at line 1]
  DebugInfo   INSERT IGNORE INTO civicrm_tmp_e_gccache_c626e96b4b2c3d1ef1860608883c1550 (group_id, contact_id) SELECT 113 AS group_id, contact_a.id as id FROM civicrm_contact contact_a WHERE ( ( contact_a.modified_date &lt; '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = 113 ) [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '; '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT ...' at line 1]
  PEAR_Exception: DB Error: syntax error in /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php on line 922</p>
  <ul>
  <li>DB_Error: DB Error: syntax error in unknown on line unknown
  Exception trace</li>
  </ul>
  <h1>Function    Location</h1>
  <p>0   CRM_Core_Error::exceptionHandler(Object(DB_Error))  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:922
  1   PEAR_Error-&gt;__construct('DB Error: syntax…', -2, 16, Array, 'INSERT IGNORE IN…')    /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB.php:997
  2   DB_Error-&gt;__construct(-2, 16, Array, 'INSERT IGNORE IN…')   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:575
  3   PEAR-&gt;_raiseError(Object(DB_mysqli), null, -2, 16, Array, 'INSERT IGNORE IN…', 'DB_Error', true)    /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:223
  4   PEAR-&gt;__call('raiseError', Array)   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php:1928
  5   DB_common-&gt;raiseError(-2, null, null, 'INSERT IGNORE IN…', '1064 ** You have…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php:936
  6   DB_mysqli-&gt;mysqliRaiseError()   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php:406
  7   DB_mysqli-&gt;simpleQuery('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php:1234
  8   DB_common-&gt;query('INSERT IGNORE IN…')   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php:2696
  9   DB_DataObject-&gt;_query('INSERT IGNORE IN…')  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php:1829
  10  DB_DataObject-&gt;query('INSERT IGNORE IN…')   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php:454
  11  CRM_Core_DAO-&gt;query('INSERT IGNORE IN…', true)  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php:1599
  12  CRM_Core_DAO::executeQuery('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:836
  13  CRM_Contact_BAO_GroupContactCache::insertGroupContactsIntoTempTable('civicrm_tmp_e_gc…', 113, 42, null) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:640
  14  CRM_Contact_BAO_GroupContactCache::buildGroupContactTempTable(Array, Object(CRM_Utils_SQL_TempTable))   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:380
  15  CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:3167
  16  CRM_Contact_BAO_Query-&gt;addGroupContactCache(Array, 'civicrm_group_co…', 'contact_a', 'IN')  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:3068
  17  CRM_Contact_BAO_Query-&gt;group(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:1830
  18  CRM_Contact_BAO_Query-&gt;whereClauseSingle(Array, false)  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:2068
  19  CRM_Contact_BAO_Query-&gt;whereClause(false)   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:575
  20  CRM_Contact_BAO_Query-&gt;initialize(null) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:524
  21  CRM_Contact_BAO_Query-&gt;__construct(Array, Array, Array, true, false, 1, true, true, false, null, 'AND', null, 1)    /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:4594
  22  CRM_Contact_BAO_Query::apiQuery(Array, Array, null, null, 0, 0, false)  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:152
  23  CRM_Contact_BAO_GroupContactCache::add(Array)   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:135
  24  CRM_Contact_BAO_GroupContactCache::loadAll()    /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:446
  25  CRM_Contact_BAO_GroupContactCache::contactGroup(4271)   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/View/ContactSmartGroup.php:41
  26  CRM_Contact_Page_View_ContactSmartGroup-&gt;browse()   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/View/ContactSmartGroup.php:89
  27  CRM_Contact_Page_View_ContactSmartGroup-&gt;run(Array, null)   /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:313
  28  CRM_Core_Invoke::runItem(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69
  29  CRM_Core_Invoke::_invoke(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36
  30  CRM_Core_Invoke::invoke(Array)  /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm.php:1172
  31  CiviCRM_For_WordPress-&gt;invoke('')   /domains/eestertest.nl/crm/wp-includes/class-wp-hook.php:303
  32  WP_Hook-&gt;apply_filters('', Array)   /domains/eestertest.nl/crm/wp-includes/class-wp-hook.php:327
  33  WP_Hook-&gt;do_action(Array)   /domains/eestertest.nl/crm/wp-includes/plugin.php:470
  34  do_action('toplevel_page_Ci…')  /domains/eestertest.nl/crm/wp-admin/admin.php:259
  35  {main}</p>
  <p>Kind regards,</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-02T23:10:14.307Z
Comments.Text: It seems ok on https://wpmaster.demo.civicrm.org. You could try around line 820 putting `CRM_Core_Error::backtrace('testing', TRUE);` and then check in ConfigAndLog to see if the trace tells you where it's coming from.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-09T14:48:34.993Z
Comments.Text: If you run this query against the database manually (using phpmyadmin or whatever) what happens: `SELECT 113 AS group_id, contact_a.id as id FROM civicrm_contact contact_a WHERE ( ( contact_a.modified_date < '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = 113 )`
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-13T09:06:37.727Z
Comments.Text: If I run the query it goes well. but what i see is that the "contact_a.modified_date < '20190501000000' )" is in fact "contact_a.modified_date &lt; '20190501000000' )", that's the whole problem! It runs perfectly when i add "$sql = str_replace('&lt;', '<', $sql);" to the code, but without it I get the error!? Strange, not? I cannot see where the problem comes from?
Comments.UserDisplayName: Jan-Derek Vos
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-13T13:08:44.947Z
Comments.Text: Are you able to edit the smart group criteria? Maybe just re-save it? The `contact_a.modified_date < '20190501000000'` part would be coming from the smart group criteria, so maybe something is messed up in the smart group.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-17T09:26:05.347Z
Comments.Text: I will try it !
Comments.UserDisplayName: Jan-Derek Vos
Tags: <error><smartgroups><contact-view>
Title: DB Error: syntax error INSERT IGNORE INTO civicrm_tmp_e_gccache a &lt; problem
ThreadText: # DB Error: syntax error INSERT IGNORE INTO civicrm_tmp_e_gccache a &lt; problem
  
  (Asked by: username_0 on 2021-08-02)
  
  I'm using Wordpress 5.8 and civicrm 5.39.0.
  
  I think i found a bug. I get an error when i want to view the smart groups on a contact card. The error is:
  INSERT IGNORE INTO civicrm\_tmp\_e\_gccache\_e272cc7d39a4f55ebaea6f3ecbb56684 (group\_id, contact\_id) SELECT 113 AS group\_id, contact\_a.id as id FROM civicrm\_contact contact\_a WHERE ( ( contact\_a.modified\_date < '20190501000000' ) ) AND (contact\_a.is\_deleted = 0) AND contact\_a.id NOT IN ( SELECT contact\_id FROM civicrm\_group\_contact WHERE civicrm\_group\_contact.status = 'Removed' AND civicrm\_group\_contact.group\_id = 113 ) [nativecode=1064 \*\* You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '; '20190501000000' ) ) AND (contact\_a.is\_deleted = 0) AND contact\_a.id NOT ...' at line 1]
  
  I copied the "SELECT" statemant and run it from the command line, but i dident get any error's. After searching and print the $sql varaiable from the code in "CRM/Contact/BAO/GroupContactCache.php" (around line 820), i saw that the '<' is really a '&lt;'. And i fixed it temporary with "$sql = str\_replace('&lt;', '<', $sql);".
  
  Can someone reproduce this error?
  And i can't see where it gose wrong, can someone find out where the real problem comes from? (and possible a fix)
  
  The full error is:
  
  Fout Veld Foutwaarde
  Type DB\_Error
  Code -2
  Message DB Error: syntax error
  Mode 16
  UserInfo INSERT IGNORE INTO civicrm\_tmp\_e\_gccache\_c626e96b4b2c3d1ef1860608883c1550 (group\_id, contact\_id) SELECT 113 AS group\_id, contact\_a.id as id FROM civicrm\_contact contact\_a WHERE ( ( contact\_a.modified\_date < '20190501000000' ) ) AND (contact\_a.is\_deleted = 0) AND contact\_a.id NOT IN ( SELECT contact\_id FROM civicrm\_group\_contact WHERE civicrm\_group\_contact.status = 'Removed' AND civicrm\_group\_contact.group\_id = 113 ) [nativecode=1064 \*\* You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '; '20190501000000' ) ) AND (contact\_a.is\_deleted = 0) AND contact\_a.id NOT ...' at line 1]
  DebugInfo INSERT IGNORE INTO civicrm\_tmp\_e\_gccache\_c626e96b4b2c3d1ef1860608883c1550 (group\_id, contact\_id) SELECT 113 AS group\_id, contact\_a.id as id FROM civicrm\_contact contact\_a WHERE ( ( contact\_a.modified\_date < '20190501000000' ) ) AND (contact\_a.is\_deleted = 0) AND contact\_a.id NOT IN ( SELECT contact\_id FROM civicrm\_group\_contact WHERE civicrm\_group\_contact.status = 'Removed' AND civicrm\_group\_contact.group\_id = 113 ) [nativecode=1064 \*\* You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '; '20190501000000' ) ) AND (contact\_a.is\_deleted = 0) AND contact\_a.id NOT ...' at line 1]
  PEAR\_Exception: DB Error: syntax error in /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php on line 922
  
  * DB\_Error: DB Error: syntax error in unknown on line unknown
    Exception trace
  
  # Function Location
  
  0 CRM\_Core\_Error::exceptionHandler(Object(DB\_Error)) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:922
  1 PEAR\_Error->\_\_construct('DB Error: syntax…', -2, 16, Array, 'INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB.php:997
  2 DB\_Error->\_\_construct(-2, 16, Array, 'INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:575
  3 PEAR->\_raiseError(Object(DB\_mysqli), null, -2, 16, Array, 'INSERT IGNORE IN…', 'DB\_Error', true) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/pear-core-minimal/src/PEAR.php:223
  4 PEAR->\_\_call('raiseError', Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php:1928
  5 DB\_common->raiseError(-2, null, null, 'INSERT IGNORE IN…', '1064 \*\* You have…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php:936
  6 DB\_mysqli->mysqliRaiseError() /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/mysqli.php:406
  7 DB\_mysqli->simpleQuery('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/vendor/pear/db/DB/common.php:1234
  8 DB\_common->query('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php:2696
  9 DB\_DataObject->\_query('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php:1829
  10 DB\_DataObject->query('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php:454
  11 CRM\_Core\_DAO->query('INSERT IGNORE IN…', true) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php:1599
  12 CRM\_Core\_DAO::executeQuery('INSERT IGNORE IN…') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:836
  13 CRM\_Contact\_BAO\_GroupContactCache::insertGroupContactsIntoTempTable('civicrm\_tmp\_e\_gc…', 113, 42, null) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:640
  14 CRM\_Contact\_BAO\_GroupContactCache::buildGroupContactTempTable(Array, Object(CRM\_Utils\_SQL\_TempTable)) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:380
  15 CRM\_Contact\_BAO\_GroupContactCache::load(Object(CRM\_Core\_DAO)) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:3167
  16 CRM\_Contact\_BAO\_Query->addGroupContactCache(Array, 'civicrm\_group\_co…', 'contact\_a', 'IN') /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:3068
  17 CRM\_Contact\_BAO\_Query->group(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:1830
  18 CRM\_Contact\_BAO\_Query->whereClauseSingle(Array, false) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:2068
  19 CRM\_Contact\_BAO\_Query->whereClause(false) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:575
  20 CRM\_Contact\_BAO\_Query->initialize(null) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:524
  21 CRM\_Contact\_BAO\_Query->\_\_construct(Array, Array, Array, true, false, 1, true, true, false, null, 'AND', null, 1) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php:4594
  22 CRM\_Contact\_BAO\_Query::apiQuery(Array, Array, null, null, 0, 0, false) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:152
  23 CRM\_Contact\_BAO\_GroupContactCache::add(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:135
  24 CRM\_Contact\_BAO\_GroupContactCache::loadAll() /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/GroupContactCache.php:446
  25 CRM\_Contact\_BAO\_GroupContactCache::contactGroup(4271) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/View/ContactSmartGroup.php:41
  26 CRM\_Contact\_Page\_View\_ContactSmartGroup->browse() /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Contact/Page/View/ContactSmartGroup.php:89
  27 CRM\_Contact\_Page\_View\_ContactSmartGroup->run(Array, null) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:313
  28 CRM\_Core\_Invoke::runItem(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69
  29 CRM\_Core\_Invoke::\_invoke(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36
  30 CRM\_Core\_Invoke::invoke(Array) /domains/eestertest.nl/crm/wp-content/plugins/civicrm/civicrm.php:1172
  31 CiviCRM\_For\_WordPress->invoke('') /domains/eestertest.nl/crm/wp-includes/class-wp-hook.php:303
  32 WP\_Hook->apply\_filters('', Array) /domains/eestertest.nl/crm/wp-includes/class-wp-hook.php:327
  33 WP\_Hook->do\_action(Array) /domains/eestertest.nl/crm/wp-includes/plugin.php:470
  34 do\_action('toplevel\_page\_Ci…') /domains/eestertest.nl/crm/wp-admin/admin.php:259
  35 {main}
  
  Kind regards,
  
  **Tags:** error, smartgroups, contact-view
  
  > **Comments:**
  > **username_1**: It seems ok on https://wpmaster.demo.civicrm.org. You could try around line 820 putting `CRM_Core_Error::backtrace('testing', TRUE);` and then check in ConfigAndLog to see if the trace tells you where it's coming from.  
  > **username_1**: If you run this query against the database manually (using phpmyadmin or whatever) what happens: `SELECT 113 AS group_id, contact_a.id as id FROM civicrm_contact contact_a WHERE ( ( contact_a.modified_date < '20190501000000' ) ) AND (contact_a.is_deleted = 0) AND contact_a.id NOT IN ( SELECT contact_id FROM civicrm_group_contact WHERE civicrm_group_contact.status = 'Removed' AND civicrm_group_contact.group_id = 113 )`  
  > **username_0**: If I run the query it goes well. but what i see is that the "contact_a.modified_date < '20190501000000' )" is in fact "contact_a.modified_date &lt; '20190501000000' )", that's the whole problem! It runs perfectly when i add "$sql = str_replace('&lt;', '<', $sql);" to the code, but without it I get the error!? Strange, not? I cannot see where the problem comes from?  
  > **username_1**: Are you able to edit the smart group criteria? Maybe just re-save it? The `contact_a.modified_date < '20190501000000'` part would be coming from the smart group criteria, so maybe something is messed up in the smart group.  
  > **username_0**: I will try it !  
  
  ---
  
  ## 0 answers
  
  