Browse Source

Merge pull request #2 from yiisoft/master

Merge from master
tags/2.0.0-alpha
Simone 12 years ago
parent
commit
6a3e9e15ea
  1. 2
      app/protected/config/assets.php
  2. 2
      app/protected/config/main.php
  3. 2
      app/protected/controllers/SiteController.php
  4. 2
      app/protected/models/ContactForm.php
  5. 2
      app/protected/models/LoginForm.php
  6. 2
      app/protected/models/User.php
  7. 2
      app/protected/views/layouts/main.php
  8. 2
      app/protected/views/site/contact.php
  9. 2
      app/protected/views/site/login.php
  10. 316
      docs/guide/migration.md
  11. 2
      framework/assets.php
  12. 2
      framework/base/ActionFilter.php
  13. 9
      framework/base/Application.php
  14. 2
      framework/base/Exception.php
  15. 6
      framework/base/View.php
  16. 2
      framework/base/ViewEvent.php
  17. 2
      framework/base/Widget.php
  18. 2
      framework/caching/Cache.php
  19. 2
      framework/caching/Dependency.php
  20. 2
      framework/caching/MemCacheServer.php
  21. 2
      framework/caching/WinCache.php
  22. 2
      framework/console/Controller.php
  23. 2
      framework/console/controllers/AppController.php
  24. 2
      framework/console/controllers/AssetController.php
  25. 2
      framework/console/controllers/HelpController.php
  26. 2
      framework/console/webapp/config.php
  27. 2
      framework/console/webapp/default/index.php
  28. 2
      framework/console/webapp/default/protected/config/main.php
  29. 2
      framework/console/webapp/default/protected/controllers/SiteController.php
  30. 2
      framework/console/webapp/default/protected/views/layouts/main.php
  31. 2
      framework/console/webapp/default/protected/views/site/index.php
  32. 2
      framework/db/Exception.php
  33. 2
      framework/db/Expression.php
  34. 2
      framework/db/Migration.php
  35. 2
      framework/db/StaleObjectException.php
  36. 2
      framework/helpers/ArrayHelper.php
  37. 2
      framework/helpers/FileHelper.php
  38. 2
      framework/helpers/JsExpression.php
  39. 2
      framework/helpers/Json.php
  40. 2
      framework/helpers/SecurityHelper.php
  41. 2
      framework/helpers/VarDumper.php
  42. 2
      framework/helpers/base/ArrayHelper.php
  43. 2
      framework/helpers/base/FileHelper.php
  44. 2
      framework/helpers/base/Json.php
  45. 6
      framework/helpers/base/SecurityHelper.php
  46. 4
      framework/helpers/base/VarDumper.php
  47. 2
      framework/i18n/PhpMessageSource.php
  48. 2
      framework/i18n/data/plurals.php
  49. 2
      framework/logging/EmailTarget.php
  50. 2
      framework/logging/ProfileTarget.php
  51. 2
      framework/logging/Target.php
  52. 2
      framework/logging/WebTarget.php
  53. 2
      framework/renderers/SmartyViewRenderer.php
  54. 6
      framework/validators/FileValidator.php
  55. 2
      framework/validators/InlineValidator.php
  56. 2
      framework/validators/NumberValidator.php
  57. 2
      framework/validators/UniqueValidator.php
  58. 2
      framework/views/error.php
  59. 2
      framework/web/AccessControl.php
  60. 4
      framework/web/AccessRule.php
  61. 2
      framework/web/AssetBundle.php
  62. 4
      framework/web/AssetConverter.php
  63. 2
      framework/web/Controller.php
  64. 2
      framework/web/HttpCache.php
  65. 2
      framework/web/IAssetConverter.php
  66. 2
      framework/web/Identity.php
  67. 2
      framework/web/PageCache.php
  68. 2
      framework/web/Pagination.php
  69. 2
      framework/web/Sort.php
  70. 6
      framework/web/UploadedFile.php
  71. 4
      framework/web/UrlManager.php
  72. 17
      framework/web/User.php
  73. 2
      framework/web/UserEvent.php
  74. 2
      framework/widgets/ActiveField.php
  75. 2
      framework/widgets/Block.php
  76. 2
      framework/widgets/FragmentCache.php
  77. 2
      tests/unit/MysqlTestCase.php
  78. 2
      tests/unit/TestCase.php
  79. 2
      tests/unit/data/ar/ActiveRecord.php
  80. 2
      tests/unit/data/ar/Customer.php
  81. 2
      tests/unit/data/ar/Item.php
  82. 2
      tests/unit/data/ar/Order.php
  83. 2
      tests/unit/data/ar/OrderItem.php
  84. 2
      tests/unit/data/base/Singer.php
  85. 2
      tests/unit/framework/base/ComponentTest.php
  86. 2
      tests/unit/framework/base/ObjectTest.php
  87. 4
      tests/unit/framework/caching/ApcCacheTest.php
  88. 2
      tests/unit/framework/caching/DbCacheTest.php
  89. 2
      tests/unit/framework/caching/FileCacheTest.php
  90. 2
      tests/unit/framework/caching/MemCacheTest.php
  91. 2
      tests/unit/framework/caching/MemCachedTest.php
  92. 2
      tests/unit/framework/caching/WinCacheTest.php
  93. 2
      tests/unit/framework/caching/XCacheTest.php
  94. 2
      tests/unit/framework/caching/ZendDataCacheTest.php
  95. 2
      tests/unit/framework/db/ActiveRecordTest.php
  96. 2
      tests/unit/framework/db/CommandTest.php
  97. 2
      tests/unit/framework/db/QueryTest.php
  98. 2
      tests/unit/framework/helpers/JsonTest.php
  99. 2
      tests/unit/framework/helpers/StringHelperTest.php
  100. 2
      tests/unit/framework/helpers/VarDumperTest.php
  101. Some files were not shown because too many files have changed in this diff Show More

