From 82fbb568e0269fb703455bd99e8e7876826d4384 Mon Sep 17 00:00:00 2001 From: Sebastian Thierer Date: Thu, 9 Jul 2015 11:52:33 -0300 Subject: [PATCH 01/23] Fix for 9056 --- framework/CHANGELOG.md | 1 + framework/db/mysql/QueryBuilder.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 50ce96c3a8..227d59fe60 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -23,6 +23,7 @@ Yii Framework 2 Change Log - Bug #8772: ActiveQuery failed removing duplicate records after join when the resultset did not contain the pk values e.g. after grouping (cebe) - Bug #8900: Fixed determine active menu item with url-alias in route `\yii\widgets\Menu::isItemActive()` (demi) - Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe) +- Bug #9056: Workaround over mysql create index bug and table name change to lowercase. (sebathi) - Bug: Fixed string comparison in `BaseActiveRecord::unlink()` which may result in wrong comparison result for hash valued primary keys starting with `0e` (cebe) - Bug: Pass correct action name to `yii\console\Controller::options()` when default action was requested (cebe) - Bug: Automatic garbage collection in `yii\caching\FileCache` was not triggered (kidol) diff --git a/framework/db/mysql/QueryBuilder.php b/framework/db/mysql/QueryBuilder.php index 818513cdf7..67f87b0cd9 100644 --- a/framework/db/mysql/QueryBuilder.php +++ b/framework/db/mysql/QueryBuilder.php @@ -80,6 +80,25 @@ class QueryBuilder extends \yii\db\QueryBuilder . $this->db->quoteColumnName($newName); } + /** + * Builds a SQL statement for creating a new index. + * @param string $name the name of the index. The name will be properly quoted by the method. + * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method. + * @param string|array $columns the column(s) that should be included in the index. If there are multiple columns, + * separate them with commas or use an array to represent them. Each column name will be properly quoted + * by the method, unless a parenthesis is found in the name. + * @param boolean $unique whether to add UNIQUE constraint on the created index. + * @return string the SQL statement for creating a new index. + */ + public function createIndex($name, $table, $columns, $unique = false) + { + return 'ALTER TABLE ' + . $this->db->quoteTableName($table) + . ($unique ? ' ADD UNIQUE INDEX ' : ' ADD INDEX ') + . $this->db->quoteTableName($name) + . ' (' . $this->buildColumns($columns) . ')'; + } + /** * Builds a SQL statement for dropping a foreign key constraint. * @param string $name the name of the foreign key constraint to be dropped. The name will be properly quoted by the method. From bc0a6662ee3e24b31759c2ff62c42f57bc6cf91b Mon Sep 17 00:00:00 2001 From: Sebastian Thierer Date: Thu, 9 Jul 2015 11:54:28 -0300 Subject: [PATCH 02/23] typo on changelog --- framework/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 227d59fe60..2953e005d4 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -23,7 +23,7 @@ Yii Framework 2 Change Log - Bug #8772: ActiveQuery failed removing duplicate records after join when the resultset did not contain the pk values e.g. after grouping (cebe) - Bug #8900: Fixed determine active menu item with url-alias in route `\yii\widgets\Menu::isItemActive()` (demi) - Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe) -- Bug #9056: Workaround over mysql create index bug and table name change to lowercase. (sebathi) +- Bug #9063: Workaround over mysql create index bug and table name change to lowercase. (sebathi) - Bug: Fixed string comparison in `BaseActiveRecord::unlink()` which may result in wrong comparison result for hash valued primary keys starting with `0e` (cebe) - Bug: Pass correct action name to `yii\console\Controller::options()` when default action was requested (cebe) - Bug: Automatic garbage collection in `yii\caching\FileCache` was not triggered (kidol) From e0d2107e1b3bac6777dda51d3c54b75d5b3586b4 Mon Sep 17 00:00:00 2001 From: Sebastian Thierer Date: Fri, 10 Jul 2015 12:27:15 -0300 Subject: [PATCH 03/23] Mysql unique index creation fix. --- framework/CHANGELOG.md | 2 +- framework/db/mysql/QueryBuilder.php | 11 ++--------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 2953e005d4..508ac20831 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -23,7 +23,7 @@ Yii Framework 2 Change Log - Bug #8772: ActiveQuery failed removing duplicate records after join when the resultset did not contain the pk values e.g. after grouping (cebe) - Bug #8900: Fixed determine active menu item with url-alias in route `\yii\widgets\Menu::isItemActive()` (demi) - Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe) -- Bug #9063: Workaround over mysql create index bug and table name change to lowercase. (sebathi) +- Bug #9063: Workaround over MySQL create index bug and table name change to lowercase. (sebathi) - Bug: Fixed string comparison in `BaseActiveRecord::unlink()` which may result in wrong comparison result for hash valued primary keys starting with `0e` (cebe) - Bug: Pass correct action name to `yii\console\Controller::options()` when default action was requested (cebe) - Bug: Automatic garbage collection in `yii\caching\FileCache` was not triggered (kidol) diff --git a/framework/db/mysql/QueryBuilder.php b/framework/db/mysql/QueryBuilder.php index 67f87b0cd9..ef4860fc0e 100644 --- a/framework/db/mysql/QueryBuilder.php +++ b/framework/db/mysql/QueryBuilder.php @@ -81,14 +81,7 @@ class QueryBuilder extends \yii\db\QueryBuilder } /** - * Builds a SQL statement for creating a new index. - * @param string $name the name of the index. The name will be properly quoted by the method. - * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method. - * @param string|array $columns the column(s) that should be included in the index. If there are multiple columns, - * separate them with commas or use an array to represent them. Each column name will be properly quoted - * by the method, unless a parenthesis is found in the name. - * @param boolean $unique whether to add UNIQUE constraint on the created index. - * @return string the SQL statement for creating a new index. + * @inheritdoc */ public function createIndex($name, $table, $columns, $unique = false) { @@ -98,7 +91,7 @@ class QueryBuilder extends \yii\db\QueryBuilder . $this->db->quoteTableName($name) . ' (' . $this->buildColumns($columns) . ')'; } - + /** * Builds a SQL statement for dropping a foreign key constraint. * @param string $name the name of the foreign key constraint to be dropped. The name will be properly quoted by the method. From 897cea0c099b56e25bdf271312eb23a095d21e62 Mon Sep 17 00:00:00 2001 From: Linux2000 Date: Wed, 15 Jul 2015 14:10:11 +0300 Subject: [PATCH 04/23] Update tutorial-i18n.md Fix typos --- docs/guide-ru/tutorial-i18n.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide-ru/tutorial-i18n.md b/docs/guide-ru/tutorial-i18n.md index ff5e98afa7..583a2ba628 100644 --- a/docs/guide-ru/tutorial-i18n.md +++ b/docs/guide-ru/tutorial-i18n.md @@ -13,7 +13,7 @@ Yii располагает несколькими средствами, приз Локализация и языки ------------------- -В Yii приложении определены два языка: [[yii\base\Application::$sourceLanguage|исходный язык]] н [[yii\base\ +В Yii приложении определены два языка: [[yii\base\Application::$sourceLanguage|исходный язык]] и [[yii\base\ Application::$language|язык перевода]]. На "исходном языке" написаны сообщения в коде приложения. Если мы определяем исходным языком английский, то From fc74fd63169c561958494e5eaf61150fb74ea67e Mon Sep 17 00:00:00 2001 From: Linux2000 Date: Thu, 16 Jul 2015 12:21:07 +0300 Subject: [PATCH 05/23] Update structure-views.md Correction of typographical errors in the text --- docs/guide-ru/structure-views.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide-ru/structure-views.md b/docs/guide-ru/structure-views.md index ce4b2c3744..0593155d43 100644 --- a/docs/guide-ru/structure-views.md +++ b/docs/guide-ru/structure-views.md @@ -294,7 +294,7 @@ use yii\helpers\Html; Как видите, шаблон генерирует HTML тэги, которые присутствуют на всех страницах. Внутри секции ``, шаблон выводит переменную `$content`, которая содержит результат рендеринга видов контента, который передается в шаблон, при работе метода [[yii\base\Controller::render()]]. -Большинство шаблонов вызывают методы, аналогично тому, как это сделано в примере выше, чтобы скрипты и тэги, зарегистированные в других местах приложения могли быть правильно отображены в местах вызова (например, в шаблоне). +Большинство шаблонов вызывают методы, аналогично тому, как это сделано в примере выше, чтобы скрипты и тэги, зарегистрированные в других местах приложения могли быть правильно отображены в местах вызова (например, в шаблоне). - [[yii\base\View::beginPage()|beginPage()]]: Этот метод нужно вызывать в самом начале шаблона. Он вызывает событие [[yii\base\View::EVENT_BEGIN_PAGE|EVENT_BEGIN_PAGE]], которое происходит при начале обработки страницы. @@ -516,7 +516,7 @@ $this->registerMetaTag(['name' => 'keywords', 'content' => 'yii, framework, php' ``` -Обратите внимание, что при вызове метода [[yii\web\View::registerMetaTag()]] несколько раз мета тэги будут регистироваться +Обратите внимание, что при вызове метода [[yii\web\View::registerMetaTag()]] несколько раз мета тэги будут регистрироваться каждый раз без проверки на уникальность. Чтобы убедиться, что зарегистрирован только один экземпляр одного типа мета тэгов, вы можете указать ключ мета тэга в качестве второго From d568236858bffe5ea47fe8b594fa724b04093451 Mon Sep 17 00:00:00 2001 From: Linux2000 Date: Thu, 16 Jul 2015 12:31:29 +0300 Subject: [PATCH 06/23] Update structure-models.md Correction of typographical errors in the text --- docs/guide-ru/structure-models.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide-ru/structure-models.md b/docs/guide-ru/structure-models.md index 8ff036597a..632d92fe3c 100644 --- a/docs/guide-ru/structure-models.md +++ b/docs/guide-ru/structure-models.md @@ -244,7 +244,7 @@ public function rules() Если не указать свойство `on`, то правило применяется во всех сценариях. Правило называется *активным правилом* если оно может быть применено в текущем сценарии [[yii\base\Model::scenario|scenario]]. Атрибут будет проверяться тогда и только тогда если он является активным атрибутом объявленным в `scenarios()` и -связаным с одним или несколькими активными правилами, объявленными в `rules()`. +связанным с одним или несколькими активными правилами, объявленными в `rules()`. ## Массовое Присвоение From 5af6105ea77d1647dffa468bc5998d97a2844a8e Mon Sep 17 00:00:00 2001 From: Sitawit Suteepohnwiroj Date: Thu, 16 Jul 2015 15:53:35 +0700 Subject: [PATCH 07/23] Fixes #9127, Fixes #9128: Fixed MSSQL `QueryBuilder::renameColumn()` and `QueryBuilder::renameTable()` escaping --- framework/CHANGELOG.md | 1 + framework/db/mssql/QueryBuilder.php | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 0fad24230f..7c5560c269 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -24,6 +24,7 @@ Yii Framework 2 Change Log - Bug #8772: ActiveQuery failed removing duplicate records after join when the resultset did not contain the pk values e.g. after grouping (cebe) - Bug #8900: Fixed determine active menu item with url-alias in route `\yii\widgets\Menu::isItemActive()` (demi) - Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe) +- Bug #9127, #9128: Fixed MSSQL `QueryBuilder::renameColumn()` and `QueryBuilder::renameTable()` escaping (sitawit) - Bug: Fixed string comparison in `BaseActiveRecord::unlink()` which may result in wrong comparison result for hash valued primary keys starting with `0e` (cebe) - Bug: Pass correct action name to `yii\console\Controller::options()` when default action was requested (cebe) - Bug: Automatic garbage collection in `yii\caching\FileCache` was not triggered (kidol) diff --git a/framework/db/mssql/QueryBuilder.php b/framework/db/mssql/QueryBuilder.php index f3df81879f..f26a9544de 100644 --- a/framework/db/mssql/QueryBuilder.php +++ b/framework/db/mssql/QueryBuilder.php @@ -119,25 +119,28 @@ class QueryBuilder extends \yii\db\QueryBuilder /** * Builds a SQL statement for renaming a DB table. - * @param string $table the table to be renamed. The name will be properly quoted by the method. + * @param string $oldName the table to be renamed. The name will be properly quoted by the method. * @param string $newName the new table name. The name will be properly quoted by the method. * @return string the SQL statement for renaming a DB table. */ - public function renameTable($table, $newName) + public function renameTable($oldName, $newName) { - return "sp_rename '$table', '$newName'"; + return 'sp_rename ' . $this->db->quoteTableName($oldName) . ', ' . $this->db->quoteTableName($newName); } /** * Builds a SQL statement for renaming a column. * @param string $table the table whose column is to be renamed. The name will be properly quoted by the method. - * @param string $name the old name of the column. The name will be properly quoted by the method. + * @param string $oldName the old name of the column. The name will be properly quoted by the method. * @param string $newName the new name of the column. The name will be properly quoted by the method. * @return string the SQL statement for renaming a DB column. */ - public function renameColumn($table, $name, $newName) + public function renameColumn($table, $oldName, $newName) { - return "sp_rename '$table.$name', '$newName', 'COLUMN'"; + $table = $this->db->quoteTableName($table); + $oldName = $this->db->quoteColumnName($oldName); + $newName = $this->db->quoteColumnName($newName); + return "sp_rename '{$table}.{$oldName}', {$newName}, 'COLUMN'"; } /** From 00cfa02af088b9de86c25915f8ea5469f36da51b Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 16 Jul 2015 19:14:31 +0300 Subject: [PATCH 08/23] Fixes #9107: Fixed incorrect note about view files translation --- docs/guide/tutorial-i18n.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/guide/tutorial-i18n.md b/docs/guide/tutorial-i18n.md index 9d099c63fa..9855a5c76e 100644 --- a/docs/guide/tutorial-i18n.md +++ b/docs/guide/tutorial-i18n.md @@ -575,9 +575,8 @@ language is `ru-RU`, you may translate the view and save it as the file `views/ whenever you call [[yii\base\View::renderFile()]] or any method that invoke this method (e.g. [[yii\base\Controller::render()]]) to render the view `views/site/index.php`, it will end up rendering the translated view `views/site/ru-RU/index.php`, instead. -> Note: If the [[yii\base\Application::$language|target language]] is the same as [[yii\base\Application::$sourceLanguage|source language]], -> view translation may still work as long as you provide a translated view. For example, if both languages are `en-US` -> and you have both `views/site/index.php` and `views/site/en-US/index.php`, then the latter will be rendered. +> Note: If the [[yii\base\Application::$language|target language]] is the same as [[yii\base\Application::$sourceLanguage|source language]] +> original view will be rendered regardless of presence of translated view. ## Formatting Date and Number Values From 140a81af05493d37de69f29db9244ab716482047 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 16 Jul 2015 19:17:59 +0300 Subject: [PATCH 09/23] Fixes #9111: translated untranslated piece in Russian version of output-data-widgets --- docs/guide-ru/output-data-widgets.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/guide-ru/output-data-widgets.md b/docs/guide-ru/output-data-widgets.md index bf7a6bd857..eba07b570a 100644 --- a/docs/guide-ru/output-data-widgets.md +++ b/docs/guide-ru/output-data-widgets.md @@ -459,10 +459,9 @@ $query->andFilterWhere(['LIKE', 'author.name', $this->getAttribute('author.name' ``` > Информация: В коде, что выше, использует такая же строка, как и имя зависимости и псевдонима таблицы. -> however, when your alias and relation name -> differ, you have to pay attention to where you use the alias and where you use the relation name. -> A simple rule for this is to use the alias in every place that is used to build the database query and the -> relation name in all other definitions such as `attributes()` and `rules()` etc. +> Однако, когда ваш псевдоним и имя связи различаются, вы должны обратить внимание, где вы используете псевдоним, +> а где имя связи. Простым правилом для этого является использование псевдонима в каждом месте, которое используется +> для построения запроса к базе данных, и имя связи во всех других определениях, таких как `attributes()`, `rules()` и т.д. > > Например, если вы используете псевдоним `au` для связи с таблицей автора, то joinWith будет выглядеть так: > From 12a5b3510b8782b3255eaec5fdb155e98c60c086 Mon Sep 17 00:00:00 2001 From: Abdullah Almesbahi Date: Thu, 16 Jul 2015 22:19:41 +0300 Subject: [PATCH 10/23] Update yii.php Urgent Fix for arabic language , This will stop yii2 from working if arabic language is chosen. --- framework/messages/ar/yii.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/messages/ar/yii.php b/framework/messages/ar/yii.php index 1602470323..57fb28507d 100644 --- a/framework/messages/ar/yii.php +++ b/framework/messages/ar/yii.php @@ -98,5 +98,5 @@ return [ '{nFormatted} {n, plural, =1{pebibyte} other{pebibytes}}' => '{nFormatted} بيبيبايت', '{nFormatted} {n, plural, =1{petabyte} other{petabytes}}' => '{nFormatted} بيتابايت', '{nFormatted} {n, plural, =1{tebibyte} other{tebibytes}}' => '{nFormatted} تيبيبايت', - '{nFormatted} {n, plural, =1{terabyte} other{terabytes}}' => '{nFormatted} تيرابايت',‎ + '{nFormatted} {n, plural, =1{terabyte} other{terabytes}}' => '{nFormatted} تيرابايت', ]; From c7b6d0bbf84779caeb5e1b99346371eeb64fbc3d Mon Sep 17 00:00:00 2001 From: den007 Date: Fri, 17 Jul 2015 02:25:22 +0300 Subject: [PATCH 11/23] Insignificant correction in translation --- docs/guide-ru/output-data-widgets.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide-ru/output-data-widgets.md b/docs/guide-ru/output-data-widgets.md index eba07b570a..a9d86971c2 100644 --- a/docs/guide-ru/output-data-widgets.md +++ b/docs/guide-ru/output-data-widgets.md @@ -3,7 +3,7 @@ Yii предоставляет набор [виджетов](structure-widgets.md), которые могут быть использованы для отображения данных. В то время как виджет [DetailView](#detail-view) может быть использован для отображения данных по одной записи, то -виджеты [ListView](#list-view) и [GridView](#grid-view) могут быть использованы для показа данных в виде списка иил +виджеты [ListView](#list-view) и [GridView](#grid-view) могут быть использованы для показа данных в виде списка или таблицы с возможностью сортировки, фильтрации и разбивки данных постранично. @@ -40,7 +40,7 @@ echo DetailView::widget([ ListView -------- -Виджет [[yii\widgets\ListView|ListView]] использует для отображения информации [провайдер данных](output-data-providers.md). +Виджет [[yii\widgets\ListView|ListView]] использует для отображения информации [провайдера данных](output-data-providers.md). Каждая модель отображается, используя определённый [[yii\widgets\ListView::$itemView|вид]]. Поскольку провайдер включает в себя разбивку на страницы, сортировку и фильтрацию, то его использование удобно для отображения информации конечному пользователю и создания интерфейса управления данными. From fed6f3562763e51182d5f0dba43b77d141cbf1c2 Mon Sep 17 00:00:00 2001 From: matthewyang Date: Fri, 17 Jul 2015 12:23:27 +0800 Subject: [PATCH 12/23] remove redefined parent property --- framework/console/Application.php | 5 ----- framework/web/Application.php | 5 ----- 2 files changed, 10 deletions(-) diff --git a/framework/console/Application.php b/framework/console/Application.php index 19b41665ab..9376ce5795 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -64,11 +64,6 @@ class Application extends \yii\base\Application * Defaults to true. */ public $enableCoreCommands = true; - /** - * @var Controller the currently active controller instance - */ - public $controller; - /** * @inheritdoc diff --git a/framework/web/Application.php b/framework/web/Application.php index c02e30d9e0..ebb4ec4925 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -45,11 +45,6 @@ class Application extends \yii\base\Application * Defaults to null, meaning catch-all is not used. */ public $catchAll; - /** - * @var Controller the currently active controller instance - */ - public $controller; - /** * @inheritdoc From c115c677e66fa3f902495c1dff47f4aff4b8064b Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 17 Jul 2015 14:27:09 +0300 Subject: [PATCH 13/23] Fixed #9141: Fixed docs for migrate/history --- framework/console/controllers/BaseMigrateController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 48b4172d63..9ff9f9c302 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -367,7 +367,7 @@ abstract class BaseMigrateController extends Controller * ~~~ * * @param integer $limit the maximum number of migrations to be displayed. - * If it is 0, the whole migration history will be displayed. + * If it is "all", the whole migration history will be displayed. * @throws \yii\console\Exception if invalid limit value passed */ public function actionHistory($limit = 10) From ef27d820d268b91d1d122abb3287d82651a54fee Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 17 Jul 2015 15:42:29 +0300 Subject: [PATCH 14/23] #9140: better fix for IDEs --- framework/console/Application.php | 2 ++ framework/web/Application.php | 1 + 2 files changed, 3 insertions(+) diff --git a/framework/console/Application.php b/framework/console/Application.php index b0e78c832e..a52927647d 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -50,6 +50,8 @@ defined('STDERR') or define('STDERR', fopen('php://stderr', 'w')); * yii help * ~~~ * + * @property Controller $controller + * * @author Qiang Xue * @since 2.0 */ diff --git a/framework/web/Application.php b/framework/web/Application.php index ebb4ec4925..63fa65aa15 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -16,6 +16,7 @@ use yii\base\InvalidRouteException; * @property string $homeUrl The homepage URL. * @property Session $session The session component. This property is read-only. * @property User $user The user component. This property is read-only. + * @property Controller $controller * * @author Qiang Xue * @since 2.0 From e279c13d6f7d93dbb1392ee3fb5843c80f51b642 Mon Sep 17 00:00:00 2001 From: Chris Harris Date: Fri, 17 Jul 2015 16:48:48 -0700 Subject: [PATCH 15/23] Variable was being enclosed in an array in comparison example --- docs/guide/concept-di-container.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guide/concept-di-container.md b/docs/guide/concept-di-container.md index 804ca4406a..f41c1d91c1 100644 --- a/docs/guide/concept-di-container.md +++ b/docs/guide/concept-di-container.md @@ -208,7 +208,7 @@ For example, $db = $container->get('db'); // equivalent to: $engine = new \app\components\SearchEngine($apiKey, ['type' => 1]); -$engine = $container->get('app\components\SearchEngine', [$apiKey], ['type' => 1]); +$engine = $container->get('app\components\SearchEngine', $apiKey, ['type' => 1]); ``` Behind the scene, the DI container does much more work than just creating a new object. From 77c1fcf7c4c753398658b4cfea68d269aab66932 Mon Sep 17 00:00:00 2001 From: Paul Klimov Date: Sat, 18 Jul 2015 14:39:25 +0300 Subject: [PATCH 16/23] DI object creation with constructor arguments example fixed --- docs/guide/concept-di-container.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/guide/concept-di-container.md b/docs/guide/concept-di-container.md index f41c1d91c1..95a309eaf6 100644 --- a/docs/guide/concept-di-container.md +++ b/docs/guide/concept-di-container.md @@ -207,8 +207,8 @@ For example, // "db" is a previously registered alias name $db = $container->get('db'); -// equivalent to: $engine = new \app\components\SearchEngine($apiKey, ['type' => 1]); -$engine = $container->get('app\components\SearchEngine', $apiKey, ['type' => 1]); +// equivalent to: $engine = new \app\components\SearchEngine($apiKey, $apiSecret, ['type' => 1]); +$engine = $container->get('app\components\SearchEngine', [$apiKey, $apiSecret], ['type' => 1]); ``` Behind the scene, the DI container does much more work than just creating a new object. From b53f50a762e20e0efdecf641ab268149040e5042 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sat, 18 Jul 2015 22:08:33 +0300 Subject: [PATCH 17/23] Reverted #9140 See discussion at https://github.com/yiisoft/yii2/commit/ef27d820d268b91d1d122abb3287d82651a54fee --- framework/console/Application.php | 6 ++++-- framework/web/Application.php | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/framework/console/Application.php b/framework/console/Application.php index a52927647d..d8d6e1ff65 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -50,8 +50,6 @@ defined('STDERR') or define('STDERR', fopen('php://stderr', 'w')); * yii help * ~~~ * - * @property Controller $controller - * * @author Qiang Xue * @since 2.0 */ @@ -72,6 +70,10 @@ class Application extends \yii\base\Application * Defaults to true. */ public $enableCoreCommands = true; + /** + * @var Controller the currently active controller instance + */ + public $controller; /** * @inheritdoc diff --git a/framework/web/Application.php b/framework/web/Application.php index 63fa65aa15..8f88562175 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -16,7 +16,6 @@ use yii\base\InvalidRouteException; * @property string $homeUrl The homepage URL. * @property Session $session The session component. This property is read-only. * @property User $user The user component. This property is read-only. - * @property Controller $controller * * @author Qiang Xue * @since 2.0 @@ -46,6 +45,10 @@ class Application extends \yii\base\Application * Defaults to null, meaning catch-all is not used. */ public $catchAll; + /** + * @var Controller the currently active controller instance + */ + public $controller; /** * @inheritdoc From 21e55a554d7a5a4b820491f1f0d7b9ca0f2650b4 Mon Sep 17 00:00:00 2001 From: Oleg Belostotskiy Date: Sun, 19 Jul 2015 04:38:55 +0300 Subject: [PATCH 18/23] Fixing a typo --- framework/caching/FileDependency.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/caching/FileDependency.php b/framework/caching/FileDependency.php index 743aa85cfb..dc77464668 100644 --- a/framework/caching/FileDependency.php +++ b/framework/caching/FileDependency.php @@ -13,7 +13,7 @@ use yii\base\InvalidConfigException; /** * FileDependency represents a dependency based on a file's last modification time. * - * If th last modification time of the file specified via [[fileName]] is changed, + * If the last modification time of the file specified via [[fileName]] is changed, * the dependency is considered as changed. * * @author Qiang Xue From 9ab57780ab3a5e6005979e8864a8e44c5c6bf823 Mon Sep 17 00:00:00 2001 From: Alexander Pletnev Date: Sun, 19 Jul 2015 18:27:24 +0300 Subject: [PATCH 19/23] close #9149 --- framework/console/controllers/BaseMigrateController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 9ff9f9c302..9492591226 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -68,7 +68,7 @@ abstract class BaseMigrateController extends Controller $path = Yii::getAlias($this->migrationPath); if (!is_dir($path)) { if ($action->id !== 'create') { - throw new Exception('Migration failed. Directory specified in migrationPath doesn\'t exist.'); + throw new Exception("Migration failed. Directory specified in migrationPath doesn\'t exist: {$this->migrationPath}"); } FileHelper::createDirectory($path); } From 91eae2fe4502579090c9a66b1e4ac1944bb8a89d Mon Sep 17 00:00:00 2001 From: Alexander Pletnev Date: Sun, 19 Jul 2015 18:34:41 +0300 Subject: [PATCH 20/23] changelog --- framework/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index b13d351200..292fcd7f81 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -45,6 +45,7 @@ Yii Framework 2 Change Log - Enh #8903: PostgreSQL `QueryBuilder::createIndex()` can now specify the index method to use (LAV45) - Enh #9011: Allow `yii\widgets\MaskedInput` to produce an input tag of a custom type (TriAnMan) - Enh #9038: Write warning to log in case `FileCache` fails to write into file (foccy) +- Enh #9149: Print directory migrationPath in a `yii migrate` command error. (RusAlex) - Chg #6354: `ErrorHandler::logException()` will now log the whole exception object instead of only its string representation (cebe) - Chg #8556: Extracted `yii\web\User::getAuthManager()` method (samdark) From 9aac3966a6fecf2ded23e80526183a660b11770b Mon Sep 17 00:00:00 2001 From: Carsten Brandt Date: Sun, 19 Jul 2015 17:42:41 +0200 Subject: [PATCH 21/23] fixed typo in error message #9154 --- framework/console/controllers/BaseMigrateController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/console/controllers/BaseMigrateController.php b/framework/console/controllers/BaseMigrateController.php index 9492591226..94352c3399 100644 --- a/framework/console/controllers/BaseMigrateController.php +++ b/framework/console/controllers/BaseMigrateController.php @@ -68,7 +68,7 @@ abstract class BaseMigrateController extends Controller $path = Yii::getAlias($this->migrationPath); if (!is_dir($path)) { if ($action->id !== 'create') { - throw new Exception("Migration failed. Directory specified in migrationPath doesn\'t exist: {$this->migrationPath}"); + throw new Exception("Migration failed. Directory specified in migrationPath doesn't exist: {$this->migrationPath}"); } FileHelper::createDirectory($path); } From c9fb60bc18561a043f8aec0cb4b00e75974732c5 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 21 Jul 2015 00:55:33 +0300 Subject: [PATCH 22/23] Fixes #7671: more novice-friendly way of initializing Gii and Debug extensions --- docs/guide/start-gii.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/guide/start-gii.md b/docs/guide/start-gii.md index f209722891..ea50a9f3c9 100644 --- a/docs/guide/start-gii.md +++ b/docs/guide/start-gii.md @@ -23,7 +23,9 @@ $config = [ ... ]; if (YII_ENV_DEV) { $config['bootstrap'][] = 'gii'; - $config['modules']['gii'] = 'yii\gii\Module'; + $config['modules']['gii'] = [ + 'class' => 'yii\gii\Module', + ]; } ``` From df6f270a0e691253318b787c23d5332b7dc28389 Mon Sep 17 00:00:00 2001 From: zetamen Date: Mon, 20 Jul 2015 22:33:08 +0300 Subject: [PATCH 23/23] Fixes #9161: Fixed `yii\web\Request` ignore `queryParams` when resolve request --- framework/CHANGELOG.md | 1 + framework/web/Request.php | 9 +++-- tests/framework/web/RequestTest.php | 56 +++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 3 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 292fcd7f81..7c1ee440ca 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -26,6 +26,7 @@ Yii Framework 2 Change Log - Bug #9046: Fixed problem with endless error loop when an error occurred after sending a stream or file download response to the user (cebe) - Bug #9063: Workaround for MySQL losing table case when adding index (sebathi) - Bug #9127, #9128: Fixed MSSQL `QueryBuilder::renameColumn()` and `QueryBuilder::renameTable()` escaping (sitawit) +- Bug #9161: Fixed `yii\web\Request` ignore `queryParams` when resolve request (zetamen) - Bug: Fixed string comparison in `BaseActiveRecord::unlink()` which may result in wrong comparison result for hash valued primary keys starting with `0e` (cebe) - Bug: Pass correct action name to `yii\console\Controller::options()` when default action was requested (cebe) - Bug: Automatic garbage collection in `yii\caching\FileCache` was not triggered (kidol) diff --git a/framework/web/Request.php b/framework/web/Request.php index 9b7ddfdb70..4dc5118135 100644 --- a/framework/web/Request.php +++ b/framework/web/Request.php @@ -180,9 +180,12 @@ class Request extends \yii\base\Request $result = Yii::$app->getUrlManager()->parseRequest($this); if ($result !== false) { list ($route, $params) = $result; - $_GET = $params + $_GET; // preserve numeric keys - - return [$route, $_GET]; + if ($this->_queryParams === null) { + $_GET = $params + $_GET; // preserve numeric keys + } else { + $this->_queryParams = $params + $this->_queryParams; + } + return [$route, $this->getQueryParams()]; } else { throw new NotFoundHttpException(Yii::t('yii', 'Page not found.')); } diff --git a/tests/framework/web/RequestTest.php b/tests/framework/web/RequestTest.php index b65b98fd53..aa45e137ce 100644 --- a/tests/framework/web/RequestTest.php +++ b/tests/framework/web/RequestTest.php @@ -90,4 +90,60 @@ class RequestTest extends TestCase $this->assertTrue($request->validateCsrfToken($token)); } + + public function testResolve() + { + $this->mockWebApplication([ + 'components' => [ + 'urlManager' => [ + 'enablePrettyUrl' => true, + 'showScriptName' => false, + 'cache' => null, + 'rules' => [ + 'posts' => 'post/list', + 'post/' => 'post/view', + ], + ] + ] + ]); + + $request = new Request(); + $request->pathInfo = 'posts'; + + $_GET['page'] = 1; + $result = $request->resolve(); + $this->assertEquals(['post/list', ['page' => 1]], $result); + $this->assertEquals($_GET, ['page' => 1]); + + $request->setQueryParams(['page' => 5]); + $result = $request->resolve(); + $this->assertEquals(['post/list', ['page' => 5]], $result); + $this->assertEquals($_GET, ['page' => 1]); + + $request->setQueryParams(['custom-page' => 5]); + $result = $request->resolve(); + $this->assertEquals(['post/list', ['custom-page' => 5]], $result); + $this->assertEquals($_GET, ['page' => 1]); + + unset($_GET['page']); + + $request = new Request(); + $request->pathInfo = 'post/21'; + + $this->assertEquals($_GET, []); + $result = $request->resolve(); + $this->assertEquals(['post/view', ['id' => 21]], $result); + $this->assertEquals($_GET, ['id' => 21]); + + $_GET['id'] = 42; + $result = $request->resolve(); + $this->assertEquals(['post/view', ['id' => 21]], $result); + $this->assertEquals($_GET, ['id' => 21]); + + $_GET['id'] = 63; + $request->setQueryParams(['token' => 'secret']); + $result = $request->resolve(); + $this->assertEquals(['post/view', ['id' => 21, 'token' => 'secret']], $result); + $this->assertEquals($_GET, ['id' => 63]); + } }