1

We're using CiviCase as a project tracker and document generator. It has been working fine, but I had to recently move the site to a new server. The directory structure, domain, database all stayed the same, but it's a new OS install on a new VPS. When we run "Print/Merge Document" on the "Manage Case" page, the task fails with the error "Cannot instantiate malformed locale: EN". There is a little more info in the CiviCRM log, but it doesn't tell me anything more that I can make sense of. I assume there is some issue with the php or system locale, but I can't figure out what.

Any thoughts?

CiviCRM log:

Oct 02 16:21:24  [error]
$Fatal Error Details = array:3 [
  "message" => "Cannot instantiate malformed locale: EN"
  "code" => null
  "exception" => CRM_Core_Exception {#11809
    -errorData: array:1 [
      "error_code" => 0
    ]
    #cause: null
    -_trace: null
    #message: "Cannot instantiate malformed locale: EN"
    #code: 0
    #file: "/var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/Core/Locale.php"
    #line: 177
    trace: {
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/Core/Locale.php:177 {
        Civi\Core\Locale::negotiate(string $preferred): Locale
        › if (!preg_match(';^[a-z][a-z]_[A-Z][A-Z]$;', $preferred)) {
        ›   throw new \CRM_Core_Exception("Cannot instantiate malformed locale: $preferred");
        › }
      }
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Subscriber/I18nSubscriber.php:61 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php:251 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/vendor/symfony/event-dispatcher/EventDispatcher.php:73 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/Core/CiviEventDispatcher.php:260 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php:249 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php:157 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/Civi/Api4/Generic/AbstractAction.php:249 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/MessageTemplate.php:484 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/MessageTemplate.php:345 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/BAO/MessageTemplate.php:271 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Contact/Form/Task/PDFTrait.php:240 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php:612 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php:153 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Upload.php:120 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php:203 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php:103 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php:355 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Utils/Wrapper.php:98 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:292 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:69 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php:36 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm.php:1199 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-includes/class-wp-hook.php:310 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-includes/class-wp-hook.php:334 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-includes/plugin.php:517 { …}
      /var/www/civi.waccglobal.org/wordpress/wp-admin/admin.php:259 { …}
    }
  }
]


Oct 02 16:21:24  [debug] $backTrace = #0 /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(443): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(39): CRM_Core_Error::handleUnhandledException(Object(CRM_Core_Exception))
#2 /var/www/civi.waccglobal.org/wordpress/wp-content/plugins/civicrm/civicrm.php(1199): CRM_Core_Invoke::invoke((Array:4))
#3 /var/www/civi.waccglobal.org/wordpress/wp-includes/class-wp-hook.php(310): CiviCRM_For_WordPress->invoke("")
#4 /var/www/civi.waccglobal.org/wordpress/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters("", (Array:1))
#5 /var/www/civi.waccglobal.org/wordpress/wp-includes/plugin.php(517): WP_Hook->do_action((Array:1))
#6 /var/www/civi.waccglobal.org/wordpress/wp-admin/admin.php(259): do_action("toplevel_page_CiviCRM")
#7 {main}

We're running on WordPress 6.3.1 on Debian 12 (bookworm). CiviCRM version 5.63.2. Yes I do need to upgrade. However, experience has shown I should fix errors before doing so.

2
  • It's expecting something like en_US not just "en". The question is where is it getting that from. The rest of the stacktrace might actually be helpful.
    – Demerit
    Sep 28, 2023 at 23:44
  • Thanks @demerit I've included the full trace now
    – kapn
    Oct 2, 2023 at 20:33

1 Answer 1

1

Ah that does help. It's likely one of the contacts has a malformed preferred_language on their contact where it has EN instead of en_SOMETHING.

From https://github.com/civicrm/civicrm-core/blob/c3a9a0894c3702d961d4bcaf61a3404e66c56371/CRM/Core/BAO/MessageTemplate.php#L343

You can run a query on the database like SELECT id FROM civicrm_contact WHERE preferred_language = 'EN' to find the contact id.

1
  • 1
    Thank you! Seems like every English contact was set as EN. It must have been acceptable on the previous server. Changed every one to en_US and now documents generate fine.
    – kapn
    Oct 2, 2023 at 21:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.