2
app/protected/config/assets.php

@ -16,4 +16,4 @@ return array(
'yii',
),
),
);
);

2
app/protected/config/main.php

@ -18,4 +18,4 @@ return array(
'params' => array(
'adminEmail' => 'admin@example.com',
),
);
);

2
app/protected/controllers/SiteController.php

@ -46,4 +46,4 @@ class SiteController extends Controller
{
echo $this->render('about');
}
}
}

2
app/protected/models/ContactForm.php

@ -60,4 +60,4 @@ class ContactForm extends Model
return false;
}
}
}
}

2
app/protected/models/LoginForm.php

@ -55,4 +55,4 @@ class LoginForm extends Model
return false;
}
}
}
}

2
app/protected/models/User.php

@ -58,4 +58,4 @@ class User extends \yii\base\Object implements \yii\web\Identity
{
return $this->password === $password;
}
}
}

2
app/protected/views/layouts/main.php

@ -54,4 +54,4 @@ $this->registerAssetBundle('app');
</div>
</body>
</html>
<?php $this->endPage(); ?>
<?php $this->endPage(); ?>

2
app/protected/views/site/contact.php

@ -30,4 +30,4 @@ $this->title = 'Contact';
<div class="form-actions">
<?php echo Html::submitButton('Submit', null, null, array('class' => 'btn btn-primary')); ?>
</div>
<?php $this->endWidget(); ?>
<?php $this->endWidget(); ?>

2
app/protected/views/site/login.php

@ -18,4 +18,4 @@ $this->title = 'Login';
<div class="form-actions">
<?php echo Html::submitButton('Login', null, null, array('class' => 'btn btn-primary')); ?>
</div>
<?php $this->endWidget(); ?>
<?php $this->endWidget(); ?>

316
docs/guide/migration.md

