mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-18 23:43:19 +08:00
Merge commit '51b5e1d368c785e62a1d01a6501ff3fefe032814' into 9063-workaround-on-mysql-create-index-bug
Conflicts: framework/CHANGELOG.md
This commit is contained in:
@@ -139,6 +139,33 @@ to `Schema::TYPE_STRING` to specify that the column cannot be null.
|
|||||||
|
|
||||||
> Info: The mapping between abstract types and physical types is specified by
|
> Info: The mapping between abstract types and physical types is specified by
|
||||||
the [[yii\db\QueryBuilder::$typeMap|$typeMap]] property in each concrete `QueryBuilder` class.
|
the [[yii\db\QueryBuilder::$typeMap|$typeMap]] property in each concrete `QueryBuilder` class.
|
||||||
|
|
||||||
|
Since 2.0.5 schema builder which provides more convenient way defining column schema was introduced so migration above
|
||||||
|
could be written like the following:
|
||||||
|
|
||||||
|
```php
|
||||||
|
|
||||||
|
use yii\db\Schema;
|
||||||
|
use yii\db\Migration;
|
||||||
|
|
||||||
|
class m150101_185401_create_news_table extends \yii\db\Migration
|
||||||
|
{
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
$this->createTable('news', [
|
||||||
|
'id' => Schema::primaryKey(),
|
||||||
|
'title' => Schema::string()->notNull(),
|
||||||
|
'content' => Schema::text(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
$this->dropTable('news');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Transactional Migrations <span id="transactional-migrations"></span>
|
### Transactional Migrations <span id="transactional-migrations"></span>
|
||||||
@@ -163,9 +190,9 @@ class m150101_185401_create_news_table extends Migration
|
|||||||
public function safeUp()
|
public function safeUp()
|
||||||
{
|
{
|
||||||
$this->createTable('news', [
|
$this->createTable('news', [
|
||||||
'id' => 'pk',
|
'id' => Schema::primaryKey(),,
|
||||||
'title' => Schema::TYPE_STRING . ' NOT NULL',
|
'title' => Schema::string()->notNull(),
|
||||||
'content' => Schema::TYPE_TEXT,
|
'content' => Schema::text(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->insert('news', [
|
$this->insert('news', [
|
||||||
|
|||||||
@@ -141,10 +141,10 @@ takes the default value `app\controllers`:
|
|||||||
|
|
||||||
Controller classes must be [autoloadable](concept-autoloading.md). For this reason, in the above examples,
|
Controller classes must be [autoloadable](concept-autoloading.md). For this reason, in the above examples,
|
||||||
the `article` controller class should be saved in the file whose [alias](concept-aliases.md)
|
the `article` controller class should be saved in the file whose [alias](concept-aliases.md)
|
||||||
is `@app/controllers/ArticleController.php`; while the `admin/post2-comment` controller should be
|
is `@app/controllers/ArticleController.php`; while the `admin/post-comment` controller should be
|
||||||
in `@app/controllers/admin/Post2CommentController.php`.
|
in `@app/controllers/admin/PostCommentController.php`.
|
||||||
|
|
||||||
> Info: The last example `admin/post2-comment` shows how you can put a controller under a sub-directory
|
> Info: The last example `admin/post-comment` shows how you can put a controller under a sub-directory
|
||||||
of the [[yii\base\Application::controllerNamespace|controller namespace]]. This is useful when you want
|
of the [[yii\base\Application::controllerNamespace|controller namespace]]. This is useful when you want
|
||||||
to organize your controllers into several categories and you do not want to use [modules](structure-modules.md).
|
to organize your controllers into several categories and you do not want to use [modules](structure-modules.md).
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #8592: Fixed `yii\db\Command::getRawSql()` unable to parse params specified without colon (':') (klimov-paul)
|
- Bug #8592: Fixed `yii\db\Command::getRawSql()` unable to parse params specified without colon (':') (klimov-paul)
|
||||||
- Bug #8593: Fixed `yii\db\ActiveQuery` produces incorrect SQL for aggregations, when `sql` field is set (klimov-paul)
|
- Bug #8593: Fixed `yii\db\ActiveQuery` produces incorrect SQL for aggregations, when `sql` field is set (klimov-paul)
|
||||||
- Bug #8595: Fixed `yii\rbac\DbManager::checkAccessFromCache()` to check against auth items loaded in cache recursively (achretien, qiangxue)
|
- Bug #8595: Fixed `yii\rbac\DbManager::checkAccessFromCache()` to check against auth items loaded in cache recursively (achretien, qiangxue)
|
||||||
|
- Bug #8549: Fixed `yii\caching\FileCache` doesn't lock cache files when reading (iworker)
|
||||||
- Bug #8606: Fixed `yii\web\Response::xSendFile()` does not reset format (vyants)
|
- Bug #8606: Fixed `yii\web\Response::xSendFile()` does not reset format (vyants)
|
||||||
- Bug #8627: Fixed `yii\db\Migration` produces incorrect results due to table schema caching (klimov-paul)
|
- Bug #8627: Fixed `yii\db\Migration` produces incorrect results due to table schema caching (klimov-paul)
|
||||||
- Bug #8661: Fixed `yii.activeForm.js` scrolling to top (nkovacs)
|
- Bug #8661: Fixed `yii.activeForm.js` scrolling to top (nkovacs)
|
||||||
@@ -24,6 +25,7 @@ Yii Framework 2 Change Log
|
|||||||
- Bug #8900: Fixed determine active menu item with url-alias in route `\yii\widgets\Menu::isItemActive()` (demi)
|
- 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 #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 #9070: Fixed `ViewAction::resolveViewName()` not to accept `/../` and `/./` (thejahweh, samdark)
|
||||||
- Bug: Fixed string comparison in `BaseActiveRecord::unlink()` which may result in wrong comparison result for hash valued primary keys starting with `0e` (cebe)
|
- 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: 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)
|
- Bug: Automatic garbage collection in `yii\caching\FileCache` was not triggered (kidol)
|
||||||
@@ -45,7 +47,6 @@ Yii Framework 2 Change Log
|
|||||||
- Chg #6354: `ErrorHandler::logException()` will now log the whole exception object instead of only its string representation (cebe)
|
- 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)
|
- Chg #8556: Extracted `yii\web\User::getAuthManager()` method (samdark)
|
||||||
|
|
||||||
|
|
||||||
2.0.4 May 10, 2015
|
2.0.4 May 10, 2015
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
|
|||||||
@@ -107,11 +107,19 @@ class FileCache extends Cache
|
|||||||
protected function getValue($key)
|
protected function getValue($key)
|
||||||
{
|
{
|
||||||
$cacheFile = $this->getCacheFile($key);
|
$cacheFile = $this->getCacheFile($key);
|
||||||
|
|
||||||
if (@filemtime($cacheFile) > time()) {
|
if (@filemtime($cacheFile) > time()) {
|
||||||
return @file_get_contents($cacheFile);
|
$fp = @fopen($cacheFile, 'r');
|
||||||
} else {
|
if ($fp !== false) {
|
||||||
return false;
|
@flock($fp, LOCK_SH);
|
||||||
|
$cacheValue = @file_get_contents($cacheFile);
|
||||||
|
@flock($fp, LOCK_UN);
|
||||||
|
@fclose($fp);
|
||||||
|
return $cacheValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ namespace yii\log;
|
|||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Component;
|
use yii\base\Component;
|
||||||
use yii\base\ErrorHandler;
|
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\helpers\VarDumper;
|
use yii\helpers\VarDumper;
|
||||||
use yii\web\Request;
|
use yii\web\Request;
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ return [
|
|||||||
'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.' => 'Totaal <b>{count, number}</b> {count, plural, one{item} other{items}}.',
|
'Total <b>{count, number}</b> {count, plural, one{item} other{items}}.' => 'Totaal <b>{count, number}</b> {count, plural, one{item} other{items}}.',
|
||||||
'Unable to verify your data submission.' => 'Het is niet mogelijk uw verstrekte gegevens te verifiëren.',
|
'Unable to verify your data submission.' => 'Het is niet mogelijk uw verstrekte gegevens te verifiëren.',
|
||||||
'Unknown option: --{name}' => 'Onbekende optie: --{name}',
|
'Unknown option: --{name}' => 'Onbekende optie: --{name}',
|
||||||
'Update' => 'Update',
|
'Update' => 'Bewerk',
|
||||||
'View' => 'Bekijk',
|
'View' => 'Bekijk',
|
||||||
'Yes' => 'Ja',
|
'Yes' => 'Ja',
|
||||||
'You are not allowed to perform this action.' => 'U bent niet gemachtigd om deze actie uit te voeren.',
|
'You are not allowed to perform this action.' => 'U bent niet gemachtigd om deze actie uit te voeren.',
|
||||||
|
|||||||
@@ -42,38 +42,38 @@ class m140506_102106_rbac_init extends \yii\db\Migration
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->createTable($authManager->ruleTable, [
|
$this->createTable($authManager->ruleTable, [
|
||||||
'name' => Schema::TYPE_STRING . '(64) NOT NULL',
|
'name' => Schema::string(64)->notNull(),
|
||||||
'data' => Schema::TYPE_TEXT,
|
'data' => Schema::text(),
|
||||||
'created_at' => Schema::TYPE_INTEGER,
|
'created_at' => Schema::integer(),
|
||||||
'updated_at' => Schema::TYPE_INTEGER,
|
'updated_at' => Schema::integer(),
|
||||||
'PRIMARY KEY (name)',
|
'PRIMARY KEY (name)',
|
||||||
], $tableOptions);
|
], $tableOptions);
|
||||||
|
|
||||||
$this->createTable($authManager->itemTable, [
|
$this->createTable($authManager->itemTable, [
|
||||||
'name' => Schema::TYPE_STRING . '(64) NOT NULL',
|
'name' => Schema::string(64)->notNull(),
|
||||||
'type' => Schema::TYPE_INTEGER . ' NOT NULL',
|
'type' => Schema::integer()->notNull(),
|
||||||
'description' => Schema::TYPE_TEXT,
|
'description' => Schema::text(),
|
||||||
'rule_name' => Schema::TYPE_STRING . '(64)',
|
'rule_name' => Schema::string(64),
|
||||||
'data' => Schema::TYPE_TEXT,
|
'data' => Schema::text(),
|
||||||
'created_at' => Schema::TYPE_INTEGER,
|
'created_at' => Schema::integer(),
|
||||||
'updated_at' => Schema::TYPE_INTEGER,
|
'updated_at' => Schema::integer(),
|
||||||
'PRIMARY KEY (name)',
|
'PRIMARY KEY (name)',
|
||||||
'FOREIGN KEY (rule_name) REFERENCES ' . $authManager->ruleTable . ' (name) ON DELETE SET NULL ON UPDATE CASCADE',
|
'FOREIGN KEY (rule_name) REFERENCES ' . $authManager->ruleTable . ' (name) ON DELETE SET NULL ON UPDATE CASCADE',
|
||||||
], $tableOptions);
|
], $tableOptions);
|
||||||
$this->createIndex('idx-auth_item-type', $authManager->itemTable, 'type');
|
$this->createIndex('idx-auth_item-type', $authManager->itemTable, 'type');
|
||||||
|
|
||||||
$this->createTable($authManager->itemChildTable, [
|
$this->createTable($authManager->itemChildTable, [
|
||||||
'parent' => Schema::TYPE_STRING . '(64) NOT NULL',
|
'parent' => Schema::string(64)->notNull(),
|
||||||
'child' => Schema::TYPE_STRING . '(64) NOT NULL',
|
'child' => Schema::string(64)->notNull(),
|
||||||
'PRIMARY KEY (parent, child)',
|
'PRIMARY KEY (parent, child)',
|
||||||
'FOREIGN KEY (parent) REFERENCES ' . $authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
|
'FOREIGN KEY (parent) REFERENCES ' . $authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||||
'FOREIGN KEY (child) REFERENCES ' . $authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
|
'FOREIGN KEY (child) REFERENCES ' . $authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||||
], $tableOptions);
|
], $tableOptions);
|
||||||
|
|
||||||
$this->createTable($authManager->assignmentTable, [
|
$this->createTable($authManager->assignmentTable, [
|
||||||
'item_name' => Schema::TYPE_STRING . '(64) NOT NULL',
|
'item_name' => Schema::string(64)->notNull(),
|
||||||
'user_id' => Schema::TYPE_STRING . '(64) NOT NULL',
|
'user_id' => Schema::string(64)->notNull(),
|
||||||
'created_at' => Schema::TYPE_INTEGER,
|
'created_at' => Schema::integer(),
|
||||||
'PRIMARY KEY (item_name, user_id)',
|
'PRIMARY KEY (item_name, user_id)',
|
||||||
'FOREIGN KEY (item_name) REFERENCES ' . $authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
|
'FOREIGN KEY (item_name) REFERENCES ' . $authManager->itemTable . ' (name) ON DELETE CASCADE ON UPDATE CASCADE',
|
||||||
], $tableOptions);
|
], $tableOptions);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ namespace yii\validators;
|
|||||||
use DateTime;
|
use DateTime;
|
||||||
use IntlDateFormatter;
|
use IntlDateFormatter;
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Exception;
|
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
use yii\helpers\FormatConverter;
|
use yii\helpers\FormatConverter;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ use yii\base\Model;
|
|||||||
* ~~~php
|
* ~~~php
|
||||||
* class MyModel extends Model
|
* class MyModel extends Model
|
||||||
* {
|
* {
|
||||||
* public $arrayAttribute = [];
|
* public $categoryIDs = [];
|
||||||
*
|
*
|
||||||
* public function rules()
|
* public function rules()
|
||||||
* {
|
* {
|
||||||
|
|||||||
@@ -655,11 +655,10 @@ class User extends Component
|
|||||||
*/
|
*/
|
||||||
public function can($permissionName, $params = [], $allowCaching = true)
|
public function can($permissionName, $params = [], $allowCaching = true)
|
||||||
{
|
{
|
||||||
$auth = $this->getAuthManager();
|
|
||||||
if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
|
if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
|
||||||
return $this->_access[$permissionName];
|
return $this->_access[$permissionName];
|
||||||
}
|
}
|
||||||
$access = $auth->checkAccess($this->getId(), $permissionName, $params);
|
$access = $this->getAuthManager()->checkAccess($this->getId(), $permissionName, $params);
|
||||||
if ($allowCaching && empty($params)) {
|
if ($allowCaching && empty($params)) {
|
||||||
$this->_access[$permissionName] = $access;
|
$this->_access[$permissionName] = $access;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,9 +119,9 @@ class ViewAction extends Action
|
|||||||
{
|
{
|
||||||
$viewName = Yii::$app->request->get($this->viewParam, $this->defaultView);
|
$viewName = Yii::$app->request->get($this->viewParam, $this->defaultView);
|
||||||
|
|
||||||
if (!is_string($viewName) || !preg_match('/^\w[\w\/\-\.]*$/', $viewName)) {
|
if (!is_string($viewName) || !preg_match('~^\w(?:(?!\/\.{0,2}\/)[\w\/\-\.])*$~', $viewName)) {
|
||||||
if (YII_DEBUG) {
|
if (YII_DEBUG) {
|
||||||
throw new NotFoundHttpException("The requested view \"$viewName\" must start with a word character and can contain only word characters, forward slashes, dots and dashes.");
|
throw new NotFoundHttpException("The requested view \"$viewName\" must start with a word character, must not contain /../ or /./, can contain only word characters, forward slashes, dots and dashes.");
|
||||||
} else {
|
} else {
|
||||||
throw new NotFoundHttpException(Yii::t('yii', 'The requested view "{name}" was not found.', ['name' => $viewName]));
|
throw new NotFoundHttpException(Yii::t('yii', 'The requested view "{name}" was not found.', ['name' => $viewName]));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user