Answers.Body: <p>For 5.15.1 you can add these lines just before line 6373 in CRM/Contact/BAO/Query.php.</p>
  
  <pre><code>if (empty($fieldSpec['bao'])) {
    continue;
  }
  </code></pre>
  
  <p>There will also be a similar workaround put into 5.18.2 when it is released. <a href="https://github.com/civicrm/civicrm-core/pull/15454" rel="nofollow noreferrer">https://github.com/civicrm/civicrm-core/pull/15454</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-09T11:41:17.040Z
Answers.Text: Thanks, that worked! I also installed 5.18.2 today and the problem is gone.
Answers.UserDisplayName: minbori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-10-08T17:43:31.337Z
Answers.LastActivityDate: 2019-10-08T17:43:31.337Z
Answers.UserDisplayName: Demerit
Body: <p>this has me stumped, and wondering if anyone else has encountered it.</p>
  
  <p>I have a profile search results page where the result table includes both standard fields and custom fields.</p>
  
  <p>I am able to sort the table successfully on the standard fields by clicking the arrows/column headers, but the custom fields column sort fails. I see one of two errors:</p>
  
  <ol>
  <li><p>If I click the up/down arrows next to the column header text, a popup "Network Error Unable to reach the server. Please refresh this page in your browser and try again." appears, and a 500 server error is registered in the web server error log.</p></li>
  <li><p>If I click the column header text, I get a 404 page with the error message "Class name must be a valid object or a string" </p></li>
  </ol>
  
  <p>You can see this in action live at <a href="https://www.fawco.org/index.php?option=com_civicrm&amp;task=civicrm/profile&amp;force=1&amp;gid=18&amp;reset=1&amp;crmRowCount=100&amp;Itemid=388" rel="nofollow noreferrer">https://www.fawco.org/index.php?option=com_civicrm&amp;task=civicrm/profile&amp;force=1&amp;gid=18&amp;reset=1&amp;crmRowCount=100&amp;Itemid=388</a>
  ("Name" and "Country" are default fields, "FAWCO Region" is a custom field.)</p>
  
  <p>Per my testing:</p>
  
  <ul>
  <li>Search itself works properly.</li>
  <li>There are no errors in the CiviCRM log or the Joomla log. </li>
  <li>Joomla and CiviCRM debug modes have not shown any errors.</li>
  <li>web server logs report as described above, 500 for the sort request via arrow, 404 for the sort request via text.</li>
  <li>Adding and removing different default and custom fields to the results makes no difference: default columns consistently work and custom consistently fail.</li>
  </ul>
  
  <p>System is Joomla 3.9.10 with CiviCRM 5.15.1.</p>
  
  <p>Has anyone seen this before, or could someone give me a hint where I could start troubleshooting? </p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-02T11:30:30.630Z
Comments.Text: Further investigation: monitoring the network traffic, it's this custom field sort request that is failing:
  https://www.fawco.org/index.php?option=com_civicrm&task=civicrm/profile&Itemid=388&option=com_civicrm&force=1&gid=18&reset=1&crmRowCount=100&Itemid=388&crmSID=3_u&snippet=json
  
  But the exact same format request for the standard data field sort is successful.
  
  I just have no idea where to start looking for the difference in behavior.
Comments.UserDisplayName: minbori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-02T13:16:17.983Z
Comments.Text: Look in the apache error logs. It should give some info about the code file and line number where the "Class name must be a valid object or a string" error is happening.
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-04T11:34:16.403Z
Comments.Text: There is no event in the Apache error logs.  Am trying to test whether PHP errors are actually being logged.
Comments.UserDisplayName: minbori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-04T16:02:00.147Z
Comments.Text: OK, so here's the error:
  [04-Oct-2019 15:53:43 UTC] PHP Fatal error: Class name must be a valid object or a string in /home/fawcoho/public_html/administrator/components/com_civicrm/civicrm/CRM/Contact/BAO/Query.php on line 6373