@ -1,3 +1,319 @@
Database Migration
==================
Like source code, the structure of a database is evolving as we develop and maintain
a database-driven application. For example, during development, we may want to
add a new table; or after the application is put into production, we may realize
the need of adding an index on a column. It is important to keep track of these
structural database changes (called **migration**) like we do with our source
code. If the source code and the database are out of sync, it is very likely
the whole system may break. For this reason, Yii provides a database migration
tool that can keep track of database migration history, apply new migrations,
or revert existing ones.
The following steps show how we can use database migration during development:
1. Tim creates a new migration (e.g. create a new table)
2. Tim commits the new migration into source control system (e.g. GIT, Mercurial)
3. Doug updates from source control system and receives the new migration
4. Doug applies the migration to his local development database
Yii supports database migration via the `yiic migrate` command line tool. This
tool supports creating new migrations, applying/reverting/redoing migrations, and
showing migration history and new migrations.
Creating Migrations
-------------------
To create a new migration (e.g. create a news table), we run the following command:
~~~
yiic migrate/create <name>
~~~
The required `name` parameter specifies a very brief description of the migration
(e.g. `create_news_table`). As we will show in the following, the `name` parameter
is used as part of a PHP class name. Therefore, it should only contain letters,
digits and/or underscore characters.
~~~
yiic migrate/create create_news_table
~~~
The above command will create under the `protected/migrations` directory a new
file named `m101129_185401_create_news_table.php` which contains the following
initial code:
~~~
[php]
class m101129_185401_create_news_table extends \yii\db\Migration
{
public function up()
{
}
public function down()
{
echo "m101129_185401_create_news_table cannot be reverted.\n";
return false;
}
}
~~~
Notice that the class name is the same as the file name which is of the pattern
`m<timestamp>_<name>`, where `<timestamp>` refers to the UTC timestamp (in the
format of `yymmdd_hhmmss`) when the migration is created, and `<name>` is taken
from the command's `name` parameter.
The `up()` method should contain the code implementing the actual database
migration, while the `down()` method may contain the code reverting what is
done in `up()`.
Sometimes, it is impossible to implement `down()`. For example, if we delete
table rows in `up()`, we will not be able to recover them in `down()`. In this
case, the migration is called irreversible, meaning we cannot roll back to
a previous state of the database. In the above generated code, the `down()`
method returns `false` to indicate that the migration cannot be reverted.
As an example, let's show the migration about creating a news table.
~~~
[php]
class m101129_185401_create_news_table extends \yii\db\Migration
{
public function up()
{
$this->db->createCommand()->createTable('tbl_news, array(
'id' => 'pk',
'title' => 'string NOT NULL',
'content' => 'text',
))->execute();
}
public function down()
{
$this->db->createCommand()->dropTable('tbl_news')->execute();
}
}
~~~
The base class [\yii\db\Migration] exposes a database connection via `db`
property. You can use it for manipulating data and schema of a database.
Transactional Migrations
------------------------
While performing complex DB migrations, we usually want to make sure that each
migration succeed or fail as a whole so that the database maintains the
consistency and integrity. In order to achieve this goal, we can exploit
DB transactions.
We could explicitly start a DB transaction and enclose the rest of the DB-related
code within the transaction, like the following:
~~~
[php]
class m101129_185401_create_news_table extends \yii\db\Migration
{
public function up()
{
$transaction=$this->getDbConnection()->beginTransaction();
try
{
$this->db->createCommand()->createTable('tbl_news, array(
'id' => 'pk',
'title' => 'string NOT NULL',
'content' => 'text',
))->execute();
$transaction->commit();
}
catch(Exception $e)
{
echo "Exception: ".$e->getMessage()."\n";
$transaction->rollback();
return false;
}
}
// ...similar code for down()
}
~~~
> Note: Not all DBMS support transactions. And some DB queries cannot be put
> into a transaction. In this case, you will have to implement `up()` and
> `down()`, instead. And for MySQL, some SQL statements may cause
> [implicit commit](http://dev.mysql.com/doc/refman/5.1/en/implicit-commit.html).
Applying Migrations
-------------------
To apply all available new migrations (i.e., make the local database up-to-date),
run the following command:
~~~
yiic migrate
~~~
The command will show the list of all new migrations. If you confirm to apply
the migrations, it will run the `up()` method in every new migration class, one
after another, in the order of the timestamp value in the class name.
After applying a migration, the migration tool will keep a record in a database
table named `tbl_migration`. This allows the tool to identify which migrations
have been applied and which are not. If the `tbl_migration` table does not exist,
the tool will automatically create it in the database specified by the `db`
application component.
Sometimes, we may only want to apply one or a few new migrations. We can use the
following command:
~~~
yiic migrate/up 3
~~~
This command will apply the 3 new migrations. Changing the value 3 will allow
us to change the number of migrations to be applied.
We can also migrate the database to a specific version with the following command:
~~~
yiic migrate/to 101129_185401
~~~
That is, we use the timestamp part of a migration name to specify the version
that we want to migrate the database to. If there are multiple migrations between
the last applied migration and the specified migration, all these migrations
will be applied. If the specified migration has been applied before, then all
migrations applied after it will be reverted (to be described in the next section).
Reverting Migrations
--------------------
To revert the last one or several applied migrations, we can use the following
command:
~~~
yiic migrate/down [step]
~~~
where the optional `step` parameter specifies how many migrations to be reverted
back. It defaults to 1, meaning reverting back the last applied migration.
As we described before, not all migrations can be reverted. Trying to revert
such migrations will throw an exception and stop the whole reverting process.
Redoing Migrations
------------------
Redoing migrations means first reverting and then applying the specified migrations.
This can be done with the following command:
~~~
yiic migrate/redo [step]
~~~
where the optional `step` parameter specifies how many migrations to be redone.
It defaults to 1, meaning redoing the last migration.
Showing Migration Information
-----------------------------
Besides applying and reverting migrations, the migration tool can also display
the migration history and the new migrations to be applied.
~~~
yiic migrate/history [limit]
yiic migrate/new [limit]
~~~
where the optional parameter `limit` specifies the number of migrations to be
displayed. If `limit` is not specified, all available migrations will be displayed.
The first command shows the migrations that have been applied, while the second
command shows the migrations that have not been applied.
Modifying Migration History
---------------------------
Sometimes, we may want to modify the migration history to a specific migration
version without actually applying or reverting the relevant migrations. This
often happens when developing a new migration. We can use the following command
to achieve this goal.
~~~
yiic migrate/mark 101129_185401
~~~
This command is very similar to `yiic migrate/to` command, except that it only
modifies the migration history table to the specified version without applying
or reverting the migrations.
Customizing Migration Command
-----------------------------
There are several ways to customize the migration command.
### Use Command Line Options
The migration command comes with four options that can be specified in command
line:
* `interactive`: boolean, specifies whether to perform migrations in an
interactive mode. Defaults to true, meaning the user will be prompted when
performing a specific migration. You may set this to false should the
migrations be done in a background process.
* `migrationPath`: string, specifies the directory storing all migration class
files. This must be specified in terms of a path alias, and the corresponding
directory must exist. If not specified, it will use the `migrations`
sub-directory under the application base path.
* `migrationTable`: string, specifies the name of the database table for storing
migration history information. It defaults to `tbl_migration`. The table
structure is `version varchar(255) primary key, apply_time integer`.
* `connectionID`: string, specifies the ID of the database application component.
Defaults to 'db'.
* `templateFile`: string, specifies the path of the file to be served as the code
template for generating the migration classes. This must be specified in terms
of a path alias (e.g. `application.migrations.template`). If not set, an
internal template will be used. Inside the template, the token `{ClassName}`
will be replaced with the actual migration class name.
To specify these options, execute the migrate command using the following format
~~~
yiic migrate/up --option1=value1 --option2=value2 ...
~~~
For example, if we want to migrate for a `forum` module whose migration files
are located within the module's `migrations` directory, we can use the following
command:
~~~
yiic migrate/up --migrationPath=ext.forum.migrations
~~~
### Configure Command Globally
While command line options allow us to configure the migration command
on-the-fly, sometimes we may want to configure the command once for all.
For example, we may want to use a different table to store the migration history,
or we may want to use a customized migration template. We can do so by modifying
the console application's configuration file like the following,
```php
TBD
```
Now if we run the `migrate` command, the above configurations will take effect
without requiring us to enter the command line options every time.

2
framework/assets.php

@ -28,4 +28,4 @@ return array(
),
'depends' => array('yii', 'yii/validation'),
),
);
);

