From 04691935d01027eabe56f37ea79170cb6f1fd0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Prai=C3=9F?= Date: Fri, 21 Feb 2025 11:22:43 +0100 Subject: [PATCH] [5.x] Fix issue with localication files named like global sets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We were encountering an issue ’’’placeholderLabel(): Argument #1 ($label) must be of type ?string, array given’’’ that appeared when there is a localization file that is named like a global set. Similar issues can appear with fieldsets. They are related to the way laravel localization works when a translation file is named like a translation key, e.g. __('search") and lang/en/search.php. In this case the whole contents of a file are returned instead of a string. The underlying issue was already encountered and had been fixed for some parts of statamic 4, so I applied the same fix to the relevant files. https://github.com/statamic/cms/pull/9525/files --- src/Auth/CorePermissions.php | 2 ++ src/Auth/Permission.php | 2 ++ src/Fields/Blueprint.php | 2 ++ src/Fields/Field.php | 2 ++ src/Fields/Fieldtype.php | 2 ++ src/Fields/Tab.php | 2 ++ 6 files changed, 12 insertions(+) diff --git a/src/Auth/CorePermissions.php b/src/Auth/CorePermissions.php index 8bbf8c8a12..1931c25b8d 100644 --- a/src/Auth/CorePermissions.php +++ b/src/Auth/CorePermissions.php @@ -12,6 +12,8 @@ use Statamic\Facades\Taxonomy; use Statamic\Facades\Utility; +use function Statamic\trans as __; + class CorePermissions { public function boot() diff --git a/src/Auth/Permission.php b/src/Auth/Permission.php index b06731a9f6..905ca852c4 100644 --- a/src/Auth/Permission.php +++ b/src/Auth/Permission.php @@ -4,6 +4,8 @@ use Statamic\Support\Traits\FluentlyGetsAndSets; +use function Statamic\trans as __; + class Permission { use FluentlyGetsAndSets; diff --git a/src/Fields/Blueprint.php b/src/Fields/Blueprint.php index 5235d27d2d..c44ae5f9fd 100644 --- a/src/Fields/Blueprint.php +++ b/src/Fields/Blueprint.php @@ -28,6 +28,8 @@ use Statamic\Support\Arr; use Statamic\Support\Str; +use function Statamic\trans as __; + class Blueprint implements Arrayable, ArrayAccess, Augmentable, QueryableValue { use ExistsAsFile, HasAugmentedData; diff --git a/src/Fields/Field.php b/src/Fields/Field.php index b7b9f4f17e..ef9c1c9a36 100644 --- a/src/Fields/Field.php +++ b/src/Fields/Field.php @@ -13,6 +13,8 @@ use Statamic\Support\Arr; use Statamic\Support\Str; +use function Statamic\trans as __; + class Field implements Arrayable { protected $handle; diff --git a/src/Fields/Fieldtype.php b/src/Fields/Fieldtype.php index 7fd86d79bf..956f2aee44 100644 --- a/src/Fields/Fieldtype.php +++ b/src/Fields/Fieldtype.php @@ -12,6 +12,8 @@ use Statamic\Statamic; use Statamic\Support\Str; +use function Statamic\trans as __; + abstract class Fieldtype implements Arrayable { use HasHandle, RegistersItself { diff --git a/src/Fields/Tab.php b/src/Fields/Tab.php index ef0d095e89..bbc50f2a2b 100644 --- a/src/Fields/Tab.php +++ b/src/Fields/Tab.php @@ -5,6 +5,8 @@ use Statamic\Support\Arr; use Statamic\Support\Str; +use function Statamic\trans as __; + class Tab { protected $handle;