Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/Repository/ContentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public function createContent(APIContentCreateStruct $contentCreateStruct, array
);

if (!empty($errors)) {
throw new ContentFieldValidationException($errors);
throw ContentFieldValidationException::createNewWithMultiline($errors);
}

$spiLocationCreateStructs = $this->buildSPILocationCreateStructs(
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Repository/Service/Mock/ContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2503,7 +2503,7 @@ public function providerForTestCreateContentThrowsContentFieldValidationExceptio
public function testCreateContentThrowsContentFieldValidationException($mainLanguageCode, $structFields): void
{
$this->expectException(ContentFieldValidationException::class);
$this->expectExceptionMessage('Content fields did not validate');
$this->expectExceptionMessage('Content "" fields did not validate');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is concerning. Is there no content name at this stage due to business logic or mocking?

Side note: this code is most likely a result of few automated refactoring. If you're touching this, both expectException and expectExceptionMessage should be moved right before the statement which produces the exception.

Copy link
Contributor Author

@reithor reithor Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, what are the implications for the UI? Meaning how does this show up in the interface?

I don't think it is shown in the UI at all.
Error is thrown when creating content

# [src/lib/Repository/ContentService->createContent()

        $errors = $this->validate(
            $contentCreateStruct,
            [],
            $fieldIdentifiersToValidate
        );

        if (!empty($errors)) {
-            throw new ContentFieldValidationException($errors);
+           throw ContentFieldValidationException::createNewWithMultiline($errors);
        }

At this stage we only have $contentCreateStruct - nothing is persisted - we do not have a ContentName yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I see the BC concerns.


$fieldDefinitions = $this->fixturesForTestCreateContentNonRedundantFieldSetComplex();
list($contentCreateStruct, $allFieldErrors) =
Expand Down
Loading