2
framework/base/ActionFilter.php

@ -87,4 +87,4 @@ class ActionFilter extends Behavior
{
return !in_array($action->id, $this->except, true) && (empty($this->only) || in_array($action->id, $this->only, true));
}
}
}

9
framework/base/Application.php

@ -306,6 +306,15 @@ class Application extends Module
}
/**
* @return null|Component
* @todo
*/
public function getAuthManager()
{
return $this->getComponent('auth');
}
/**
* Registers the core application components.
* @see setComponents
*/

2
framework/base/Exception.php

@ -22,4 +22,4 @@ class Exception extends \Exception
{
return \Yii::t('yii|Exception');
}
}
}

6
framework/base/View.php

@ -744,10 +744,10 @@ class View extends Component
{
$lines = array();
if (!empty($this->metaTags)) {
$lines[] = implode("\n", $this->cssFiles);
$lines[] = implode("\n", $this->metaTags);
}
if (!empty($this->linkTags)) {
$lines[] = implode("\n", $this->cssFiles);
$lines[] = implode("\n", $this->linkTags);
}
if (!empty($this->cssFiles)) {
$lines[] = implode("\n", $this->cssFiles);
@ -797,4 +797,4 @@ class View extends Component
}
return implode("\n", $lines);
}
}
}

2
framework/base/ViewEvent.php

@ -41,4 +41,4 @@ class ViewEvent extends Event
$this->viewFile = $viewFile;
parent::__construct($config);
}
}
}

2
framework/base/Widget.php

@ -134,4 +134,4 @@ class Widget extends Component
return pathinfo($file, PATHINFO_EXTENSION) === '' ? $file . '.php' : $file;
}
}
}

2
framework/caching/Cache.php

@ -349,4 +349,4 @@ abstract class Cache extends Component implements \ArrayAccess
{
$this->delete($key);
}
}
}

2
framework/caching/Dependency.php

@ -49,4 +49,4 @@ abstract class Dependency extends \yii\base\Object
* @return mixed the data needed to determine if dependency has been changed.
*/
abstract protected function generateDependencyData();
}
}

2
framework/caching/MemCacheServer.php

@ -46,4 +46,4 @@ class MemCacheServer extends \yii\base\Object
* @var boolean if the server should be flagged as online upon a failure. This is used by memcache only.
*/
public $status = true;
}
}

