Answers.Body: <p>This sounds the same as <a href="https://lab.civicrm.org/dev/core/-/issues/2301#note_52815" rel="nofollow noreferrer">https://lab.civicrm.org/dev/core/-/issues/2301#note_52815</a> but it's a bit hard to fix properly because there are multiple problems at once and the validation on that form is not correct to begin with.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-06-08T20:06:56.567Z
Answers.LastActivityDate: 2022-06-08T20:06:56.567Z
Answers.UserDisplayName: Demerit
Body: <p>I'm running against a fatal error when I attempt to update my user profile on a drupal9/civicrm5.49.5 setup (url path: /user/1/edit/profile/1).</p>
  <p>The error message is as follows:</p>
  <pre><code>The website encountered an unexpected error. Please try again later.
  TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in include() (line 15 of sites/default/files/civicrm/templates_c/en_US/%%4D/4DC/4DC76B26%%body.tpl.php).
  
  include() (Line: 1914)
  Smarty-&gt;_smarty_include(Array) (Line: 43)
  include('/app/web/sites/default/files/civicrm/templates_c/en_US/%%0A/0AF/0AF6F87E%%Dynamic.tpl.php') (Line: 1273)
  Smarty-&gt;fetch('CRM/Profile/Form/Dynamic.tpl', NULL, NULL, ) (Line: 185)
  CRM_Core_Smarty-&gt;fetch('CRM/Profile/Form/Dynamic.tpl') (Line: 930)
  CRM_Core_BAO_UFGroup::getEditHTML(203, 'Name and Address') (Line: 86)
  Drupal\civicrm\Form\UserProfile-&gt;buildForm(Array, Object, Object, '1')
  call_user_func_array(Array, Array) (Line: 531)
  Drupal\Core\Form\FormBuilder-&gt;retrieveForm('civicrm_user_profile', Object) (Line: 278)
  Drupal\Core\Form\FormBuilder-&gt;buildForm(Object, Object) (Line: 73)
  Drupal\Core\Controller\FormController-&gt;getContentResult(Object, Object)
  call_user_func_array(Array, Array) (Line: 123)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 564)
  Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 158)
  Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 80)
  Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 58)
  Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 48)
  Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 106)
  Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
  Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 48)
  Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 51)
  Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 23)
  Stack\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 708)
  Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
  </code></pre>
  <p>I suspect a problem with PHP 8 support. The problem goes away after downgrading PHP to 7.4. to be more specific, the error is not FATAL on 7.4 and is fatal PHP 8+</p>
  <p>Seems related to another PHP 7.4, PHP 8 TypeError I encountered when making adjustments to the search preferences, unchecking not needed fields and checking new custom fields, reordering or any change on the search preferences page. no autocomplete drop down anymore and when I TRY to go back into search preferences, error is thrown with:</p>
  <p><code>The website encountered an unexpected error. Please try again later. TypeError: array_flip(): Argument #1 ($array) must be of type array, string given in array_flip() (line 380 of /code/vendor/civicrm/civicrm-core/CRM/Admin/Form/SettingTrait.php). array_flip('external_identifiersort_namecitycustom_Annuity_Balancecustom_PAP_Balancecustom_Pension_Credits_to_Date') (Line: 380) CRM_Admin_Form_Setting::reorderSortableOptions('quicksearch_options', Array) (Line: 224) CRM_Admin_Form_Setting-&gt;addFieldsDefinedInSettingsMetadata() (Line: 66) CRM_Admin_Form_Setting-&gt;buildQuickForm() (Line: 47) CRM_Admin_Form_Setting_Search-&gt;buildQuickForm() (Line: 689) CRM_Core_Form-&gt;buildForm() (Line: 76).... and more..</code></p>
  <p>This is Fatal because of php 8? Not fatal on php 7.4.</p>
  <p>This issue is related to CiviCRM 5.55.1 .2 and 5.56</p>
  <p>I did create an issue of this and <a href="https://lab.civicrm.org/dev/core/-/issues/4022" rel="nofollow noreferrer">filed as bug.</a></p>
  
Tags: <profile><php>
Title: PHP 7.4 error, PHP 8 Fatal Error - TypeError: array_flip() related to Search Prefrences
ThreadText: # PHP 7.4 error, PHP 8 Fatal Error - TypeError: array_flip() related to Search Prefrences
  
  (Asked by: username_0 on 2022-06-08)
  
  I'm running against a fatal error when I attempt to update my user profile on a drupal9/civicrm5.49.5 setup (url path: /user/1/edit/profile/1).
  The error message is as follows:
  The website encountered an unexpected error. Please try again later.
  TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in include() (line 15 of sites/default/files/civicrm/templates_c/en_US/%%4D/4DC/4DC76B26%%body.tpl.php).
  
  include() (Line: 1914)
  Smarty->_smarty_include(Array) (Line: 43)
  include('/app/web/sites/default/files/civicrm/templates_c/en_US/%%0A/0AF/0AF6F87E%%Dynamic.tpl.php') (Line: 1273)
  Smarty->fetch('CRM/Profile/Form/Dynamic.tpl', NULL, NULL, ) (Line: 185)
  CRM_Core_Smarty->fetch('CRM/Profile/Form/Dynamic.tpl') (Line: 930)
  CRM_Core_BAO_UFGroup::getEditHTML(203, 'Name and Address') (Line: 86)
  Drupal\civicrm\Form\UserProfile->buildForm(Array, Object, Object, '1')
  call_user_func_array(Array, Array) (Line: 531)
  Drupal\Core\Form\FormBuilder->retrieveForm('civicrm_user_profile', Object) (Line: 278)
  Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
  Drupal\Core\Controller\FormController->getContentResult(Object, Object)
  call_user_func_array(Array, Array) (Line: 123)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
  Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
  Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
  Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
  Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
  Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
  Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
  Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
  Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
  Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
  Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
  Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 708)
  Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
  
  I suspect a problem with PHP 8 support. The problem goes away after downgrading PHP to 7.4. to be more specific, the error is not FATAL on 7.4 and is fatal PHP 8+
  Seems related to another PHP 7.4, PHP 8 TypeError I encountered when making adjustments to the search preferences, unchecking not needed fields and checking new custom fields, reordering or any change on the search preferences page. no autocomplete drop down anymore and when I TRY to go back into search preferences, error is thrown with:
  The website encountered an unexpected error. Please try again later. TypeError: array_flip(): Argument #1 ($array) must be of type array, string given in array_flip() (line 380 of /code/vendor/civicrm/civicrm-core/CRM/Admin/Form/SettingTrait.php). array_flip('external_identifiersort_namecitycustom_Annuity_Balancecustom_PAP_Balancecustom_Pension_Credits_to_Date') (Line: 380) CRM_Admin_Form_Setting::reorderSortableOptions('quicksearch_options', Array) (Line: 224) CRM_Admin_Form_Setting->addFieldsDefinedInSettingsMetadata() (Line: 66) CRM_Admin_Form_Setting->buildQuickForm() (Line: 47) CRM_Admin_Form_Setting_Search->buildQuickForm() (Line: 689) CRM_Core_Form->buildForm() (Line: 76).... and more..
  This is Fatal because of php 8? Not fatal on php 7.4.
  This issue is related to CiviCRM 5.55.1 .2 and 5.56
  I did create an issue of this and filed as bug.
  
  **Tags:** profile, php
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-06-08. Score: 1
  
  This sounds the same as <https://lab.civicrm.org/dev/core/-/issues/2301#note_52815> but it's a bit hard to fix properly because there are multiple problems at once and the validation on that form is not correct to begin with.
  
  
  ---
  
  