From ced6d04dc1f48498b67ed0dd52e7692fde0bdcd2 Mon Sep 17 00:00:00 2001 From: Akbar Herlambang Date: Tue, 26 Sep 2023 16:16:35 +0800 Subject: [PATCH 01/20] fix: #19978 - Mistake in Korean translation --- framework/messages/ko/yii.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/messages/ko/yii.php b/framework/messages/ko/yii.php index 4fe82311fe..2f204437e2 100644 --- a/framework/messages/ko/yii.php +++ b/framework/messages/ko/yii.php @@ -75,8 +75,8 @@ return [ '{attribute} must be greater than or equal to "{compareValue}".' => '{attribute}는 "{compareValue}" 보다 크거나 같아야 합니다.', '{attribute} must be less than "{compareValue}".' => '{attribute}는 "{compareValue}" 보다 작아야 합니다.', '{attribute} must be less than or equal to "{compareValue}".' => '{attribute}는 "{compareValue}" 보다 작거나 같아야 합니다.', - '{attribute} must be no greater than {max}.' => '{attribute}는 "{compareValue}" 보다 클 수 없습니다.', - '{attribute} must be no less than {min}.' => '{attribute}는 "{compareValue}" 보다 작을 수 없습니다.', + '{attribute} must be no greater than {max}.' => '{attribute}는 {max} 보다 클 수 없습니다.', + '{attribute} must be no less than {min}.' => '{attribute}는 {min} 보다 작을 수 없습니다.', '{attribute} must be repeated exactly.' => '{attribute}는 정확하게 반복합니다.', '{attribute} must not be equal to "{compareValue}".' => '{attribute}는 "{compareValue}"와 같을 수 없습니다.', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute}는 최소 {min}자 이어야합니다.', From 17386c75012c11f0e3d1c403defb01db23fd0b67 Mon Sep 17 00:00:00 2001 From: Akbar Herlambang Date: Tue, 26 Sep 2023 16:24:47 +0800 Subject: [PATCH 02/20] fix: keep doublequote --- framework/messages/ko/yii.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/messages/ko/yii.php b/framework/messages/ko/yii.php index 2f204437e2..b0ad872fe7 100644 --- a/framework/messages/ko/yii.php +++ b/framework/messages/ko/yii.php @@ -75,8 +75,8 @@ return [ '{attribute} must be greater than or equal to "{compareValue}".' => '{attribute}는 "{compareValue}" 보다 크거나 같아야 합니다.', '{attribute} must be less than "{compareValue}".' => '{attribute}는 "{compareValue}" 보다 작아야 합니다.', '{attribute} must be less than or equal to "{compareValue}".' => '{attribute}는 "{compareValue}" 보다 작거나 같아야 합니다.', - '{attribute} must be no greater than {max}.' => '{attribute}는 {max} 보다 클 수 없습니다.', - '{attribute} must be no less than {min}.' => '{attribute}는 {min} 보다 작을 수 없습니다.', + '{attribute} must be no greater than {max}.' => '{attribute}는 "{max}" 보다 클 수 없습니다.', + '{attribute} must be no less than {min}.' => '{attribute}는 "{min}" 보다 작을 수 없습니다.', '{attribute} must be repeated exactly.' => '{attribute}는 정확하게 반복합니다.', '{attribute} must not be equal to "{compareValue}".' => '{attribute}는 "{compareValue}"와 같을 수 없습니다.', '{attribute} should contain at least {min, number} {min, plural, one{character} other{characters}}.' => '{attribute}는 최소 {min}자 이어야합니다.', From 764926a877f6c407cb85daefcf3324253d137f43 Mon Sep 17 00:00:00 2001 From: lubosdz Date: Thu, 28 Sep 2023 22:34:58 +0200 Subject: [PATCH 03/20] Do not duplicate log messages in memory --- framework/CHANGELOG.md | 1 + framework/log/FileTarget.php | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 0158d4bab3..189d30967f 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.50 under development ------------------------ +- Bug #19984: Do not duplicate log messages in memory (lubosdz) - Bug #19925: Improved PHP version check when handling MIME types (schmunk42) - Bug #19940: File Log writer without newline (terabytesoftw) - Bug #19951: Removed unneeded MIME file tests (schmunk42) diff --git a/framework/log/FileTarget.php b/framework/log/FileTarget.php index d816f73a8d..f80b154aaf 100644 --- a/framework/log/FileTarget.php +++ b/framework/log/FileTarget.php @@ -107,9 +107,8 @@ class FileTarget extends Target public function export() { $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n"; - $trimmedText = trim($text); - if (empty($trimmedText)) { + if (!trim($text)) { return; // No messages to export, so we exit the function early } From 7f3397a5cce51b378bd1557f2b8a1162f7a34c89 Mon Sep 17 00:00:00 2001 From: lubosdz Date: Sun, 1 Oct 2023 23:31:10 +0200 Subject: [PATCH 04/20] Update framework/log/FileTarget.php Co-authored-by: Bizley --- framework/log/FileTarget.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/log/FileTarget.php b/framework/log/FileTarget.php index f80b154aaf..d4c267e2ed 100644 --- a/framework/log/FileTarget.php +++ b/framework/log/FileTarget.php @@ -108,7 +108,7 @@ class FileTarget extends Target { $text = implode("\n", array_map([$this, 'formatMessage'], $this->messages)) . "\n"; - if (!trim($text)) { + if (trim($text) === '') { return; // No messages to export, so we exit the function early } From aec836620fc74f918978924b08648277769b08ac Mon Sep 17 00:00:00 2001 From: Yuriy Bachevskiy Date: Wed, 4 Oct 2023 15:43:18 +0700 Subject: [PATCH 05/20] Update concept-di-container.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Сслка "Конфигурация приложения" была не верной, она вела на страницу "Service-locator'a" --- docs/guide-ru/concept-di-container.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide-ru/concept-di-container.md b/docs/guide-ru/concept-di-container.md index 80c2c723d8..2812d4bd8f 100644 --- a/docs/guide-ru/concept-di-container.md +++ b/docs/guide-ru/concept-di-container.md @@ -498,7 +498,7 @@ class HotelController extends Controller как можно раньше. Ниже приведены рекомендуемые практики: * Если вы разработчик приложения, то вы можете зарегистрировать зависимости в конфигурации вашего приложения. - Как это сделать описано в подразделе [Конфигурация приложения](concept-service-locator.md#application-configurations) + Как это сделать описано в подразделе [Конфигурация приложения](concept-configurations.md#application-configurations) раздела [Конфигурации](concept-configurations.md). * Если вы разработчик распространяемого [расширения](structure-extensions.md), то вы можете зарегистрировать зависимости в загрузочном классе расширения. From 48d754cac227418e60dd9ef3be453201345a13a7 Mon Sep 17 00:00:00 2001 From: Bizley Date: Thu, 5 Oct 2023 18:00:59 +0200 Subject: [PATCH 06/20] Update CHANGELOG.md --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 189d30967f..887cc9c8c9 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,7 +1,7 @@ Yii Framework 2 Change Log ========================== -2.0.50 under development +2.0.49.1 under development ------------------------ - Bug #19984: Do not duplicate log messages in memory (lubosdz) From 4a1f2c6b9bc90427e91da73f5e8c8fa33d3c53c1 Mon Sep 17 00:00:00 2001 From: Bizley Date: Thu, 5 Oct 2023 18:12:27 +0200 Subject: [PATCH 07/20] release version 2.0.49.1 --- framework/BaseYii.php | 2 +- framework/CHANGELOG.md | 9 +++++---- framework/helpers/mimeTypes.php | 3 +-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/framework/BaseYii.php b/framework/BaseYii.php index 496f6aa121..061bfe35f5 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -93,7 +93,7 @@ class BaseYii */ public static function getVersion() { - return '2.0.50-dev'; + return '2.0.49.1'; } /** diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 887cc9c8c9..06b79df556 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,16 +1,17 @@ Yii Framework 2 Change Log ========================== -2.0.49.1 under development ------------------------- +2.0.49.1 October 05, 2023 +------------------------- -- Bug #19984: Do not duplicate log messages in memory (lubosdz) - Bug #19925: Improved PHP version check when handling MIME types (schmunk42) - Bug #19940: File Log writer without newline (terabytesoftw) -- Bug #19951: Removed unneeded MIME file tests (schmunk42) - Bug #19950: Fix `Query::groupBy(null)` causes error for PHP 8.1: `trim(): Passing null to parameter #1 ($string) of type string is deprecated` (uaoleg) +- Bug #19951: Removed unneeded MIME file tests (schmunk42) +- Bug #19984: Do not duplicate log messages in memory (lubosdz) - Enh #19780: added pcntl to requirements check (schmunk42) + 2.0.49 August 29, 2023 ---------------------- diff --git a/framework/helpers/mimeTypes.php b/framework/helpers/mimeTypes.php index e91f80f95f..707bdc7717 100644 --- a/framework/helpers/mimeTypes.php +++ b/framework/helpers/mimeTypes.php @@ -1003,8 +1003,7 @@ $mimeTypes = [ 'zmm' => 'application/vnd.handheld-entertainment+xml', ]; -# fix for bundled libmagic bug, see also https://github.com/yiisoft/yii2/issues/19925 -if ((PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80122) || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80209)) { +if (PHP_VERSION_ID >= 80100) { $mimeTypes = array_replace($mimeTypes, array('xz' => 'application/octet-stream')); } From 290e03cddc04a6568ad82bb1279c4834025bd573 Mon Sep 17 00:00:00 2001 From: Bizley Date: Thu, 5 Oct 2023 18:12:47 +0200 Subject: [PATCH 08/20] prepare for next release --- framework/BaseYii.php | 2 +- framework/CHANGELOG.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/BaseYii.php b/framework/BaseYii.php index 061bfe35f5..496f6aa121 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -93,7 +93,7 @@ class BaseYii */ public static function getVersion() { - return '2.0.49.1'; + return '2.0.50-dev'; } /** diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 06b79df556..8c3d204757 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,6 +1,12 @@ Yii Framework 2 Change Log ========================== +2.0.50 under development +------------------------ + +- no changes in this release. + + 2.0.49.1 October 05, 2023 ------------------------- From 9f51fe3b4b84a35e84f0bb5e9378d57eecbcbfae Mon Sep 17 00:00:00 2001 From: Robert Korulczyk Date: Fri, 6 Oct 2023 10:02:32 +0200 Subject: [PATCH 09/20] Revert changes in `mimeTypes.php` from 4a1f2c6b9bc90427e91da73f5e8c8fa33d3c53c1 restores https://github.com/yiisoft/yii2/pull/19936 --- framework/CHANGELOG.md | 3 +-- framework/helpers/mimeTypes.php | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 8c3d204757..35e8ebde9b 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,13 +4,12 @@ Yii Framework 2 Change Log 2.0.50 under development ------------------------ -- no changes in this release. +- Bug #19925: Improved PHP version check when handling MIME types (schmunk42) 2.0.49.1 October 05, 2023 ------------------------- -- Bug #19925: Improved PHP version check when handling MIME types (schmunk42) - Bug #19940: File Log writer without newline (terabytesoftw) - Bug #19950: Fix `Query::groupBy(null)` causes error for PHP 8.1: `trim(): Passing null to parameter #1 ($string) of type string is deprecated` (uaoleg) - Bug #19951: Removed unneeded MIME file tests (schmunk42) diff --git a/framework/helpers/mimeTypes.php b/framework/helpers/mimeTypes.php index 707bdc7717..e91f80f95f 100644 --- a/framework/helpers/mimeTypes.php +++ b/framework/helpers/mimeTypes.php @@ -1003,7 +1003,8 @@ $mimeTypes = [ 'zmm' => 'application/vnd.handheld-entertainment+xml', ]; -if (PHP_VERSION_ID >= 80100) { +# fix for bundled libmagic bug, see also https://github.com/yiisoft/yii2/issues/19925 +if ((PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80122) || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80209)) { $mimeTypes = array_replace($mimeTypes, array('xz' => 'application/octet-stream')); } From 7665e562163495bd88ea4849d10c800175db5d85 Mon Sep 17 00:00:00 2001 From: salehhashemi1992 <81674631+salehhashemi1992@users.noreply.github.com> Date: Sat, 7 Oct 2023 22:34:56 +0330 Subject: [PATCH 10/20] update actions/checkout to v4 --- .github/workflows/build.yml | 2 +- .github/workflows/ci-mssql.yml | 2 +- .github/workflows/ci-mysql.yml | 2 +- .github/workflows/ci-node.yml | 2 +- .github/workflows/ci-oracle.yml | 2 +- .github/workflows/ci-pgsql.yml | 2 +- .github/workflows/ci-sqlite.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 30b988edb4..6c3b0dcc34 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -71,7 +71,7 @@ jobs: run: sudo locale-gen fr_FR.UTF-8 - name: Checkout. - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP. uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 94255d93eb..777f91fd30 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -43,7 +43,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Create MS SQL Database run: docker exec -i mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'YourStrong!Passw0rd' -Q 'CREATE DATABASE yiitest' diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index a948a9e4ca..a1c201b07c 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -44,7 +44,7 @@ jobs: steps: - name: Checkout. - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP with extensions. uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/ci-node.yml b/.github/workflows/ci-node.yml index 0d93773355..3f49942b84 100644 --- a/.github/workflows/ci-node.yml +++ b/.github/workflows/ci-node.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout. - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install dependencies. run: composer update $DEFAULT_COMPOSER_FLAGS diff --git a/.github/workflows/ci-oracle.yml b/.github/workflows/ci-oracle.yml index 21520a1045..be139ff540 100644 --- a/.github/workflows/ci-oracle.yml +++ b/.github/workflows/ci-oracle.yml @@ -35,7 +35,7 @@ jobs: steps: - name: Checkout. - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP with extensions. uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index edaf4a5df5..8c623c283b 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -48,7 +48,7 @@ jobs: steps: - name: Checkout. - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP with extensions uses: shivammathur/setup-php@v2 diff --git a/.github/workflows/ci-sqlite.yml b/.github/workflows/ci-sqlite.yml index b82d187ef9..e163da1100 100644 --- a/.github/workflows/ci-sqlite.yml +++ b/.github/workflows/ci-sqlite.yml @@ -31,7 +31,7 @@ jobs: steps: - name: Checkout. - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install PHP with extensions. uses: shivammathur/setup-php@v2 From 4addf02c262c203f482690288027b0be30cd679b Mon Sep 17 00:00:00 2001 From: Bizley Date: Sun, 8 Oct 2023 13:03:48 +0200 Subject: [PATCH 11/20] Fix mime type generator --- build/controllers/MimeTypeController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build/controllers/MimeTypeController.php b/build/controllers/MimeTypeController.php index 9da23f67fc..fd0275579f 100644 --- a/build/controllers/MimeTypeController.php +++ b/build/controllers/MimeTypeController.php @@ -124,7 +124,8 @@ class MimeTypeController extends Controller */ \$mimeTypes = $array; -if (PHP_VERSION_ID >= 80100) { +# fix for bundled libmagic bug, see also https://github.com/yiisoft/yii2/issues/19925 +if ((PHP_VERSION_ID >= 80100 && PHP_VERSION_ID < 80122) || (PHP_VERSION_ID >= 80200 && PHP_VERSION_ID < 80209)) { \$mimeTypes = array_replace(\$mimeTypes, array('xz' => 'application/octet-stream')); } From 0726714e55bee5d502233cd00cfee0e08b7463d6 Mon Sep 17 00:00:00 2001 From: Bizley Date: Sun, 8 Oct 2023 13:20:43 +0200 Subject: [PATCH 12/20] Added note --- build/controllers/MimeTypeController.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build/controllers/MimeTypeController.php b/build/controllers/MimeTypeController.php index fd0275579f..7986dd56cc 100644 --- a/build/controllers/MimeTypeController.php +++ b/build/controllers/MimeTypeController.php @@ -121,6 +121,9 @@ class MimeTypeController extends Controller * Its content is generated from the apache http mime.types file. * https://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup * This file has been placed in the public domain for unlimited redistribution. + * + * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * otherwise they will be lost on next build. */ \$mimeTypes = $array; @@ -149,6 +152,9 @@ EOD; * MIME aliases. * * This file contains aliases for MIME types. + * + * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * otherwise they will be lost on next build. */ return $array; @@ -210,6 +216,9 @@ EOD; * Its content is generated from the apache http mime.types file. * https://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup * This file has been placed in the public domain for unlimited redistribution. + * + * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * otherwise they will be lost on next build. */ return $array; From 049e37c0a55fd4d1ba6af1b48a4dfeb3019c4613 Mon Sep 17 00:00:00 2001 From: Yuriy Bachevskiy Date: Thu, 12 Oct 2023 21:11:11 +0700 Subject: [PATCH 13/20] Update structure-controllers.md (#20003) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit добавил пропущенное слово "как" --- docs/guide-ru/structure-controllers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide-ru/structure-controllers.md b/docs/guide-ru/structure-controllers.md index c55a8cf151..5765f26c16 100644 --- a/docs/guide-ru/structure-controllers.md +++ b/docs/guide-ru/structure-controllers.md @@ -310,7 +310,7 @@ class HelloWorldAction extends Action [[yii\console\Response::exitStatus|статус выхода]] исполнения команды. В вышеприведенных примерах, все результаты действий являются строками, которые будут использованы в качестве тела ответа, -высланного пользователю. Следующий пример, показывает действие может перенаправить браузер пользователя на новый URL, с помощью +высланного пользователю. Следующий пример, показывает как действие может перенаправить браузер пользователя на новый URL, с помощью возврата response объекта (т. к. [[yii\web\Controller::redirect()|redirect()]] метод возвращает response объект): ```php From 33254d5dad03009ecb64fe754bb52e6a247e21b6 Mon Sep 17 00:00:00 2001 From: Bizley Date: Thu, 12 Oct 2023 17:43:55 +0200 Subject: [PATCH 14/20] Update CHANGELOG.md 2.0.49.2 changelog --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 35e8ebde9b..e7a09902e1 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,7 +1,7 @@ Yii Framework 2 Change Log ========================== -2.0.50 under development +2.0.49.2 under development ------------------------ - Bug #19925: Improved PHP version check when handling MIME types (schmunk42) From 4f1735995ad1dfe5b8c51807d1e07ac1ee54a04d Mon Sep 17 00:00:00 2001 From: Bizley Date: Thu, 12 Oct 2023 17:46:26 +0200 Subject: [PATCH 15/20] release version 2.0.49.2 --- framework/BaseYii.php | 2 +- framework/CHANGELOG.md | 4 ++-- framework/helpers/mimeAliases.php | 3 +++ framework/helpers/mimeExtensions.php | 3 +++ framework/helpers/mimeTypes.php | 3 +++ 5 files changed, 12 insertions(+), 3 deletions(-) diff --git a/framework/BaseYii.php b/framework/BaseYii.php index 496f6aa121..fe2301b0fd 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -93,7 +93,7 @@ class BaseYii */ public static function getVersion() { - return '2.0.50-dev'; + return '2.0.49.2'; } /** diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e7a09902e1..ecf64bb49a 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,8 +1,8 @@ Yii Framework 2 Change Log ========================== -2.0.49.2 under development ------------------------- +2.0.49.2 October 12, 2023 +------------------------- - Bug #19925: Improved PHP version check when handling MIME types (schmunk42) diff --git a/framework/helpers/mimeAliases.php b/framework/helpers/mimeAliases.php index 4cd89888a7..a9e677adcb 100644 --- a/framework/helpers/mimeAliases.php +++ b/framework/helpers/mimeAliases.php @@ -3,6 +3,9 @@ * MIME aliases. * * This file contains aliases for MIME types. + * + * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * otherwise they will be lost on next build. */ return [ 'text/rtf' => 'application/rtf', diff --git a/framework/helpers/mimeExtensions.php b/framework/helpers/mimeExtensions.php index 946d61cd0c..e4936030fd 100644 --- a/framework/helpers/mimeExtensions.php +++ b/framework/helpers/mimeExtensions.php @@ -8,6 +8,9 @@ * Its content is generated from the apache http mime.types file. * https://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup * This file has been placed in the public domain for unlimited redistribution. + * + * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * otherwise they will be lost on next build. */ return [ 'application/andrew-inset' => 'ez', diff --git a/framework/helpers/mimeTypes.php b/framework/helpers/mimeTypes.php index e91f80f95f..f895e8d072 100644 --- a/framework/helpers/mimeTypes.php +++ b/framework/helpers/mimeTypes.php @@ -7,6 +7,9 @@ * Its content is generated from the apache http mime.types file. * https://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup * This file has been placed in the public domain for unlimited redistribution. + * + * All extra changes made to this file must be comitted to /build/controllers/MimeTypeController.php + * otherwise they will be lost on next build. */ $mimeTypes = [ 123 => 'application/vnd.lotus-1-2-3', From 505fd5a2f827f99e34351045ace542676674fb77 Mon Sep 17 00:00:00 2001 From: Bizley Date: Thu, 12 Oct 2023 17:46:49 +0200 Subject: [PATCH 16/20] prepare for next release --- framework/BaseYii.php | 2 +- framework/CHANGELOG.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/BaseYii.php b/framework/BaseYii.php index fe2301b0fd..496f6aa121 100644 --- a/framework/BaseYii.php +++ b/framework/BaseYii.php @@ -93,7 +93,7 @@ class BaseYii */ public static function getVersion() { - return '2.0.49.2'; + return '2.0.50-dev'; } /** diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index ecf64bb49a..a2540e5d7f 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -1,6 +1,12 @@ Yii Framework 2 Change Log ========================== +2.0.50 under development +------------------------ + +- no changes in this release. + + 2.0.49.2 October 12, 2023 ------------------------- From 02ed8080564339c95e9e2f489344c6551ee25758 Mon Sep 17 00:00:00 2001 From: PowerGamer1 Date: Thu, 13 Jul 2023 15:36:16 +0300 Subject: [PATCH 17/20] New methods: BaseActiveRecord::loadRelations() and BaseActiveRecord::loadRelationsFor(). --- framework/CHANGELOG.md | 2 +- framework/db/BaseActiveRecord.php | 53 +++++++++++++++++++++++++ tests/framework/db/ActiveRecordTest.php | 47 ++++++++++++++++++++++ 3 files changed, 101 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index a2540e5d7f..a026939053 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,7 +4,7 @@ Yii Framework 2 Change Log 2.0.50 under development ------------------------ -- no changes in this release. +- Enh #12743: Added new methods `BaseActiveRecord::loadRelations()` and `BaseActiveRecord::loadRelationsFor()` to eager load related models for existing primary model instances (PowerGamer1) 2.0.49.2 October 12, 2023 diff --git a/framework/db/BaseActiveRecord.php b/framework/db/BaseActiveRecord.php index 61cf377409..ab5414416c 100644 --- a/framework/db/BaseActiveRecord.php +++ b/framework/db/BaseActiveRecord.php @@ -1787,4 +1787,57 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface return $newValue !== $oldValue; } + + /** + * Eager loads related models for the already loaded primary models. + * + * Helps to reduce the number of queries performed against database if some related models are only used + * when a specific condition is met. For example: + * + * ```php + * $customers = Customer::find()->where(['country_id' => 123])->all(); + * if (Yii:app()->getUser()->getIdentity()->canAccessOrders()) { + * Customer::loadRelationsFor($customers, 'orders.items'); + * } + * ``` + * + * @param array|ActiveRecordInterface[] $models array of primary models. Each model should have the same type and can be: + * - an active record instance; + * - active record instance represented by array (i.e. active record was loaded using [[ActiveQuery::asArray()]]). + * @param string|array $relationNames the names of the relations of primary models to be loaded from database. See [[ActiveQueryInterface::with()]] on how to specify this argument. + * @param bool $asArray whether to load each related model as an array or an object (if the relation itself does not specify that). + * @since 2.0.49 + */ + public static function loadRelationsFor(&$models, $relationNames, $asArray = false) + { + // ActiveQueryTrait::findWith() called below assumes $models array is non-empty. + if (empty($models)) { + return; + } + + static::find()->asArray($asArray)->findWith((array)$relationNames, $models); + } + + /** + * Eager loads related models for the already loaded primary model. + * + * Helps to reduce the number of queries performed against database if some related models are only used + * when a specific condition is met. For example: + * + * ```php + * $customer = Customer::find()->where(['id' => 123])->one(); + * if (Yii:app()->getUser()->getIdentity()->canAccessOrders()) { + * $customer->loadRelations('orders.items'); + * } + * ``` + * + * @param string|array $relationNames the names of the relations of this model to be loaded from database. See [[ActiveQueryInterface::with()]] on how to specify this argument. + * @param bool $asArray whether to load each relation as an array or an object (if the relation itself does not specify that). + * @since 2.0.49 + */ + public function loadRelations($relationNames, $asArray = false) + { + $models = [$this]; + static::loadRelationsFor($models, $relationNames, $asArray); + } } diff --git a/tests/framework/db/ActiveRecordTest.php b/tests/framework/db/ActiveRecordTest.php index b74803b94d..e50cca3e02 100644 --- a/tests/framework/db/ActiveRecordTest.php +++ b/tests/framework/db/ActiveRecordTest.php @@ -2225,6 +2225,53 @@ abstract class ActiveRecordTest extends DatabaseTestCase $attr = 'model2.doesNotExist.attr1'; $this->assertEquals($model->generateAttributeLabel($attr), $model->getAttributeLabel($attr)); } + + public function testLoadRelations() + { + // Test eager loading relations for multiple primary models using loadRelationsFor(). + /** @var Customer[] $customers */ + $customers = Customer::find()->all(); + Customer::loadRelationsFor($customers, ['orders.items']); + foreach ($customers as $customer) { + $this->assertTrue($customer->isRelationPopulated('orders')); + foreach ($customer->orders as $order) { + $this->assertTrue($order->isRelationPopulated('items')); + } + } + + // Test eager loading relations as arrays. + /** @var array $customers */ + $customers = Customer::find()->asArray(true)->all(); + Customer::loadRelationsFor($customers, ['orders.items' => function ($query) { $query->asArray(false); }], true); + foreach ($customers as $customer) { + $this->assertTrue(isset($customer['orders'])); + $this->assertTrue(is_array($customer['orders'])); + foreach ($customer['orders'] as $order) { + $this->assertTrue(is_array($order)); + $this->assertTrue(isset($order['items'])); + $this->assertTrue(is_array($order['items'])); + foreach ($order['items'] as $item) { + $this->assertFalse(is_array($item)); + } + } + } + + // Test eager loading relations for a single primary model using loadRelations(). + /** @var Customer $customer */ + $customer = Customer::find()->where(['id' => 1])->one(); + $customer->loadRelations('orders.items'); + $this->assertTrue($customer->isRelationPopulated('orders')); + foreach ($customer->orders as $order) { + $this->assertTrue($order->isRelationPopulated('items')); + } + + // Test eager loading previously loaded relation (relation value should be replaced with a new value loaded from database). + /** @var Customer $customer */ + $customer = Customer::find()->where(['id' => 2])->with(['orders' => function ($query) { $query->orderBy(['id' => SORT_ASC]); }])->one(); + $this->assertTrue($customer->orders[0]->id < $customer->orders[1]->id, 'Related models should be sorted by ID in ascending order.'); + $customer->loadRelations(['orders' => function ($query) { $query->orderBy(['id' => SORT_DESC]); }]); + $this->assertTrue($customer->orders[0]->id > $customer->orders[1]->id, 'Related models should be sorted by ID in descending order.'); + } } class LabelTestModel1 extends \yii\db\ActiveRecord From 9875ae6445b61bc117ae319bf00564f276c06663 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Fri, 13 Oct 2023 10:26:42 -0700 Subject: [PATCH 18/20] Fixed a bug where the yii serve command would break if a custom router was supplied and it had a space in the path --- framework/console/controllers/ServeController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/console/controllers/ServeController.php b/framework/console/controllers/ServeController.php index 68a7e50c28..d02c982042 100644 --- a/framework/console/controllers/ServeController.php +++ b/framework/console/controllers/ServeController.php @@ -80,7 +80,7 @@ class ServeController extends Controller } $this->stdout("Quit the server with CTRL-C or COMMAND-C.\n"); - passthru('"' . PHP_BINARY . '"' . " -S {$address} -t \"{$documentRoot}\" $router"); + passthru('"' . PHP_BINARY . '"' . " -S {$address} -t \"{$documentRoot}\" \"$router\""); } /** From 6ceb6f65f4345b46d74f8383346c1b2c117369df Mon Sep 17 00:00:00 2001 From: Wilmer Arambula Date: Sun, 15 Oct 2023 06:28:12 -0300 Subject: [PATCH 19/20] Fix `MaskedInputAsset::class`. --- composer.json | 4 ++-- framework/composer.json | 4 ++-- framework/widgets/MaskedInputAsset.php | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index ed19e7cce4..ef5d068f59 100644 --- a/composer.json +++ b/composer.json @@ -76,8 +76,8 @@ "ezyang/htmlpurifier": "^4.6", "cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0", "bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable", - "bower-asset/inputmask": "~3.2.2 | ~3.3.5 | ~5.0.8 ", - "bower-asset/punycode": "1.3.* | 2.2.*", + "bower-asset/inputmask": "^5.0.8 ", + "bower-asset/punycode": "^2.2", "bower-asset/yii2-pjax": "~2.0.1", "paragonie/random_compat": ">=1" }, diff --git a/framework/composer.json b/framework/composer.json index 951679faec..ff36473707 100644 --- a/framework/composer.json +++ b/framework/composer.json @@ -71,8 +71,8 @@ "ezyang/htmlpurifier": "^4.6", "cebe/markdown": "~1.0.0 | ~1.1.0 | ~1.2.0", "bower-asset/jquery": "3.7.*@stable | 3.6.*@stable | 3.5.*@stable | 3.4.*@stable | 3.3.*@stable | 3.2.*@stable | 3.1.*@stable | 2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable", - "bower-asset/inputmask": "~3.2.2 | ~3.3.5 | ~5.0.8 ", - "bower-asset/punycode": "1.3.* | 2.2.*", + "bower-asset/inputmask": "^5.0.8 ", + "bower-asset/punycode": "^2.2", "bower-asset/yii2-pjax": "~2.0.1", "paragonie/random_compat": ">=1" }, diff --git a/framework/widgets/MaskedInputAsset.php b/framework/widgets/MaskedInputAsset.php index 57748be86f..473f4315ff 100644 --- a/framework/widgets/MaskedInputAsset.php +++ b/framework/widgets/MaskedInputAsset.php @@ -21,7 +21,7 @@ class MaskedInputAsset extends AssetBundle { public $sourcePath = '@bower/inputmask/dist'; public $js = [ - 'jquery.inputmask.bundle.js', + 'jquery.inputmask.js', ]; public $depends = [ 'yii\web\YiiAsset', From 961a952f82ac7bb26045f741c323632ed9deaaea Mon Sep 17 00:00:00 2001 From: Alexandru Trandafir Catalin Date: Mon, 16 Oct 2023 10:17:02 +0300 Subject: [PATCH 20/20] Fix #19927: Fixed `console\controllers\MessageController` when saving translations to database: fixed FK error when adding new string and language at the same time, checking/regenerating all missing messages and dropping messages for unused languages --- framework/CHANGELOG.md | 1 + .../console/controllers/MessageController.php | 161 +++++++++++------- 2 files changed, 97 insertions(+), 65 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index a026939053..2ec245ea22 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -4,6 +4,7 @@ Yii Framework 2 Change Log 2.0.50 under development ------------------------ +- Bug #19927: Fixed `console\controllers\MessageController` when saving translations to database: fixed FK error when adding new string and language at the same time, checking/regenerating all missing messages and dropping messages for unused languages (atrandafir) - Enh #12743: Added new methods `BaseActiveRecord::loadRelations()` and `BaseActiveRecord::loadRelationsFor()` to eager load related models for existing primary model instances (PowerGamer1) diff --git a/framework/console/controllers/MessageController.php b/framework/console/controllers/MessageController.php index e1a7357690..6d5a7d6448 100644 --- a/framework/console/controllers/MessageController.php +++ b/framework/console/controllers/MessageController.php @@ -353,17 +353,7 @@ EOD; foreach ($rows as $row) { $currentMessages[$row['category']][$row['id']] = $row['message']; } - - $currentLanguages = []; - $rows = (new Query())->select(['language'])->from($messageTable)->groupBy('language')->all($db); - foreach ($rows as $row) { - $currentLanguages[] = $row['language']; - } - $missingLanguages = []; - if (!empty($currentLanguages)) { - $missingLanguages = array_diff($languages, $currentLanguages); - } - + $new = []; $obsolete = []; @@ -372,89 +362,130 @@ EOD; if (isset($currentMessages[$category])) { $new[$category] = array_diff($msgs, $currentMessages[$category]); + // obsolete messages per category $obsolete += array_diff($currentMessages[$category], $msgs); } else { $new[$category] = $msgs; } } - + + // obsolete categories foreach (array_diff(array_keys($currentMessages), array_keys($messages)) as $category) { $obsolete += $currentMessages[$category]; } if (!$removeUnused) { foreach ($obsolete as $pk => $msg) { + // skip already marked unused if (strncmp($msg, '@@', 2) === 0 && substr($msg, -2) === '@@') { unset($obsolete[$pk]); } } - } - - $obsolete = array_keys($obsolete); + } + $this->stdout('Inserting new messages...'); - $savedFlag = false; + $insertCount = 0; foreach ($new as $category => $msgs) { foreach ($msgs as $msg) { - $savedFlag = true; - $lastPk = $db->schema->insert($sourceMessageTable, ['category' => $category, 'message' => $msg]); - foreach ($languages as $language) { - $db->createCommand() - ->insert($messageTable, ['id' => $lastPk['id'], 'language' => $language]) - ->execute(); - } + $insertCount++; + $db->schema->insert($sourceMessageTable, ['category' => $category, 'message' => $msg]); } } - - if (!empty($missingLanguages)) { - $updatedMessages = []; - $rows = (new Query())->select(['id', 'category', 'message'])->from($sourceMessageTable)->all($db); - foreach ($rows as $row) { - $updatedMessages[$row['category']][$row['id']] = $row['message']; - } - foreach ($updatedMessages as $category => $msgs) { - foreach ($msgs as $id => $msg) { - $savedFlag = true; - foreach ($missingLanguages as $language) { - $db->createCommand() - ->insert($messageTable, ['id' => $id, 'language' => $language]) - ->execute(); - } - } - } - } - - $this->stdout($savedFlag ? "saved.\n" : "Nothing to save.\n"); + + $this->stdout($insertCount ? "{$insertCount} saved.\n" : "Nothing to save.\n"); + $this->stdout($removeUnused ? 'Deleting obsoleted messages...' : 'Updating obsoleted messages...'); if (empty($obsolete)) { $this->stdout("Nothing obsoleted...skipped.\n"); - return; } - if ($removeUnused) { - $db->createCommand() - ->delete($sourceMessageTable, ['in', 'id', $obsolete]) - ->execute(); - $this->stdout("deleted.\n"); - } elseif ($markUnused) { - $rows = (new Query()) - ->select(['id', 'message']) - ->from($sourceMessageTable) - ->where(['in', 'id', $obsolete]) - ->all($db); - - foreach ($rows as $row) { - $db->createCommand()->update( - $sourceMessageTable, - ['message' => '@@' . $row['message'] . '@@'], - ['id' => $row['id']] - )->execute(); + if ($obsolete) { + if ($removeUnused) { + $affected = $db->createCommand() + ->delete($sourceMessageTable, ['in', 'id', array_keys($obsolete)]) + ->execute(); + $this->stdout("{$affected} deleted.\n"); + } elseif ($markUnused) { + $marked=0; + $rows = (new Query()) + ->select(['id', 'message']) + ->from($sourceMessageTable) + ->where(['in', 'id', array_keys($obsolete)]) + ->all($db); + + foreach ($rows as $row) { + $marked++; + $db->createCommand()->update( + $sourceMessageTable, + ['message' => '@@' . $row['message'] . '@@'], + ['id' => $row['id']] + )->execute(); + } + $this->stdout("{$marked} updated.\n"); + } else { + $this->stdout("kept untouched.\n"); } - $this->stdout("updated.\n"); - } else { - $this->stdout("kept untouched.\n"); } + + // get fresh message id list + $freshMessagesIds = []; + $rows = (new Query())->select(['id'])->from($sourceMessageTable)->all($db); + foreach ($rows as $row) { + $freshMessagesIds[] = $row['id']; + } + + $this->stdout("Generating missing rows..."); + $generatedMissingRows = []; + + foreach ($languages as $language) { + $count = 0; + + // get list of ids of translations for this language + $msgRowsIds = []; + $msgRows = (new Query())->select(['id'])->from($messageTable)->where([ + 'language'=>$language, + ])->all($db); + foreach ($msgRows as $row) { + $msgRowsIds[] = $row['id']; + } + + // insert missing + foreach ($freshMessagesIds as $id) { + if (!in_array($id, $msgRowsIds)) { + $db->createCommand() + ->insert($messageTable, ['id' => $id, 'language' => $language]) + ->execute(); + $count++; + } + } + if ($count) { + $generatedMissingRows[] = "{$count} for {$language}"; + } + } + + $this->stdout($generatedMissingRows ? implode(", ", $generatedMissingRows).".\n" : "Nothing to do.\n"); + + $this->stdout("Dropping unused languages..."); + $droppedLanguages=[]; + + $currentLanguages = []; + $rows = (new Query())->select(['language'])->from($messageTable)->groupBy('language')->all($db); + foreach ($rows as $row) { + $currentLanguages[] = $row['language']; + } + + foreach ($currentLanguages as $currentLanguage) { + if (!in_array($currentLanguage, $languages)) { + $deleted=$db->createCommand()->delete($messageTable, "language=:language", [ + 'language'=>$currentLanguage, + ])->execute(); + $droppedLanguages[] = "removed {$deleted} rows for $currentLanguage"; + } + } + + $this->stdout($droppedLanguages ? implode(", ", $droppedLanguages).".\n" : "Nothing to do.\n"); } /**