2
framework/caching/WinCache.php

@ -89,4 +89,4 @@ class WinCache extends Cache
{
return wincache_ucache_clear();
}
}
}

2
framework/console/Controller.php

@ -147,4 +147,4 @@ class Controller extends \yii\base\Controller
{
return array();
}
}
}

2
framework/console/controllers/AppController.php

@ -321,4 +321,4 @@ class AppController extends Controller
closedir($handle);
return $list;
}
}
}

2
framework/console/controllers/AssetController.php

@ -350,4 +350,4 @@ return array(
EOD;
file_put_contents($configFile, $template);
}
}
}

2
framework/console/controllers/HelpController.php

@ -418,4 +418,4 @@ class HelpController extends Controller
$name = $required ? "$name (required)" : $name;
return $doc === '' ? $name : "$name: $doc";
}
}
}

2
framework/console/webapp/config.php

@ -14,4 +14,4 @@ return array(
'permissions' => 0755,
),
),
);
);

2
framework/console/webapp/default/index.php

@ -7,4 +7,4 @@ $config = require dirname(__DIR__).'/protected/config/main.php';
$config['basePath'] = dirname(__DIR__).'/protected';
$app = new \yii\web\Application($config);
$app->run();
$app->run();

2
framework/console/webapp/default/protected/config/main.php

@ -17,4 +17,4 @@ return array(
'class' => 'yii\caching\DummyCache',
),
),
);
);

2
framework/console/webapp/default/protected/controllers/SiteController.php

@ -12,4 +12,4 @@ class SiteController extends Controller
'name' => 'Qiang',
));
}
}
}

2
framework/console/webapp/default/protected/views/layouts/main.php

@ -14,4 +14,4 @@
<?php echo \Yii::powered()?>
</div>
</body>
</html>
</html>

2
framework/console/webapp/default/protected/views/site/index.php

@ -1 +1 @@
Hello, <?php echo $name?>!
Hello, <?php echo $name?>!

2
framework/db/Exception.php

@ -41,4 +41,4 @@ class Exception extends \yii\base\Exception
{
return \Yii::t('yii|Database Exception');
}
}
}

2
framework/db/Expression.php

@ -57,4 +57,4 @@ class Expression extends \yii\base\Object
{
return $this->expression;
}
}
}

2
framework/db/Migration.php

@ -368,4 +368,4 @@ class Migration extends \yii\base\Component
$this->db->createCommand()->dropIndex($name, $table)->execute();
echo " done (time: " . sprintf('%.3f', microtime(true) - $time) . "s)\n";
}
}
}

2
framework/db/StaleObjectException.php

@ -20,4 +20,4 @@ class StaleObjectException extends Exception
{
return \Yii::t('yii|Stale Object Exception');
}
}
}

2
framework/helpers/ArrayHelper.php

@ -16,4 +16,4 @@ namespace yii\helpers;
*/
class ArrayHelper extends base\ArrayHelper
{
}
}

2
framework/helpers/FileHelper.php

@ -18,4 +18,4 @@ namespace yii\helpers;
*/
class FileHelper extends base\FileHelper
{
}
}

2
framework/helpers/JsExpression.php

@ -42,4 +42,4 @@ class JsExpression extends Object
{
return $this->expression;
}
}
}

2
framework/helpers/Json.php

@ -15,4 +15,4 @@ namespace yii\helpers;
class Json extends base\Json
{
}
}

2
framework/helpers/SecurityHelper.php

@ -26,4 +26,4 @@ namespace yii\helpers;
*/
class SecurityHelper extends base\SecurityHelper
{
}
}

2
framework/helpers/VarDumper.php

@ -25,4 +25,4 @@ namespace yii\helpers;
*/
class VarDumper extends base\VarDumper
{
}
}

2
framework/helpers/base/ArrayHelper.php

@ -349,4 +349,4 @@ class ArrayHelper
}
return $d;
}
}
}

2
framework/helpers/base/FileHelper.php

@ -169,4 +169,4 @@ class FileHelper
}
closedir($handle);
}
}
}

2
framework/helpers/base/Json.php

@ -104,4 +104,4 @@ class Json
return $data;
}
}
}
}

6
framework/helpers/base/SecurityHelper.php

