Fix CakePHP 5.3 compatibility in ModelPropertyFactory#10
Conversation
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
|
@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? |
|
@cnizzardini i think changing the cakephp dependency to ^5.3 in composer.json for the new version would be fine |
|
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? |
|
Here's a little more context for this PR:
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. |
Summary
Fixes CakePHP 5.3 compatibility issue where
ModelPropertyFactorybreaks because__debugInfo()now returnsColumnobjects instead of arrays.Changes
__debugInfo()withgetColumn()for column default valueisPrimaryKey()to usegetPrimaryKey()public APIBoth methods are stable public API that return arrays for backwards compatibility.
Fixes mixerapi/mixerapi-dev#159