From 57f4f913f3fae5f194f6d9ba2cf9b81138b0a5e4 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 10:22:00 -0700 Subject: [PATCH 1/9] Un-deprecate treating element queries as arrays --- CHANGELOG.md | 6 ++++++ src/elements/db/ElementQuery.php | 11 ----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 767de6ad216..42da8cd309c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Release Notes for Craft CMS 3.x +## Unreleased + +### Changed +- Treating element queries as arrays is no longer deprecated. ([#11625](https://github.com/craftcms/cms/discussions/11625)) +- Using the `|length` filter on an element query is no longer deprecated. ([#11625](https://github.com/craftcms/cms/discussions/11625)) + ## 3.7.49 - 2022-07-26 ### Added diff --git a/src/elements/db/ElementQuery.php b/src/elements/db/ElementQuery.php index 4b057e0cf9a..711483d5bb6 100644 --- a/src/elements/db/ElementQuery.php +++ b/src/elements/db/ElementQuery.php @@ -602,7 +602,6 @@ public function __call($name, $params) */ public function getIterator(): ArrayIterator { - Craft::$app->getDeprecator()->log('ElementQuery::getIterator()', 'Looping through element queries directly has been deprecated. Use `all()` to fetch the query results before looping over them.'); return new ArrayIterator($this->all()); } @@ -615,8 +614,6 @@ public function getIterator(): ArrayIterator public function offsetExists($name): bool { if (is_numeric($name)) { - Craft::$app->getDeprecator()->log('ElementQuery::offsetExists()', 'Treating element queries as arrays has been deprecated. Use `exists()` to determine if an element query will yield any results, or `all()` to fetch the results.'); - // Cached? if (($cachedResult = $this->getCachedResult()) !== null) { return $name < count($cachedResult); @@ -650,8 +647,6 @@ public function offsetExists($name): bool public function offsetGet($name) { if (is_numeric($name)) { - Craft::$app->getDeprecator()->log('ElementQuery::offsetGet()', 'Treating element queries as arrays has been deprecated. Use `exists()` to determine if an element query will yield any results, or `all()` to fetch the results.'); - $element = $this->nth($name); if ($element) { return $element; @@ -1631,12 +1626,6 @@ public function afterPopulate(array $elements): array */ public function count($q = '*', $db = null) { - $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3); - $function = $backtrace[2]['function'] ?? null; - if ($function === 'twig_length_filter') { - Craft::$app->getDeprecator()->log('ElementQuery::count()', 'Treating element queries as arrays has been deprecated. Use `count()` to get the total number of results without querying for them, or use `all()` to fetch the query results, and check the length of the resulting array.'); - } - // Cached? if (($cachedResult = $this->getCachedResult()) !== null) { return count($cachedResult); From 694eac89010a8bb07c800096a1af28cd3a2917d2 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 10:22:43 -0700 Subject: [PATCH 2/9] Finish 3.7.50 --- CHANGELOG.md | 2 +- composer.json | 2 +- src/config/app.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42da8cd309c..9960862ea67 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes for Craft CMS 3.x -## Unreleased +## 3.7.50 - 2022-07-26 ### Changed - Treating element queries as arrays is no longer deprecated. ([#11625](https://github.com/craftcms/cms/discussions/11625)) diff --git a/composer.json b/composer.json index 39e75c0d05c..7dd64c4d553 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "craftcms/cms", "description": "Craft CMS", - "version": "3.7.49", + "version": "3.7.50", "keywords": [ "cms", "craftcms", diff --git a/src/config/app.php b/src/config/app.php index ed76b8f085b..68973e1c28b 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -3,7 +3,7 @@ return [ 'id' => 'CraftCMS', 'name' => 'Craft CMS', - 'version' => '3.7.49', + 'version' => '3.7.50', 'schemaVersion' => '3.7.33', 'minVersionRequired' => '2.6.2788', 'basePath' => dirname(__DIR__), // Defines the @app alias From 55cbae9f2d887c87ab617f21f6ee7ad1edab1dbd Mon Sep 17 00:00:00 2001 From: shinybrad <83238715+shinybrad@users.noreply.github.com> Date: Tue, 26 Jul 2022 15:03:45 -0400 Subject: [PATCH 3/9] New translations app.php (Persian) [ci skip] --- src/translations/fa/app.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/translations/fa/app.php b/src/translations/fa/app.php index c7fd3796ec2..13446778f32 100644 --- a/src/translations/fa/app.php +++ b/src/translations/fa/app.php @@ -82,14 +82,14 @@ 'All jobs released.' => 'همه کارها آزاد شدند.', 'All option labels must be unique.' => 'همه برچسب‌های گزینه باید یکتا باشند.', 'All option values must be unique.' => 'همه مقادیر گزینه باید یکتا باشند.', - 'All plugins must be compatible with Craft {version} before you can upgrade.' => 'قبل از این که بتوانید ارتقاء دهید، تمامی پلاگین‌ها باید با Craft {version} سازگار باشند.', + 'All plugins must be compatible with Craft {version} before you can upgrade.' => 'قبل از این که بتوانید ارتقا دهید، تمامی پلاگین‌ها باید با Craft {version} سازگار باشند.', 'All targets must have a label.' => 'همه مقصدها باید یک برچسب داشته باشند.', 'All users' => 'همه کاربرها', 'All' => 'همه', 'Allow line breaks' => 'رفتن به خط بعد را اجازه بده', 'Allow listing element drafts' => 'اجازه دادن به لیست شدن پیش‌نویس‌های مؤلفه', 'Allow listing element revisions' => 'اجازه دادن به لیست شدن بازبینی‌های مؤلفه', - 'Allow listing non-live and otherwise inactive elements.' => 'اجازه دادن به لیست شدن مؤلفه‌های غیرفعال.', + 'Allow listing non-live and otherwise inactive elements.' => 'اجازه دادن به لیست شدن مؤلفه‌های غیرفعال و غیر زنده.', 'Allow public registration' => 'اجازه ثبت نام برای عموم', 'Allow querying elements from the “{site}” site.' => 'اجازه دادن پرس و جوی مؤلفه‌ها از سایت "{site}".', 'Allow self relations' => 'اجازه دادن به روابط با خود', @@ -394,7 +394,7 @@ 'Craft CMS is running in Dev Mode.' => 'Craft CMS در حالت توسعه در حال اجرا می باشد.', 'Craft Support' => 'پشتیبانی Craft', 'Craft isn’t installed yet.' => 'Craft تا این لحظه نصب نشده است.', - 'Craft {version} Upgrade' => 'ارتقاء به Craft {version}', + 'Craft {version} Upgrade' => 'ارتقا به Craft {version}', 'Create a draft' => 'ایجاد یک پیش‌نویس', 'Create a new GraphQL Schema' => 'ایجاد یک اسکیمای GraphQL جدید', 'Create a new GraphQL token' => 'ایجاد یک توکن GraphQL جدید', @@ -827,7 +827,7 @@ 'Load this template' => 'لود کردن این قالب', 'Loaded Project Config Data' => 'داده‌های پیکربندی پروژه بارگیری شده', 'Loading Plugin Store…' => 'در حال لود کردن فروشگاه پلاگین...', - 'Loading' => 'بارگذاری', + 'Loading' => 'بارگیری', 'Local Folder' => 'پوشه محلی', 'Local copies of remote images, generated thumbnails' => 'نسخه‌های محلی تصاویر راه دور، تصاویر کوچک تولید‌شده', 'Localizing relations' => 'محلی سازی رابطه ها', @@ -1061,7 +1061,7 @@ 'Please fix on an environment where administrative changes are allowed.' => 'لطفا در محیطی که تنظیمات مدیریتی مجاز هستند اصلاح نمایید.', 'Please fix the following in your {file} file before proceeding:' => 'لطفا قبل از ادامه مورد زیر را در فایل {file} اصلاح نمایید.', 'Please notify one of your site’s admins.' => 'لطفا به یکی از مدیران سایت اطلاع دهید.', - 'Please set a valid volume for storing the user photos in user settings page first.' => 'لطفا اول یک مخزن معتبر برای نگهداری تصاویر در صفحه تنظیمات کاربر تنظیم نمایید.', + 'Please set a valid volume for storing the user photos in user settings page first.' => 'لطفاً ابتدا یک مخزن معتبر برای نگهداری تصاویر کاربر در صفحه تنظیمات کاربر تنظیم نمایید.', 'Please talk to your host/IT department about upgrading your server.' => 'لطفا درباره ارتقاء دادن سرور خود با بخش میزبانی/فناوری اطلاعات تان صحبت نمایید.', 'Plugin Installer' => 'نصب کننده پلاگین', 'Plugin Store' => 'فروشگاه پلاگین', @@ -1499,7 +1499,7 @@ 'This field is translated for each language.' => 'این فیلد برای هر زبان ترجمه می گردد.', 'This field is translated for each site group.' => 'این فیلد برای هر گروه سایت ترجمه می شود.', 'This field is translated for each site.' => 'فیلد برای هر سایت ترجمه گردید.', - 'This field was updated in the Current revision.' => 'این فیلد با بازبینی فعلی بروز شد.', + 'This field was updated in the Current revision.' => 'این فیلد با بازبینی فعلی به‌روز شد.', 'This field’s target subfolder path is invalid: {path}' => 'مسیر زیر پوشه مقصد این فیلد نا معتیر است: {path}', 'This field’s values are used as search keywords.' => 'از مقادیر این فیلد به عنان کلمات کلیدی جستجو استفاده می‌شود.', 'This global set doesn’t have any fields assigned to it in its field layout.' => 'این مجموعه سراسری هیچ فیلدی به آن در چیدمان فیلدش نسبت داده نشده است.', @@ -1577,7 +1577,7 @@ 'URL Format' => 'فرمت آدرس ابنترنتی', 'URL type' => 'نوع URL', 'URL' => 'آدرس اینترنتی', - 'Unable to fetch upgrade info at this time.' => 'در حال حاضر قادر به دریافت اطلاعات ارتقاء نیست.', + 'Unable to fetch upgrade info at this time.' => 'در حال حاضر دریافت اطلاعات ارتقا مقدور نیست.', 'Unable to find the template “{template}”.' => 'پیدا کردن قالب "{template}" ممکن نبود.', 'Unauthorized' => 'غیر مجاز', 'Uncheck for {offLabel}.' => 'تیک {offLabel} را حذف کنید.', @@ -1618,7 +1618,7 @@ 'Upload a file' => 'بارگذاری یک فایل', 'Upload a photo' => 'آپلود یک عکس', 'Upload failed for “{filename}”.' => 'آپلود “{filename}” با شکست مواجه گردید.', - 'Upload failed.' => 'آپلود با شکست مواجه شد.', + 'Upload failed.' => 'آپلود ناموفق بود.', 'Upload files' => 'آپلود فایل ها', 'Upload icon' => 'آپلود آیکن', 'Upload logo' => 'آپلود لوگو', @@ -1674,7 +1674,7 @@ 'View other users’ {type}' => 'مشاهده {type}های سایر کاربرها', 'View site' => 'مشاهده سایت', 'View tag group - {tagGroup}' => 'مشاهده گروه برچسب - {tagGroup}', - 'View the upgrade guide' => 'مشاهده راهنمای ارتقاء', + 'View the upgrade guide' => 'مشاهده راهنمای ارتقا', 'View user group - {userGroup}' => 'مشاهده گروه کاربری - {userGroup}', 'View volume - {volume}' => 'مشاهده مخزن - {volume}', 'View {plugin} in the Plugin Store' => 'مشاهده {plugin} در فروشگاه پلاگین', @@ -1719,7 +1719,7 @@ 'Where assets should be stored when they are uploaded directly to the field.' => 'جایی که فایل‌های پروژه باید نگهداری گردند زمانی که آن‌ها مستقیما به فیلد آپلود می‌شوند.', 'Where do you want to store temporary asset uploads?' => 'کجا می خواهید آپلودهای فایل پروژه موقت را ذخیره نمایید؟', 'Where do you want to store user photos? Note that the subfolder path can contain variables like {username}.' => 'تصاویر کاربران را کجا می خواهید آپلود نمایید؟ توجه نمایید که مسیر زیر پوشه می تواند شامل متغیرهایی مانند {username} باشد.', - 'Where new {type} should be placed by default in the structure.' => '{type} جدید به طور پیش فرض در ساختار کجا باید قرار بگیرد.', + 'Where new {type} should be placed by default in the structure.' => 'جایی در ساختار که {type} جدید به‌طور پیش‌فرض باید در آن قرار بگیرد.', 'Where transforms should be stored on the filesystem.' => 'جایی که تغییر‌شکل‌ها باید در سیستم‌فایل نگهداری شود.', 'Whether authors should be able to choose which time zone the time is in.' => 'این که نویسندگان باید بتوانند منطقه زمانی که در آن هستند را انتخاب نمایند.', 'Whether authors should be able to upload files directly to the field, rather than requiring them to select/upload assets via the selection modal.' => 'آیا نویسندگان باید بتوانند فایل‌ها را مستقیماً در فیلد بارگذاری کنند، به جای آنکه موظف باشند فایل‌های پروژه را از طریق مودال انتخاب، انتخاب/بارگذاری کنند.', From b39c801ec03f3d1fbc9724f5a77922a02d024cf8 Mon Sep 17 00:00:00 2001 From: shinybrad <83238715+shinybrad@users.noreply.github.com> Date: Tue, 26 Jul 2022 15:04:47 -0400 Subject: [PATCH 4/9] New translations app.php (Persian) [ci skip] --- src/translations/fa/app.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/translations/fa/app.php b/src/translations/fa/app.php index 6d4afc15c8e..aac7ac944c1 100644 --- a/src/translations/fa/app.php +++ b/src/translations/fa/app.php @@ -67,14 +67,14 @@ 'All jobs released.' => 'همه کارها آزاد شدند.', 'All option labels must be unique.' => 'همه برچسب‌های گزینه باید یکتا باشند.', 'All option values must be unique.' => 'همه مقادیر گزینه باید یکتا باشند.', - 'All plugins must be compatible with Craft {version} before you can upgrade.' => 'قبل از این که بتوانید ارتقاء دهید، تمامی پلاگین‌ها باید با Craft {version} سازگار باشند.', + 'All plugins must be compatible with Craft {version} before you can upgrade.' => 'قبل از این که بتوانید ارتقا دهید، تمامی پلاگین‌ها باید با Craft {version} سازگار باشند.', 'All targets must have a label.' => 'همه مقصدها باید یک برچسب داشته باشند.', 'All users' => 'همه کاربرها', 'All' => 'همه', 'Allow line breaks' => 'رفتن به خط بعد را اجازه بده', 'Allow listing element drafts' => 'اجازه دادن به لیست شدن پیش‌نویس‌های مؤلفه', 'Allow listing element revisions' => 'اجازه دادن به لیست شدن بازبینی‌های مؤلفه', - 'Allow listing non-live and otherwise inactive elements.' => 'اجازه دادن به لیست شدن مؤلفه‌های غیرفعال.', + 'Allow listing non-live and otherwise inactive elements.' => 'اجازه دادن به لیست شدن مؤلفه‌های غیرفعال و غیر زنده.', 'Allow public registration' => 'اجازه ثبت نام برای عموم', 'Allow self relations' => 'اجازه دادن به روابط با خود', 'Allow uploading directly to the field' => 'اجازه بارگذاری مستقیم در فیلد داده شود', @@ -359,7 +359,7 @@ 'Craft CMS is running in Dev Mode.' => 'Craft CMS در حالت توسعه در حال اجرا می باشد.', 'Craft Support' => 'پشتیبانی Craft', 'Craft isn’t installed yet.' => 'Craft تا این لحظه نصب نشده است.', - 'Craft {version} Upgrade' => 'ارتقاء به Craft {version}', + 'Craft {version} Upgrade' => 'ارتقا به Craft {version}', 'Create a draft' => 'ایجاد یک پیش‌نویس', 'Create a new GraphQL Schema' => 'ایجاد یک اسکیمای GraphQL جدید', 'Create a new GraphQL token' => 'ایجاد یک توکن GraphQL جدید', @@ -780,7 +780,7 @@ 'Load this template' => 'لود کردن این قالب', 'Loaded Project Config Data' => 'داده‌های پیکربندی پروژه بارگیری شده', 'Loading Plugin Store…' => 'در حال لود کردن فروشگاه پلاگین...', - 'Loading' => 'بارگذاری', + 'Loading' => 'بارگیری', 'Local Folder' => 'پوشه محلی', 'Local copies of remote images, generated thumbnails' => 'نسخه‌های محلی تصاویر راه دور، تصاویر کوچک تولید‌شده', 'Local volumes cannot be located within system directories.' => 'مخزن‌های محلی نمی‌توانند در شاخه‌های سیستمی قرار بگیرند.', @@ -1393,7 +1393,7 @@ 'This field is translated for each language.' => 'این فیلد برای هر زبان ترجمه می گردد.', 'This field is translated for each site group.' => 'این فیلد برای هر گروه سایت ترجمه می شود.', 'This field is translated for each site.' => 'فیلد برای هر سایت ترجمه گردید.', - 'This field was updated in the Current revision.' => 'این فیلد با بازبینی فعلی بروز شد.', + 'This field was updated in the Current revision.' => 'این فیلد با بازبینی فعلی به‌روز شد.', 'This field’s target subfolder path is invalid: {path}' => 'مسیر زیر پوشه مقصد این فیلد نا معتیر است: {path}', 'This field’s values are used as search keywords.' => 'از مقادیر این فیلد به عنان کلمات کلیدی جستجو استفاده می‌شود.', 'This global set doesn’t have any fields assigned to it in its field layout.' => 'این مجموعه سراسری هیچ فیلدی به آن در چیدمان فیلدش نسبت داده نشده است.', @@ -1465,9 +1465,9 @@ 'URL Format' => 'فرمت آدرس ابنترنتی', 'URL type' => 'نوع URL', 'URL' => 'آدرس اینترنتی', - 'Unable to fetch upgrade info at this time.' => 'در حال حاضر قادر به دریافت اطلاعات ارتقاء نیست.', + 'Unable to fetch upgrade info at this time.' => 'در حال حاضر دریافت اطلاعات ارتقا مقدور نیست.', 'Unable to find the template “{template}”.' => 'پیدا کردن قالب "{template}" ممکن نبود.', - 'Unable to use the selected directory for the volume.' => 'قادر به استفاده از دایرکتوری انتخاب شده برای مخزن نیست.', + 'Unable to use the selected directory for the volume.' => 'استفاده از دایرکتوری انتخاب‌شده برای مخزن مقدور نیست.', 'Unauthorized' => 'غیر مجاز', 'Uncheck for {offLabel}.' => 'تیک {offLabel} را حذف کنید.', 'Underline links' => 'خط کشی زیر پیوندها', @@ -1562,7 +1562,7 @@ 'View global set - {globalSet}' => 'مشاهده مجموعه سراسری - {globalSet}', 'View site' => 'مشاهده سایت', 'View tag group - {tagGroup}' => 'مشاهده گروه برچسب - {tagGroup}', - 'View the upgrade guide' => 'مشاهده راهنمای ارتقاء', + 'View the upgrade guide' => 'مشاهده راهنمای ارتقا', 'View user group - {userGroup}' => 'مشاهده گروه کاربری - {userGroup}', 'View volume - {volume}' => 'مشاهده مخزن - {volume}', 'View volume' => 'مشاهده مخزن', @@ -1605,7 +1605,7 @@ 'Where assets should be stored when they are uploaded directly to the field, or via a front-end form.' => 'محل ذخیره فایل‌های پروژه هنگامی که مستقیماً در فیلد، یا از طریق یک فرم سایت بارگذاری می‌شوند.', 'Where do you want to store temporary asset uploads?' => 'کجا می خواهید آپلودهای فایل پروژه موقت را ذخیره نمایید؟', 'Where do you want to store user photos? Note that the subfolder path can contain variables like {username}.' => 'تصاویر کاربران را کجا می خواهید آپلود نمایید؟ توجه نمایید که مسیر زیر پوشه می تواند شامل متغیرهایی مانند {username} باشد.', - 'Where new {type} should be placed by default in the structure.' => '{type} جدید به طور پیش فرض در ساختار کجا باید قرار بگیرد.', + 'Where new {type} should be placed by default in the structure.' => 'جایی در ساختار که {type} جدید به‌طور پیش‌فرض باید در آن قرار بگیرد.', 'Where selected assets should be stored.' => 'جایی که فایل‌های پروژه باید ذخیره شوند.', 'Whether authors should be able to choose which time zone the time is in.' => 'این که نویسندگان باید بتوانند منطقه زمانی که در آن هستند را انتخاب نمایند.', 'Whether authors should be able to upload files directly to the field, rather than requiring them to select/upload assets via the selection modal.' => 'آیا نویسندگان باید بتوانند فایل‌ها را مستقیماً در فیلد بارگذاری کنند، به جای آنکه موظف باشند فایل‌های پروژه را از طریق مودال انتخاب، انتخاب/بارگذاری کنند.', From c4168e52e5d36f66069ea5403bc91a630e76502e Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 15:34:39 -0700 Subject: [PATCH 5/9] Typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9960862ea67..846a2757f60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ## 3.7.49 - 2022-07-26 ### Added -- The control panel is now translated into Ukranian. +- The control panel is now translated into Ukrainian. - Added `craft\helpers\Template::resolveTemplatePathAndLine()`. ### Changed From 777e0cc44aeb411c18a58d138535f8f4728c192c Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 16:16:10 -0700 Subject: [PATCH 6/9] Force strict comparisons for objects --- CHANGELOG.md | 5 +++++ src/helpers/ArrayHelper.php | 6 +++++- tests/unit/helpers/ArrayHelperTest.php | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 756d3419065..f3062605ad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Release Notes for Craft CMS 4 +## Unreleased + +### Fixed +- Fixed an error that could occur when passing an object into `craft\helpers\ArrayHelper::removeValue()` or the `|without` filter. + ## 4.2.0 - 2022-07-26 ### Added diff --git a/src/helpers/ArrayHelper.php b/src/helpers/ArrayHelper.php index 914af947fb3..99e2c417264 100644 --- a/src/helpers/ArrayHelper.php +++ b/src/helpers/ArrayHelper.php @@ -464,12 +464,16 @@ public static function getValue($array, $key, $default = null) */ public static function removeValue(&$array, $value, bool $strict = false) { + if (is_object($value)) { + $strict = true; + } + $result = []; if (is_array($array)) { foreach ($array as $key => $val) { if ( - ($strict && $val === $value) || + (($strict || is_object($val)) && $val === $value) || (!$strict && $val == $value) ) { $result[$key] = $val; diff --git a/tests/unit/helpers/ArrayHelperTest.php b/tests/unit/helpers/ArrayHelperTest.php index 8ce2ceb82e4..0dbb5e304fe 100644 --- a/tests/unit/helpers/ArrayHelperTest.php +++ b/tests/unit/helpers/ArrayHelperTest.php @@ -672,6 +672,11 @@ public function removeValueDataProvider(): array 3, true, ], + [ + [(object)['foo' => true], (object)['bar' => true]], + [(object)['foo' => true], (object)['bar' => true]], + 1, + ], ]; } } From 26388d2750cffc8aaccf928a1ce662c4c2d3ceaa Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 16:44:59 -0700 Subject: [PATCH 7/9] Fixed test --- src/helpers/ArrayHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/ArrayHelper.php b/src/helpers/ArrayHelper.php index 99e2c417264..03da6b3ca3a 100644 --- a/src/helpers/ArrayHelper.php +++ b/src/helpers/ArrayHelper.php @@ -474,7 +474,7 @@ public static function removeValue(&$array, $value, bool $strict = false) foreach ($array as $key => $val) { if ( (($strict || is_object($val)) && $val === $value) || - (!$strict && $val == $value) + (!$strict && !is_object($val) && $val == $value) ) { $result[$key] = $val; unset($array[$key]); From c631c1bf170b2c880dbef8541d931f82530fa035 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 16:52:38 -0700 Subject: [PATCH 8/9] Take 3 --- tests/unit/helpers/ArrayHelperTest.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/helpers/ArrayHelperTest.php b/tests/unit/helpers/ArrayHelperTest.php index 0dbb5e304fe..5c4323732f5 100644 --- a/tests/unit/helpers/ArrayHelperTest.php +++ b/tests/unit/helpers/ArrayHelperTest.php @@ -655,6 +655,9 @@ public function getValueDataProvider(): array public function removeValueDataProvider(): array { + $obj1 = (object)['foo' => true]; + $obj2 = (object)['bar' => true]; + return [ [ ['a', 'b'], @@ -673,8 +676,8 @@ public function removeValueDataProvider(): array true, ], [ - [(object)['foo' => true], (object)['bar' => true]], - [(object)['foo' => true], (object)['bar' => true]], + [$obj1, $obj2], + [$obj1, $obj2], 1, ], ]; From 2054f3dd600e7cba4619eb5f99d947b15493f609 Mon Sep 17 00:00:00 2001 From: brandonkelly Date: Tue, 26 Jul 2022 17:08:39 -0700 Subject: [PATCH 9/9] Finish 4.2.0.1 --- CHANGELOG.md | 2 +- src/config/app.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3062605ad9..29f318b3ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Release Notes for Craft CMS 4 -## Unreleased +## 4.2.0.1 - 2022-07-26 ### Fixed - Fixed an error that could occur when passing an object into `craft\helpers\ArrayHelper::removeValue()` or the `|without` filter. diff --git a/src/config/app.php b/src/config/app.php index ce62129d05b..b50f01bfdcc 100644 --- a/src/config/app.php +++ b/src/config/app.php @@ -3,7 +3,7 @@ return [ 'id' => 'CraftCMS', 'name' => 'Craft CMS', - 'version' => '4.2.0', + 'version' => '4.2.0.1', 'schemaVersion' => '4.0.0.9', 'minVersionRequired' => '3.7.11', 'basePath' => dirname(__DIR__), // Defines the @app alias