@ -167,11 +167,11 @@ class SecurityHelper
*
* ~~~
* // generates the hash (usually done during user registration or when the password is changed)
* $hash = SecurityHelper::hashPassword($password);
* $hash = SecurityHelper::generatePasswordHash($password);
* // ...save $hash in database...
*
* // during login, validate if the password entered is correct using $hash fetched from database
* if (PasswordHelper::verifyPassword($password, $hash) {
* if (SecurityHelper::verifyPassword($password, $hash) {
* // password is good
* } else {
* // password is bad
@ -217,7 +217,7 @@ class SecurityHelper
throw new InvalidParamException('Password must be a string and cannot be empty.');
}
if (!preg_match('/^\$2[axy]\$(\d\d)\$[\./0-9A-Za-z]{22}/', $hash, $matches) || $matches[1] < 4 || $matches[1] > 30) {
if (!preg_match('/^\$2[axy]\$(\d\d)\$[\.\/0-9A-Za-z]{22}/', $hash, $matches) || $matches[1] < 4 || $matches[1] > 30) {
throw new InvalidParamException('Hash is invalid.');
}

4
framework/helpers/base/VarDumper.php

@ -39,7 +39,7 @@ class VarDumper
*/
public static function dump($var, $depth = 10, $highlight = false)
{
echo self::dumpAsString($var, $depth, $highlight);
echo static::dumpAsString($var, $depth, $highlight);
}
/**
@ -131,4 +131,4 @@ class VarDumper
break;
}
}
}
}

2
framework/i18n/PhpMessageSource.php

@ -76,4 +76,4 @@ class PhpMessageSource extends MessageSource
return array();
}
}
}
}

2
framework/i18n/data/plurals.php

@ -624,4 +624,4 @@ return array (
array (
0 => 'in_array(fmod($n,10),array(1,2))||fmod($n,20)==0',
),
);
);

2
framework/logging/EmailTarget.php

@ -69,4 +69,4 @@ class EmailTarget extends Target
}
mail($sentTo, $subject, $body, implode("\r\n", $headers));
}
}
}

2
framework/logging/ProfileTarget.php

@ -189,4 +189,4 @@ class CProfileLogRoute extends CWebLogRoute
$total += $delta;
return array($token, $calls, $min, $max, $total);
}
}
}

2
framework/logging/Target.php

@ -89,7 +89,7 @@ abstract class Target extends \yii\base\Component
*/
public function collect($messages, $final)
{
$this->_messages = array($this->_messages, $this->filterMessages($messages));
$this->_messages = array_merge($this->_messages, $this->filterMessages($messages));
$count = count($this->_messages);
if ($count > 0 && ($final || $this->exportInterval > 0 && $count >= $this->exportInterval)) {
if (($context = $this->getContextMessage()) !== '') {

2
framework/logging/WebTarget.php

@ -58,4 +58,4 @@ class CWebLogRoute extends CLogRoute
$viewFile = YII_PATH . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $view . '.php';
include($app->findLocalizedFile($viewFile, 'en'));
}
}
}

2
framework/renderers/SmartyViewRenderer.php

@ -102,4 +102,4 @@ class SmartyViewRenderer extends ViewRenderer
return $template->fetch();
}
}
}

6
framework/validators/FileValidator.php

@ -192,11 +192,11 @@ class FileValidator extends Validator
break;
case UPLOAD_ERR_CANT_WRITE:
$this->addError($object, $attribute, $this->message);
Yii::warning('Failed to write the uploaded file to disk: ', $file->getName(), __METHOD__);
Yii::warning('Failed to write the uploaded file to disk: ' . $file->getName(), __METHOD__);
break;
case UPLOAD_ERR_EXTENSION:
$this->addError($object, $attribute, $this->message);
Yii::warning('File upload was stopped by some PHP extension: ', $file->getName(), __METHOD__);
Yii::warning('File upload was stopped by some PHP extension: ' . $file->getName(), __METHOD__);
break;
default:
break;
@ -248,4 +248,4 @@ class FileValidator extends Validator
return (int)$sizeStr;
}
}
}
}

2
framework/validators/InlineValidator.php

@ -96,4 +96,4 @@ class InlineValidator extends Validator
return null;
}
}
}
}

2
framework/validators/NumberValidator.php

@ -151,4 +151,4 @@ class NumberValidator extends Validator
return 'yii.validation.number(value, messages, ' . Json::encode($options) . ');';
}
}
}

2
framework/validators/UniqueValidator.php

@ -97,4 +97,4 @@ class UniqueValidator extends Validator
$this->addError($object, $attribute, $this->message);
}
}
}
}

2
framework/views/error.php

@ -64,4 +64,4 @@ $title = $context->htmlEncode($exception instanceof \yii\base\Exception ? $excep
<?php echo YII_DEBUG ? $context->versionInfo : ''?>
</div>
</body>
</html>
</html>

2
framework/web/AccessControl.php

@ -103,4 +103,4 @@ class AccessControl extends ActionFilter
throw new HttpException(403, Yii::t('yii|You are not allowed to perform this action.'));
}
}
}
}

