Skip to content

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

@openclawautomation

Description

@openclawautomation

Problem

When enabling the extension on CiviCRM 5.75, the following error is thrown:

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
in Civi\Schema\EntityRepository::getEntity()
(line 38 of Civi/Schema/EntityRepository.php)

The extension fails to enable and is left in a broken/partial state.

Root Cause

The extension was generated targeting CiviCRM 6.4+, so civix omitted the mixin polyfill bootstrap with the comment:

// Based on <compatibility>, this does not currently require mixin/polyfill.php.

Without the polyfill, CiviCRM 5.75 does not scan the extension's mixin/ directory for fallback implementations. The bundled mgd-php@2.0.0.mixin.php is never activated, causing the mixin system's state to be incomplete during the enable process.

As a result, EntityRepository is populated before the extension's hook_civicrm_entityTypes listener is registered, so AllCoreTables::getEntityNameForClass() returns null for the extension's DAO classes — which is then passed into EntityRepository::getEntity(null), triggering the TypeError.

Note: mgd-php@2.0.0 was introduced in CiviCRM 6.9 — but the extension already ships it as a bundled fallback. The issue is purely that the polyfill loader is missing, so the bundled file is never used on 5.75.

Fix

Three small changes:

1. info.xml — lower minimum version

- <ver>6.4</ver>
+ <ver>5.75</ver>

2. paymentprocessingcore.civix.php — activate polyfill on older CiviCRM

In _paymentprocessingcore_civix_civicrm_config(), replace the comment with:

if (!class_exists('CRM_Extension_MixInfo')) {
    $f = include __DIR__ . '/mixin/polyfill.php';
    $f(E::LONG_NAME, E::SHORT_NAME, __DIR__);
}

3. mixin/polyfill.php — add the polyfill file

Copy polyfill.php from CiviCRM core into mixin/polyfill.php.
Reference: https://github.com/civicrm/civicrm-core/blob/5.75.0/mixin/polyfill.php

On CiviCRM 6.4+ this is a complete no-op (CRM_Extension_MixInfo exists, polyfill is skipped).

Impact

  • CiviCRM 5.75: extension currently fails to enable
  • CiviCRM 6.4+: no impact, fix is a no-op ✅

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions