Answers.Body: <p>Well I think I resolved my issue.</p>
  <p>There was some HTML and JavaScript embedded in the description of one my memberships. I discovered it when inspecting the variables in <strong>JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031</strong> This info was relayed in the background and I am guessing PHP did not like it. After removing it, the error went away.</p>
  <p>Thanks for the pointers Jon G!</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-09-29T00:55:20.807Z
Answers.LastActivityDate: 2022-09-29T00:55:20.807Z
Answers.UserDisplayName: Joe989898
Body: <p>When manually adding without recording a membership payment or modifying a membership I am getting an an error 500. Renewing with payment from front-end and manually adding a membership when recording a payment still works.</p>
  <p>The error happens when doing the AJAX call to:</p>
  <p><code>https://mysite.com/administrator/?option=com_civicrm&amp;task=civicrm/contact/view/membership&amp;action=add&amp;cid=2180&amp;context=membership&amp;snippet=json</code></p>
  <p>When enabling debugging, the response contains this error:</p>
  <p><code>0 key(): Argument #1 ($array) must be of type array, null given</code></p>
  <p>We have noticed this in CiviCRM 5.50.3, but it still occurs after upgrading to 5.53.0. I have also tried with PHP 7.4 and 8.0.</p>
  <p>I am currently running on Joomla 3.10.11, CiviCRM 5.53.0 and PHP 8.0.</p>
  <p>Edit: I could not get a backtrace because the error seems to have been caught by Joomla, not by CiviCRM. Nothing were in my logs, so I enabled debugging in Joomla to find the following:</p>
  <pre>
  An error has occurred.
  
      0 key(): Argument #1 ($array) must be of type array, null given
      /var/www/public_html/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031 
  
  Call stack
  #   Function    Location
  1   ()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031
  2   key()   JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031
  3   CRM_Member_BAO_Membership::setQuickConfigMembershipParameters()     JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form.php:444
  4   CRM_Member_Form->ensurePriceParamsAreSet()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form.php:497
  5   CRM_Member_Form->setPriceSetParameters()    JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form/Membership.php:1019
  6   CRM_Member_Form_Membership->submit()    JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form/Membership.php:878
  7   CRM_Member_Form_Membership->postProcess()   JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php:573
  8   CRM_Core_Form->mainProcess()    JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php:152
  9   CRM_Core_QuickForm_Action_Upload->realPerform()     JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php:119
  10  CRM_Core_QuickForm_Action_Upload->perform()     JROOT/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php:203
  11  HTML_QuickForm_Controller->handle()     JROOT/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php:103
  12  HTML_QuickForm_Page->handle()   JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php:355
  13  CRM_Core_Controller->run()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Page/Tab.php:324
  14  CRM_Member_Page_Tab->edit()     JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Page/Tab.php:394
  15  CRM_Member_Page_Tab->run()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php:319
  16  CRM_Core_Invoke::runItem()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php:69
  17  CRM_Core_Invoke::_invoke()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php:36
  18  CRM_Core_Invoke::invoke()   JROOT/administrator/components/com_civicrm/civicrm.php:121
  19  civicrm_invoke()    JROOT/administrator/components/com_civicrm/civicrm.php:40
  20  require_once()  JROOT/libraries/src/Component/ComponentHelper.php:402
  21  Joomla\CMS\Component\ComponentHelper::executeComponent()    JROOT/libraries/src/Component/ComponentHelper.php:377
  22  Joomla\CMS\Component\ComponentHelper::renderComponent()     JROOT/libraries/src/Application/AdministratorApplication.php:101
  23  Joomla\CMS\Application\AdministratorApplication->dispatch()     JROOT/libraries/src/Application/AdministratorApplication.php:159
  24  Joomla\CMS\Application\AdministratorApplication->doExecute()    JROOT/libraries/src/Application/CMSApplication.php:225
  25  Joomla\CMS\Application\CMSApplication->execute()    JROOT/administrator/index.php:51 
  </pre>
  <p>Edit 2: If it helps, this was an ancient install that was running Joomla 1.5 and CiviCRM 3.4.8 then progressively upgraded to the current version.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-14T12:17:09.707Z
