Skip to content

Backport: add mixin polyfill to support CiviCRM 5.75+#21

Merged
erawat merged 1 commit intomasterfrom
backport/5.75-mixin-polyfill
Mar 31, 2026
Merged

Backport: add mixin polyfill to support CiviCRM 5.75+#21
erawat merged 1 commit intomasterfrom
backport/5.75-mixin-polyfill

Conversation

@openclawautomation
Copy link
Copy Markdown
Collaborator

Closes #20

Summary

Adds mixin polyfill support so the extension works on CiviCRM 5.75+ as well as 6.4+.

Problem

On CiviCRM 5.75, enabling the extension throws:

TypeError: Civi\Schema\EntityRepository::getEntity(): Argument #1 ($entityName)
must be of type string, null given,
called in CRM/Core/DAO/Base.php on line 275

The extension was generated targeting CiviCRM 6.4+, so civix omitted the mixin polyfill bootstrap. Without it, the bundled mgd-php@2.0.0.mixin.php is never activated on 5.75, leaving entity registration incomplete during enable — causing getEntityNameForClass() to return null → TypeError.

Changes

info.xml

  • Lowered minimum compatibility from 6.45.75

paymentprocessingcore.civix.php

  • Added polyfill activation in _paymentprocessingcore_civix_civicrm_config():
if (!class_exists('CRM_Extension_MixInfo')) {
    $f = include __DIR__ . '/mixin/polyfill.php';
    $f(E::LONG_NAME, E::SHORT_NAME, __DIR__);
}
  • Guard ensures this is a complete no-op on CiviCRM 6.4+ (where CRM_Extension_MixInfo exists)

mixin/polyfill.php (new file)

  • Copied from CiviCRM core 5.75 — activates bundled mixins on older CiviCRM versions that lack native mixin support

Compatibility

CiviCRM 5.75 CiviCRM 6.4+
Before this PR ❌ TypeError on enable ✅ Works
After this PR ✅ Works ✅ Works (no-op)

Notes

  • This is a stopgap fix. The proper long-term approach is to run civix upgrade after updating info.xml to <ver>5.75</ver> — that will regenerate civix.php correctly so future upgrades don't regress. See Backport: add mixin polyfill to support CiviCRM 5.75+ #20 for full details.
  • The mgd-php@2.0.0 mixin was already bundled in the extension — this PR just ensures it gets activated on 5.75.

The extension was originally generated targeting CiviCRM 6.4+, which caused
civix to omit the mixin polyfill bootstrap. As a result, on CiviCRM 5.75 the
bundled mgd-php@2.0.0.mixin.php was never activated, leading to a TypeError
during extension enable:

  TypeError: Civi\Schema\EntityRepository::getEntity(): Argument #1 ($entityName)
  must be of type string, null given

Root cause: without the polyfill, CiviCRM 5.75 does not scan the extension's
mixin/ directory for fallback implementations. The entity registry is populated
before the extension's hook_civicrm_entityTypes listener is registered, so
getEntityNameForClass() returns null for the extension's DAO classes.

Changes:
- info.xml: lower minimum compatibility to 5.75
- paymentprocessingcore.civix.php: activate polyfill when CRM_Extension_MixInfo
  is absent (i.e. CiviCRM < ~5.77 without native mixin support)
- mixin/polyfill.php: add the polyfill file from CiviCRM core 5.75

On CiviCRM 6.4+ this is a no-op (CRM_Extension_MixInfo exists, polyfill skipped).
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a mixin polyfill to resolve a TypeError encountered when enabling the extension on CiviCRM 5.75. By backporting the necessary bootstrap logic, the extension can now correctly register entities on older CiviCRM versions while maintaining existing functionality for 6.4+ environments.

Highlights

  • Compatibility Update: Lowered the minimum CiviCRM compatibility requirement in info.xml from 6.4 to 5.75.
  • Mixin Polyfill Implementation: Added a new mixin/polyfill.php file to enable bundled mixins on CiviCRM versions older than 6.4.
  • Bootstrap Integration: Updated paymentprocessingcore.civix.php to conditionally trigger the polyfill during configuration, ensuring it remains a no-op on newer CiviCRM versions.
Ignored Files
  • Ignored by pattern: paymentprocessingcore.civix.php (1)
    • paymentprocessingcore.civix.php
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enables backport support for CiviCRM 5.75+ by adjusting the version compatibility in info.xml and adding a polyfill for mixin services. Feedback was provided regarding the PR title and commit message, which need to be updated to follow the mandatory 'CIVIMM-###:' naming convention defined in the style guide.

<develStage>alpha</develStage>
<compatibility>
<ver>6.4</ver>
<ver>5.75</ver>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

WARNING: The PR title (and likely the commit message) does not follow the required format CIVIMM-###:. Please update it to include the relevant ticket number (e.g., CIVIMM-20: Backport: add mixin polyfill to support CiviCRM 5.75+) as per the repository style guide (rule 25).

References
  1. Commit messages must follow the CIVIMM-###: format (Rule 25). (link)

Copy link
Copy Markdown
Member

@erawat erawat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR created byt openclawns, tested with deploy site, approved and merge for 5.75+ complatibiltiy.

@erawat erawat merged commit dc5c08c into master Mar 31, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backport: add mixin polyfill to support CiviCRM 5.75+

2 participants