Skip to content

Conversation

@jamisonbryant
Copy link

Summary

Fixes CakePHP 5.3 compatibility issue where ModelPropertyFactory breaks because __debugInfo() now returns Column objects instead of arrays.

Changes

  • Replace __debugInfo() with getColumn() for column default value
  • Simplify isPrimaryKey() to use getPrimaryKey() public API

Both methods are stable public API that return arrays for backwards compatibility.

Fixes mixerapi/mixerapi-dev#159

Use public API methods instead of __debugInfo() for accessing column
metadata and primary key information. In CakePHP 5.3, TableSchema
stores columns and constraints as objects rather than arrays, causing
__debugInfo() to return Column/Constraint objects instead of arrays.

Changes:
- Replace __debugInfo() with getColumn() for column default value
- Simplify isPrimaryKey() to use getPrimaryKey() public API

Both getColumn() and getPrimaryKey() are stable public API methods
that return arrays for backwards compatibility.

Fixes mixerapi/mixerapi-dev#159
@cnizzardini cnizzardini merged commit 96998c8 into mixerapi:master Jan 9, 2026
3 checks passed
@cnizzardini
Copy link
Member

@jamisonbryant holding off on tagging this into a release because it just occured to me to ask if this change is backwards compatible with 5.0 - 5.2?

@segy
Copy link

segy commented Jan 16, 2026

@cnizzardini i think changing the cakephp dependency to ^5.3 in composer.json for the new version would be fine

@cnizzardini
Copy link
Member

cnizzardini commented Jan 16, 2026

Yes, if I must, but I prefer to do a revision and not a minor. I still have not had time to set down and test BC on this. I also don't really want to support < 5.3 and >= 5.3 when I can just support ^5.0. Who would want that extra work?

@cnizzardini
Copy link
Member

@jamisonbryant
Copy link
Author

jamisonbryant commented Jan 16, 2026

Here's a little more context for this PR:

  1. As part of the ongoing cakephp/migrations overhaul, the Cake core is leaning more heavily on objects instead of arrays for storing column metadata. Several of these objects were imported into cakephp/cakephp, see: Add Column from migrations cakephp/cakephp#18748.
  2. One of the changes in the above PR was changing the type of the $_constraints and $_columns properties in TableSchema.php from "mostly arrays" to "arrays of objects".
    1. Before: https://github.com/cakephp/cakephp/blob/5.0.0/src/Datasource/SchemaInterface.php#L67
    2. After: https://github.com/cakephp/cakephp/blob/5.3.0/src/Datasource/SchemaInterface.php#L67
  3. mixerapi/core relies on the __debugInfo() function to introspect some column metadata for identifying primary keys. Since __debugInfo() just returns $this->_columns directly, it now returns Column objects instead of arrays.

This would have resulted in an error like "Fatal error: Cannot use object of type Cake\Database\Schema\Column as array in vendor/mixerapi/core/src/Model/ModelPropertyFactory.php on line 38".

Summary: MixerAPI Core was using an internal method (though not labeled as such, which can potentially be corrected) and when some property types changed upstream, a change was necessary to switch to the stable public API.

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.

ModelPropertyFactory breaks with CakePHP 5.3 due to Column object changes

3 participants