Add DatabaseObjectBuilder with TagBuilder implementation#6689
Add DatabaseObjectBuilder with TagBuilder implementation#6689BurntimeX wants to merge 18 commits into
DatabaseObjectBuilder with TagBuilder implementation#6689Conversation
Introduces an abstract builder for creating, updating and deleting database objects with a fluent setter API, batched transactional deletes and an `INSERT IGNORE`-style helper. `TagBuilder` is the first concrete implementation.
Replace the `TagAction`-based persistence in `TagAddForm`/`TagEditForm` with the new `DatabaseObjectBuilder` flow.
Introduce a counterpart to `saveValueCallback()` that loads a field's value from an `IStorableObject` when an edit form is populated. When set, the callback takes precedence over the default property-based loading in `updatedObject()`, allowing values that must be derived from a related object or an additional query.
Provides a static helper to atomically increment or decrement counter columns for a given object, mirroring the behavior of the legacy `DatabaseObjectEditor::updateCounters()`.
The method was based on `DatabaseObjectEditor::fastCreate()` which is used very rarely and therefore is not needed in the new API. The change simplifies the code and allows the DBO to be passed directly as a parameter to `afterCreate()` and `afterUpdate()`
Pattern for BuildersWe need to formalize the pattern at some point, for now I think it’s reasonable to go with:
Things not yet decidedSupport for Implicit Default ValuesNot every value can be mapped through MySQL’s default values, for example, we cannot set default values for However, this can be extended to other kind of columns, such as auto-filling the user. DBOActions usually set it to whatever is present in We could add this as an indirect feature to the Asymmetric Visibility on Builder Properties (PHP 8.4)PHP 8.4 has the asymmetric visibility that would allow us to define the properties as The major drawback of this is that Ubuntu 22.04 LTS ships with PHP 8.3 (Debian Trixie offers PHP 8.4) natively, which would mean that this would be a bit of a steep increase in system requirements. That said, PHP 8.3 is already out of support, with security support ending Jan 1, 2028. It is already a pretty old version of PHP. See https://www.php.net/releases/8.4/en.php#asymmetric_visibility to learn more. |
|
Both the Maybe add a new helper method that fails loud when accessing the object on a create instance? Or just turn the |
Introduces an abstract builder for creating, updating and deleting database objects with a fluent setter API, batched transactional deletes and an
INSERT IGNORE-style helper.TagBuilderis the first concrete implementation.