From 431486e7009b0a33c17f72ffa63d4db3e8f16610 Mon Sep 17 00:00:00 2001 From: "Mr.Web" Date: Sat, 4 Apr 2026 14:33:39 +0200 Subject: [PATCH 1/3] Fix null author locale when saving new content When creating a new content record, $originalAuthor is null because there is no original content to get the author from. This causes a fatal error at line 184 when calling ->getLocale() on null. Falls back to the request locale when originalAuthor is null. Fixes #3696 --- src/Controller/Backend/ContentEditController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controller/Backend/ContentEditController.php b/src/Controller/Backend/ContentEditController.php index 6129435c6..c9c26fc1d 100644 --- a/src/Controller/Backend/ContentEditController.php +++ b/src/Controller/Backend/ContentEditController.php @@ -181,7 +181,7 @@ public function save(Request $request, ?Content $originalContent = null, ?Conten $event = new ContentEvent($content); $this->dispatcher->dispatch($event, ContentEvent::POST_SAVE); - $locale = $originalAuthor->getLocale(); + $locale = $originalAuthor ? $originalAuthor->getLocale() : $request->getLocale(); // If we're "Saving Ajaxy" if ($request->isXmlHttpRequest()) { From 0f188bad2973bb50748f6c6776a793dfe87d3bf3 Mon Sep 17 00:00:00 2001 From: Andrea Lombardi Date: Thu, 9 Apr 2026 09:18:52 +0200 Subject: [PATCH 2/3] Update src/Controller/Backend/ContentEditController.php Co-authored-by: Bob van de Vijver --- src/Controller/Backend/ContentEditController.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Controller/Backend/ContentEditController.php b/src/Controller/Backend/ContentEditController.php index c9c26fc1d..204f8927f 100644 --- a/src/Controller/Backend/ContentEditController.php +++ b/src/Controller/Backend/ContentEditController.php @@ -181,10 +181,9 @@ public function save(Request $request, ?Content $originalContent = null, ?Conten $event = new ContentEvent($content); $this->dispatcher->dispatch($event, ContentEvent::POST_SAVE); - $locale = $originalAuthor ? $originalAuthor->getLocale() : $request->getLocale(); - // If we're "Saving Ajaxy" if ($request->isXmlHttpRequest()) { + $locale = $originalAuthor ? $originalAuthor->getLocale() : $request->getLocale(); $modified = sprintf( '(%s: %s)', $this->translator->trans('field.modifiedAt', [], null, $locale), From a89fd00c0903346a30667836d69cdb3513bba561 Mon Sep 17 00:00:00 2001 From: Andrea Lombardi Date: Thu, 9 Apr 2026 14:11:58 +0200 Subject: [PATCH 3/3] Remove PHPStan baseline entry for fixed getLocale() null check --- phpstan-baseline.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 808d1e110..2e9d4aef6 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -1147,12 +1147,6 @@ 'count' => 2, 'path' => __DIR__ . '/src/Controller/Backend/ContentEditController.php', ]; -$ignoreErrors[] = [ - 'message' => '#^Cannot call method getLocale\\(\\) on Bolt\\\\Entity\\\\User\\|null\\.$#', - 'identifier' => 'method.nonObject', - 'count' => 1, - 'path' => __DIR__ . '/src/Controller/Backend/ContentEditController.php', -]; $ignoreErrors[] = [ 'message' => '#^Method Bolt\\\\Controller\\\\Backend\\\\ContentEditController\\:\\:getFieldToUpdate\\(\\) has parameter \\$fieldDefinition with no type specified\\.$#', 'identifier' => 'missingType.parameter',