4
framework/web/AccessRule.php

@ -144,7 +144,7 @@ class AccessRule extends Component
return true;
} elseif ($role === '@' && !$user->getIsGuest()) {
return true;
} elseif ($user->hasAccess($role)) {
} elseif ($user->checkAccess($role)) {
return true;
}
}
@ -185,4 +185,4 @@ class AccessRule extends Component
{
return empty($this->matchCallback) || call_user_func($this->matchCallback, $this, $action);
}
}
}

2
framework/web/AssetBundle.php

@ -173,4 +173,4 @@ class AssetBundle extends Object
}
}
}
}
}

4
framework/web/AssetConverter.php

@ -53,10 +53,10 @@ class AssetConverter extends Component implements IAssetConverter
));
exec($command, $output);
Yii::info("Converted $asset into $result: " . implode("\n", $output), __METHOD__);
return "$baseUrl/$result";
}
return "$baseUrl/$result";
}
}
return "$baseUrl/$asset";
}
}
}

2
framework/web/Controller.php

@ -40,4 +40,4 @@ class Controller extends \yii\base\Controller
}
return Yii::$app->getUrlManager()->createUrl($route, $params);
}
}
}

2
framework/web/HttpCache.php

@ -128,4 +128,4 @@ class HttpCache extends ActionFilter
{
return '"' . base64_encode(sha1($seed, true)) . '"';
}
}
}

2
framework/web/IAssetConverter.php

@ -24,4 +24,4 @@ interface IAssetConverter
* need conversion, "$baseUrl/$asset" should be returned.
*/
public function convert($asset, $basePath, $baseUrl);
}
}

2
framework/web/Identity.php

@ -78,4 +78,4 @@ interface Identity
* @see getAuthKey()
*/
public function validateAuthKey($authKey);
}
}

2
framework/web/PageCache.php

@ -101,4 +101,4 @@ class PageCache extends ActionFilter
{
$this->view->endCache();
}
}
}

2
framework/web/Pagination.php

@ -205,4 +205,4 @@ class Pagination extends \yii\base\Object
{
return $this->pageSize < 1 ? -1 : $this->pageSize;
}
}
}

2
framework/web/Sort.php

@ -333,4 +333,4 @@ class Sort extends \yii\base\Object
return false;
}
}
}
}

6
framework/web/UploadedFile.php

@ -7,7 +7,7 @@
namespace yii\web;
use yii\widgets\ActiveForm;
use yii\widgets\Html;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
@ -66,7 +66,7 @@ class UploadedFile extends \yii\base\Object
*/
public static function getInstance($model, $attribute)
{
$name = ActiveForm::getInputName($model, $attribute);
$name = Html::getInputName($model, $attribute);
return static::getInstanceByName($name);
}
@ -80,7 +80,7 @@ class UploadedFile extends \yii\base\Object
*/
public static function getInstances($model, $attribute)
{
$name = ActiveForm::getInputName($model, $attribute);
$name = Html::getInputName($model, $attribute);
return static::getInstancesByName($name);
}

4
framework/web/UrlManager.php

@ -51,7 +51,7 @@ class UrlManager extends Component
* @var boolean whether to show entry script name in the constructed URL. Defaults to true.
* This property is used only if [[enablePrettyUrl]] is true.
*/
public $showScriptName = true;
public $showScriptName = false;
/**
* @var string the GET variable name for route. This property is used only if [[enablePrettyUrl]] is false.
*/
@ -174,7 +174,7 @@ class UrlManager extends Component
public function createUrl($route, $params = array())
{
$anchor = isset($params['#']) ? '#' . $params['#'] : '';
unset($params['#']);
unset($params['#'], $params[$this->routeVar]);
$route = trim($route, '/');
$baseUrl = $this->getBaseUrl();

17
framework/web/User.php

@ -447,4 +447,21 @@ class User extends Component
}
}
}
/**
* Checks whether the user has access to the specified operation.
* @param $operator
* @param array $params
* @return bool
* @todo
*/
public function checkAccess($operation, $params = array())
{
$auth = Yii::$app->getAuthManager();
if ($auth !== null) {
return $auth->checkAccess($this->getId(), $operation, $params);
} else {
return true;
}
}
}

2
framework/web/UserEvent.php

@ -31,4 +31,4 @@ class UserEvent extends Event
* This property is only meaningful for [[User::EVENT_BEFORE_LOGIN]] and [[User::EVENT_BEFORE_LOGOUT]] events.
*/
public $isValid = true;
}
}

2
framework/widgets/ActiveField.php

@ -541,4 +541,4 @@ class ActiveField extends Component
. '</div>'
);
}
}
}

2
framework/widgets/Block.php

