Skip to content

Instantly share code, notes, and snippets.

@totten
Last active July 7, 2022 04:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save totten/3ec8164c3f8ca9d3c51e768feab946da to your computer and use it in GitHub Desktop.
Save totten/3ec8164c3f8ca9d3c51e768feab946da to your computer and use it in GitHub Desktop.
dev/core#3724 - CaseType memory exhaustion

This is an example extension that simply registers an a case type via hook_managed.

Installation fails as follows:

$ cv en shimmy
Enabling extension "shimmy"
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 69632 bytes) in /Users/totten/bknix/build/dmaster/web/sites/all/modules/civicrm/CRM/Core/Error.php on line 818

Note that is 256mb which should be quite ample for basic administration.


Note: This example was actually developed/generated through this process:

  • Checkout civicrm/civicrm-core#23961
  • Update BunnyDance.mgd.php to enable the definition
  • Use mixer to build+execute an example
    civibuild restore dmaster
    ./tools/mixin/bin/mixer test -f --bare /Users/totten/bknix/build/dmaster/web/sites/default/files/civicrm/ext/example-mixin/ mgd-php@1
    
  • The same error will appear in the test.
  • The generated folder contains an example extension. I copied it to the gist. To make it more readable, I renamed/trimmed some files.

See also: https://lab.civicrm.org/dev/core/-/issues/3724

<?php
return [
[
'name' => 'CaseType_BunnyDance',
'entity' => 'CaseType',
'cleanup' => 'unused',
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
'name' => 'BunnyDance',
'title' => 'Bunny Dance Case',
'description' => 'The mysterious case of the dancing bunny',
'is_active' => TRUE,
'is_reserved' => TRUE,
'weight' => 1,
// FIXME: At time of writing, if I create a full CaseType with a definition, then the system runs out of memory.
'definition' => [
'activityTypes' => [
['name' => 'Open Case', 'max_instances' => '1'],
['name' => 'Follow up'],
['name' => 'Change Case Type'],
['name' => 'Change Case Status'],
['name' => 'Change Case Start Date'],
['name' => 'Link Cases'],
['name' => 'Email'],
['name' => 'Meeting'],
['name' => 'Phone Call'],
['name' => 'Nibble'],
],
'activitySets' => [
[
'name' => 'standard_timeline',
'label' => 'Standard Timeline',
'timeline' => 1,
'activityTypes' => [
['name' => 'Open Case', 'status' => 'Completed'],
['name' => 'Phone Call', 'reference_offset' => '1', 'reference_select' => 'newest'],
['name' => 'Follow up', 'reference_offset' => '7', 'reference_select' => 'newest'],
],
],
],
'timelineActivityTypes' => [
['name' => 'Open Case', 'status' => 'Completed'],
['name' => 'Phone Call', 'reference_offset' => '1', 'reference_select' => 'newest'],
['name' => 'Follow up', 'reference_offset' => '7', 'reference_select' => 'newest'],
],
'caseRoles' => [
['name' => 'Case Coordinator', 'creator' => '1', 'manager' => '1'],
],
],
],
],
],
];
<?xml version="1.0"?>
<extension key="shimmy" type="module">
<file>shimmy</file>
<name>FIXME</name>
<description>FIXME</description>
<license>AGPL-3.0</license>
<maintainer>
<author>CiviCRM LLC</author>
<email>info@civicrm.org</email>
</maintainer>
<urls>
<url desc="Main Extension Page">http://FIXME</url>
<url desc="Documentation">http://FIXME</url>
<url desc="Support">http://FIXME</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2021-03-21</releaseDate>
<version>1.0</version>
<develStage>alpha</develStage>
<tags>
<tag>mgmt:hidden</tag>
</tags>
<compatibility>
<ver>5.0</ver>
</compatibility>
<comments>This is a new, undeveloped module</comments>
<classloader>
<psr0 prefix="CRM_" path="."/>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
<civix>
<namespace>CRM/Shimmy</namespace>
</civix>
<mixins>
<mixin>mgd-php@1.1.0</mixin>
</mixins>
</extension>
<?php
// Placeholder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment