Repository navigation
fix: resolve all dal:validate errors (#87) - #88
Closed
logmedia-openclaw wants to merge 1 commit into
Closed
logmedia-openclaw wants to merge 1 commit into
logmedia-openclaw wants to merge 1 commit into
Conversation
- remove PrimaryKey flag from cms_page_version_id ReferenceVersionField (table has PRIMARY KEY (id) only; matches LandingPageDefinition pattern) - change cmsPage association from OneToOne to ManyToOne, reverse side is already provided by CmsPageExtension::blogEntries - provide reverse many-to-many via new TagExtension (tag.blogEntries) and use the registered BlogEntryTagMappingDefinition instead of a raw table name string for the tags mapping - document the manually hydrated media property as @internal so the definition validator skips the struct check (teaser image is stored translatable in the translations, hydration stays in BlogSubscriber) - make BlogEntryEntity::setTags() non-nullable for to-many associations - add migration making werkl_blog_entry_translation.title/slug and werkl_blog_category_translation.name nullable for language fallback
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.
Problem
Fixes #87 —
./bin/console dal:validatereports 8 errors in 4 entities on Shopware 6.7.14.I reproduced each error against
Shopware\Core\Framework\DataAbstractionLayer\DefinitionValidator(v6.7.14.0) and fixed all of them:1. Primary key mismatch in entity
werkl_blog_entryReferenceVersionField(cms_page_version_id)carried aPrimaryKeyflag, but the table hasPRIMARY KEY (id)only (the column was added later viaALTER TABLEand the PK was never extended). Removed the flag — same pattern as core'sLandingPageDefinition(ReferenceVersionField(CmsPageDefinition)withRequired+ApiAwareonly).2. Field
mediain entity struct is missing inBlogEntryDefinitionSince the teaser image became translatable (1744229687),
media_idlives in the translation table andBlogEntryEntity::$mediais hydrated manually byBlogSubscriber::onBlogEntryLoaded()(which is why all storefront templates likeentry.media.urlkeep working). The validator skips struct properties documented with@internal— that's exactly what this property is, so it is now documented that way instead of silently polluting the DAL field collection.3. Missing reverse one-to-one association (
cmsPage<->CmsPageDefinition)The reverse side is already provided by
CmsPageExtension::blogEntries, which is aOneToManyAssociationField.OneToOnerequires aOneToOnemirror, so the owning side was switched toManyToOneAssociationField— the same direction core itself uses forproduct.cmsPage/landingPage.cmsPage. No schema change; the DAL read/write behaviour for a foreign-key-owned association is unchanged.4. Setter
setTagsis nullableto-manysetters must not accept null (seeOrderEntity::setTags()). Changed tosetTags(TagCollection $tags). Nothing in the plugin passes null.5. Missing reverse many-to-many association for
BlogEntryDefinition.tagsTagExtensionthat mirrors core's own approach (TagDefinitiondeclares a reverseManyToManyAssociationFieldfor every taggable entity, e.g.products,media,landingPages) —tag.blogEntriesviawerkl_blog_entry_tagwithCascadeDelete.tagsassociation now references the already registeredBlogEntryTagMappingDefinitionclass instead of the magic table-name string, consistent with theblogCategoriesassociation and core conventions (behaviour-identical, but statically checkable).6–8.
werkl_blog_entry_translation.title/slugandwerkl_blog_category_translation.nameare not nullableTranslated columns must be nullable so values can fall back through the language hierarchy (see core, e.g.
category_translation.nameisNULLalthough the definition field keeps itsRequiredflag). Added migrationMigration1789100000NullableTranslationColumns(MODIFY ... NULL); theRequiredflags on the definition fields stay as they are, matching core behaviour.How tested
DefinitionValidatorinvolved in the 8 reported messages (validatePrimaryKeyConsistency,validateOneToOne,validateManyToMany,validateTranslatedColumnsAreNullable,findEntityNotices,validateSetterIsNotNull) was traced against the fix.tests/unit/Content/Blog/BlogEntryDefinitionTest.phpcovering all eight points (PK flags, association types/directions, mapping definition identity, reverse sides from both extensions,@internalmedia property, non-nullablesetTags).php -land definition reflection checks pass.Note for reviewers
The changelog entries are kept under a
5.3.1heading; feel free to squash that into your next release version as usual.