@ -46,4 +46,4 @@ class Block extends Widget
}
$this->view->blocks[$this->id] = $block;
}
}
}

2
framework/widgets/FragmentCache.php

@ -171,4 +171,4 @@ class FragmentCache extends Widget
}
return $this->cache->buildKey($factors);
}
}
}

2
tests/unit/MysqlTestCase.php

@ -33,4 +33,4 @@ class MysqlTestCase extends TestCase
}
return $db;
}
}
}

2
tests/unit/TestCase.php

@ -13,4 +13,4 @@ class TestCase extends \yii\test\TestCase
}
return isset(self::$params[$name]) ? self::$params[$name] : null;
}
}
}

2
tests/unit/data/ar/ActiveRecord.php

@ -23,4 +23,4 @@ class ActiveRecord extends \yii\db\ActiveRecord
{
return self::$db;
}
}
}

2
tests/unit/data/ar/Customer.php

@ -24,4 +24,4 @@ class Customer extends ActiveRecord
{
return $query->andWhere('status=1');
}
}
}

2
tests/unit/data/ar/Item.php

@ -8,4 +8,4 @@ class Item extends ActiveRecord
{
return 'tbl_item';
}
}
}

2
tests/unit/data/ar/Order.php

@ -43,4 +43,4 @@ class Order extends ActiveRecord
return false;
}
}
}
}

2
tests/unit/data/ar/OrderItem.php

@ -18,4 +18,4 @@ class OrderItem extends ActiveRecord
{
return $this->hasOne('Item', array('id' => 'item_id'));
}
}
}

2
tests/unit/data/base/Singer.php

@ -18,4 +18,4 @@ class Singer extends Model
array('underscore_style', 'yii\validators\CaptchaValidator'),
);
}
}
}

2
tests/unit/framework/base/ComponentTest.php

@ -387,4 +387,4 @@ class NewComponent2 extends Component
$this->b = $b;
$this->c = $c;
}
}
}

2
tests/unit/framework/base/ObjectTest.php

@ -181,4 +181,4 @@ class NewObject extends Object
{
return $this->_items;
}
}
}

4
tests/unit/framework/caching/ApcCacheTest.php

@ -17,6 +17,8 @@ class ApcCacheTest extends CacheTest
{
if(!extension_loaded("apc")) {
$this->markTestSkipped("APC not installed. Skipping.");
} else if ('cli' === PHP_SAPI && !ini_get('apc.enable_cli')) {
$this->markTestSkipped("APC cli is not enabled. Skipping.");
}
if($this->_cacheInstance === null) {
@ -24,4 +26,4 @@ class ApcCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/DbCacheTest.php

@ -67,4 +67,4 @@ class DbCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/FileCacheTest.php

@ -22,4 +22,4 @@ class FileCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/MemCacheTest.php

@ -24,4 +24,4 @@ class MemCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/MemCachedTest.php

@ -26,4 +26,4 @@ class MemCachedTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/WinCacheTest.php

@ -28,4 +28,4 @@ class WinCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/XCacheTest.php

@ -24,4 +24,4 @@ class XCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/caching/ZendDataCacheTest.php

@ -24,4 +24,4 @@ class ZendDataCacheTest extends CacheTest
}
return $this->_cacheInstance;
}
}
}

2
tests/unit/framework/db/ActiveRecordTest.php

@ -356,4 +356,4 @@ class ActiveRecordTest extends \yiiunit\MysqlTestCase
$customers = Customer::find()->all();
$this->assertEquals(0, count($customers));
}
}
}

2
tests/unit/framework/db/CommandTest.php

@ -289,4 +289,4 @@ class CommandTest extends \yiiunit\MysqlTestCase
{
}
}
}

2
tests/unit/framework/db/QueryTest.php

@ -113,4 +113,4 @@ class QueryTest extends \yiiunit\MysqlTestCase
{
}
}
}

2
tests/unit/framework/helpers/JsonTest.php

@ -57,4 +57,4 @@ class JsonTest extends \yii\test\TestCase
$this->setExpectedException('yii\base\InvalidParamException');
Json::decode($json);
}
}
}

2
tests/unit/framework/helpers/StringHelperTest.php

@ -70,4 +70,4 @@ class StringHelperTest extends \yii\test\TestCase
$this->assertEquals('PostTag', StringHelper::id2camel('post-tag'));
$this->assertEquals('PostTag', StringHelper::id2camel('post_tag', '_'));
}
}
}

2
tests/unit/framework/helpers/VarDumperTest.php

@ -9,4 +9,4 @@ class VarDumperTest extends \yii\test\TestCase
$obj = new \StdClass();
VarDumper::dump($obj);
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save