Comments.Text: Could you also enable backtrace and post the full backtrace here?
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-23T17:34:30.103Z
Comments.Text: Thanks for the reply @JonG-MegaphoneTech, sorry for the delay. I posted the backtrace in an edit.
Comments.UserDisplayName: Joe989898
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-23T20:57:02.967Z
Comments.Text: I don't think this is the correct backtrace, since the error is different.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-26T19:11:44.790Z
Comments.Text: You are right, I had not noticed it. It is odd though I can reproduce the error, it does not seem to produce a backtrace. Is that possible?
Comments.UserDisplayName: Joe989898
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-26T19:34:24.553Z
Comments.Text: I'm not familiar with Joomla - but I know that Drupal catches certain backtraces in its "watchdog" table, and WordPress errors end up in the PHP log (in the `/var/log` folder on Debian/Ubuntu-likes).  You may want to look for your PHP log.  Note that if you use `mod_php` rather than `php-fpm` it may be in your Apache log.
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-28T00:35:03.360Z
Comments.Text: I think I found the proper details of the error. From what I can figure is that it expects a price set, but none is given?
Comments.UserDisplayName: Joe989898
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-09-28T14:37:28.833Z
Comments.Text: That's the correct backtrace - but looking at the code, I don't think I can resolve this without knowing more about your data - but yes, I think there's a price set problem.
Comments.UserDisplayName: Jon G - Megaphone Tech
Tags: <civimember><joomla><error-page>
Title: Error 500 when adding or modifying membership
ThreadText: # Error 500 when adding or modifying membership
  
  (Asked by: username_0 on 2022-09-14)
  
  When manually adding without recording a membership payment or modifying a membership I am getting an an error 500. Renewing with payment from front-end and manually adding a membership when recording a payment still works.
  The error happens when doing the AJAX call to:
  https://mysite.com/administrator/?option=com_civicrm&task=civicrm/contact/view/membership&action=add&cid=2180&context=membership&snippet=json
  When enabling debugging, the response contains this error:
  0 key(): Argument #1 ($array) must be of type array, null given
  We have noticed this in CiviCRM 5.50.3, but it still occurs after upgrading to 5.53.0. I have also tried with PHP 7.4 and 8.0.
  I am currently running on Joomla 3.10.11, CiviCRM 5.53.0 and PHP 8.0.
  Edit: I could not get a backtrace because the error seems to have been caught by Joomla, not by CiviCRM. Nothing were in my logs, so I enabled debugging in Joomla to find the following:
  
  An error has occurred.
  
      0 key(): Argument #1 ($array) must be of type array, null given
      /var/www/public_html/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031 
  
  Call stack
  #   Function    Location
  1   ()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031
  2   key()   JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031
  3   CRM_Member_BAO_Membership::setQuickConfigMembershipParameters()     JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form.php:444
  4   CRM_Member_Form->ensurePriceParamsAreSet()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form.php:497
  5   CRM_Member_Form->setPriceSetParameters()    JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form/Membership.php:1019
  6   CRM_Member_Form_Membership->submit()    JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Form/Membership.php:878
  7   CRM_Member_Form_Membership->postProcess()   JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php:573
  8   CRM_Core_Form->mainProcess()    JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php:152
  9   CRM_Core_QuickForm_Action_Upload->realPerform()     JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php:119
  10  CRM_Core_QuickForm_Action_Upload->perform()     JROOT/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php:203
  11  HTML_QuickForm_Controller->handle()     JROOT/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php:103
  12  HTML_QuickForm_Page->handle()   JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php:355
  13  CRM_Core_Controller->run()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Page/Tab.php:324
  14  CRM_Member_Page_Tab->edit()     JROOT/administrator/components/com_civicrm/civicrm/CRM/Member/Page/Tab.php:394
  15  CRM_Member_Page_Tab->run()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php:319
  16  CRM_Core_Invoke::runItem()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php:69
  17  CRM_Core_Invoke::_invoke()  JROOT/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php:36
  18  CRM_Core_Invoke::invoke()   JROOT/administrator/components/com_civicrm/civicrm.php:121
  19  civicrm_invoke()    JROOT/administrator/components/com_civicrm/civicrm.php:40
  20  require_once()  JROOT/libraries/src/Component/ComponentHelper.php:402
  21  Joomla\CMS\Component\ComponentHelper::executeComponent()    JROOT/libraries/src/Component/ComponentHelper.php:377
  22  Joomla\CMS\Component\ComponentHelper::renderComponent()     JROOT/libraries/src/Application/AdministratorApplication.php:101
  23  Joomla\CMS\Application\AdministratorApplication->dispatch()     JROOT/libraries/src/Application/AdministratorApplication.php:159
  24  Joomla\CMS\Application\AdministratorApplication->doExecute()    JROOT/libraries/src/Application/CMSApplication.php:225
  25  Joomla\CMS\Application\CMSApplication->execute()    JROOT/administrator/index.php:51 
  
  Edit 2: If it helps, this was an ancient install that was running Joomla 1.5 and CiviCRM 3.4.8 then progressively upgraded to the current version.
  
  **Tags:** civimember, joomla, error-page
  
  > **Comments:**
  > **username_1**: Could you also enable backtrace and post the full backtrace here?  
  > **username_0**: Thanks for the reply @JonG-MegaphoneTech, sorry for the delay. I posted the backtrace in an edit.  
  > **username_1**: I don't think this is the correct backtrace, since the error is different.  
  > **username_0**: You are right, I had not noticed it. It is odd though I can reproduce the error, it does not seem to produce a backtrace. Is that possible?  
  > **username_1**: I'm not familiar with Joomla - but I know that Drupal catches certain backtraces in its "watchdog" table, and WordPress errors end up in the PHP log (in the `/var/log` folder on Debian/Ubuntu-likes).  You may want to look for your PHP log.  Note that if you use `mod_php` rather than `php-fpm` it may be in your Apache log.  
  > **username_0**: I think I found the proper details of the error. From what I can figure is that it expects a price set, but none is given?  
  > **username_1**: That's the correct backtrace - but looking at the code, I don't think I can resolve this without knowing more about your data - but yes, I think there's a price set problem.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2022-09-29. Score: 2 | Accepted answer
  
  Well I think I resolved my issue.
  
  There was some HTML and JavaScript embedded in the description of one my memberships. I discovered it when inspecting the variables in **JROOT/administrator/components/com\_civicrm/civicrm/CRM/Member/BAO/Membership.php:2031** This info was relayed in the background and I am guessing PHP did not like it. After removing it, the error went away.
  
  Thanks for the pointers Jon G!
  
  
  ---
  
  