Repository navigation
refactor!: pass the data to the add/edit methods of the handler classes uniformly - #6781
Merged
Merged
Conversation
…es uniformly
The add/edit methods of `ArticleHandler`, `CategoryHandler`, `LanguageHandler` and `MediaCategoryHandler` now all
take the values to store as one `$data` array, keyed like the columns, followed by `$meta`:
CategoryHandler::add($parentId, ['catname' => …, 'catpriority' => …]) -> add(['parent_id' => …, 'name' => …, 'priority' => …])
CategoryHandler::edit($id, $languageId, ['catname' => …]) -> edit($id, $languageId, ['name' => …])
LanguageHandler::add($code, $name, $priority, $status) -> add(['code' => …, 'name' => …, …])
LanguageHandler::edit($id, $code, $name, $priority, $status) -> edit($id, ['status' => …])
MediaCategoryHandler::add($name, $parent) -> add(['parent_id' => …, 'name' => …])
Arrays can grow without breaking callers and distinguish a missing key from `null`. In `edit()` missing keys keep
their value, so e.g. toggling the status of a language no longer requires passing all other values. `priority` is
optional in `add()` and appends the element. The start article of a new category always gets the category name.
`Type::requireKeys()` replaces the private `reqKey()` helpers and accepts `null` values.
Also fixes the path of media categories: the root path `|` was read as `[0]`, so `MediaCategory::getParentTree()`
failed for every category and subcategories were stored with a leading `0`.
This was referenced Oct 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The add/edit methods of the handler classes took their data in different ways:
$dataarrays with legacy keys (catname,catpriority), the parent as a separate parameter or as an object, or a list of positional values (LanguageHandler). This alignsArticleHandler,CategoryHandler,LanguageHandlerandMediaCategoryHandler:$dataarray, keyed like the columns, followed by$meta$id,$languageId) stays a separate parameteredit()missing keys keep their value, a given key (alsonull) is storedpriorityis optional inadd()and appends the elementArrays rather than single parameters, because they can get new fields after the release without breaking callers, and they distinguish a missing key from an explicit
null.Breaking changes
CategoryHandler::add(?int $categoryId, array $data, …)→add(array $data, …)withparent_id;catname/catpriority→name/priority; the separate start articlenameis gone, the start article gets the category nameCategoryHandler::edit():catname/catpriority→name/priorityArticleHandler::edit():nameis no longer requiredLanguageHandler::add()/edit()take$dataarrays instead of positional valuesMediaCategoryHandler::add(string $name, ?MediaCategory $parent)→add(array $data)withparent_id; an unknown parent now throws aUserMessageExceptioninstead of silently creating a root categoryFix
MediaCategoryread the root path|as[0], sogetParentTree()threw for every media category and subcategories were stored with a leading0in their path.MediaHandlerfollows in a separate PR (passing the file as a SymfonyFile/UploadedFileinstead of the$_FILESshape).