Comments.UserDisplayName: minbori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-04T16:33:46.537Z
Comments.Text: Now I'm really not sure where to go next -- this is out-of-the-box CiviCRM code, nothing custom.
Comments.UserDisplayName: minbori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-04T16:36:36.570Z
Comments.Text: Yes this seems like a bug where it isn't able to get the right field definition. There's some comments in the code just above that line that seem like it's unfinished and doesn't handle this situation. Do you want to file a bug at https://lab.civicrm.org/dev/core/issues ?
Comments.UserDisplayName: Demerit
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-04T16:44:21.463Z
Comments.Text: I'll give it a try -- I didn't want to report a bug before I tried to figure out if the cause was something stupid I did! :-)  Thanks for the attention to my question.
Comments.UserDisplayName: minbori
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-10-07T17:20:19.700Z
Comments.Text: I added a note to https://lab.civicrm.org/dev/core/issues/1269 since it seems to be the same root cause.
Comments.UserDisplayName: Demerit
Tags: <joomla><search-results>
Title: can't sort search result table by column when the column shows a custom field
ThreadText: # can't sort search result table by column when the column shows a custom field
  
  (Asked by: username_0 on 2019-10-02)
  
  this has me stumped, and wondering if anyone else has encountered it.
  
  I have a profile search results page where the result table includes both standard fields and custom fields.
  
  I am able to sort the table successfully on the standard fields by clicking the arrows/column headers, but the custom fields column sort fails. I see one of two errors:
  
  1. If I click the up/down arrows next to the column header text, a popup "Network Error Unable to reach the server. Please refresh this page in your browser and try again." appears, and a 500 server error is registered in the web server error log.
  2. If I click the column header text, I get a 404 page with the error message "Class name must be a valid object or a string"
  
  You can see this in action live at <https://www.fawco.org/index.php?option=com_civicrm&task=civicrm/profile&force=1&gid=18&reset=1&crmRowCount=100&Itemid=388>
  ("Name" and "Country" are default fields, "FAWCO Region" is a custom field.)
  
  Per my testing:
  
  * Search itself works properly.
  * There are no errors in the CiviCRM log or the Joomla log.
  * Joomla and CiviCRM debug modes have not shown any errors.
  * web server logs report as described above, 500 for the sort request via arrow, 404 for the sort request via text.
  * Adding and removing different default and custom fields to the results makes no difference: default columns consistently work and custom consistently fail.
  
  System is Joomla 3.9.10 with CiviCRM 5.15.1.
  
  Has anyone seen this before, or could someone give me a hint where I could start troubleshooting?
  
  **Tags:** joomla, search-results
  
  > **Comments:**
  > **username_0**: Further investigation: monitoring the network traffic, it's this custom field sort request that is failing: https://www.fawco.org/index.php?option=com_civicrm&task=civicrm/profile&Itemid=388&option=com_civicrm&force=1&gid=18&reset=1&crmRowCount=100&Itemid=388&crmSID=3_u&snippet=json  But the exact same format request for the standard data field sort is successful.  I just have no idea where to start looking for the difference in behavior.  
  > **username_1**: Look in the apache error logs. It should give some info about the code file and line number where the "Class name must be a valid object or a string" error is happening.  
  > **username_0**: There is no event in the Apache error logs.  Am trying to test whether PHP errors are actually being logged.  
  > **username_0**: OK, so here's the error: [04-Oct-2019 15:53:43 UTC] PHP Fatal error: Class name must be a valid object or a string in /home/fawcoho/public_html/administrator/components/com_civicrm/civicrm/CRM/Contact/BAO/Query.php on line 6373  
  > **username_0**: Now I'm really not sure where to go next -- this is out-of-the-box CiviCRM code, nothing custom.  
  > **username_1**: Yes this seems like a bug where it isn't able to get the right field definition. There's some comments in the code just above that line that seem like it's unfinished and doesn't handle this situation. Do you want to file a bug at https://lab.civicrm.org/dev/core/issues ?  
  > **username_0**: I'll give it a try -- I didn't want to report a bug before I tried to figure out if the cause was something stupid I did! :-)  Thanks for the attention to my question.  
  > **username_1**: I added a note to https://lab.civicrm.org/dev/core/issues/1269 since it seems to be the same root cause.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2019-10-08. Score: 1 | Accepted answer
  
  For 5.15.1 you can add these lines just before line 6373 in CRM/Contact/BAO/Query.php.
  if (empty($fieldSpec['bao'])) {
    continue;
  }
  
  There will also be a similar workaround put into 5.18.2 when it is released. https://github.com/civicrm/civicrm-core/pull/15454
  
  > **Comments:**
  > **username_0**: Thanks, that worked! I also installed 5.18.2 today and the problem is gone.  
  
  ---
  
  