Commit 6a3e9e15 by Simone

Merge pull request #2 from yiisoft/master

Merge from master
parents 1451aa60 637e1160
...@@ -306,6 +306,15 @@ class Application extends Module ...@@ -306,6 +306,15 @@ class Application extends Module
} }
/** /**
* @return null|Component
* @todo
*/
public function getAuthManager()
{
return $this->getComponent('auth');
}
/**
* Registers the core application components. * Registers the core application components.
* @see setComponents * @see setComponents
*/ */
......
...@@ -744,10 +744,10 @@ class View extends Component ...@@ -744,10 +744,10 @@ class View extends Component
{ {
$lines = array(); $lines = array();
if (!empty($this->metaTags)) { if (!empty($this->metaTags)) {
$lines[] = implode("\n", $this->cssFiles); $lines[] = implode("\n", $this->metaTags);
} }
if (!empty($this->linkTags)) { if (!empty($this->linkTags)) {
$lines[] = implode("\n", $this->cssFiles); $lines[] = implode("\n", $this->linkTags);
} }
if (!empty($this->cssFiles)) { if (!empty($this->cssFiles)) {
$lines[] = implode("\n", $this->cssFiles); $lines[] = implode("\n", $this->cssFiles);
......
...@@ -167,11 +167,11 @@ class SecurityHelper ...@@ -167,11 +167,11 @@ class SecurityHelper
* *
* ~~~ * ~~~
* // generates the hash (usually done during user registration or when the password is changed) * // 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... * // ...save $hash in database...
* *
* // during login, validate if the password entered is correct using $hash fetched from 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 * // password is good
* } else { * } else {
* // password is bad * // password is bad
...@@ -217,7 +217,7 @@ class SecurityHelper ...@@ -217,7 +217,7 @@ class SecurityHelper
throw new InvalidParamException('Password must be a string and cannot be empty.'); 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.'); throw new InvalidParamException('Hash is invalid.');
} }
......
...@@ -39,7 +39,7 @@ class VarDumper ...@@ -39,7 +39,7 @@ class VarDumper
*/ */
public static function dump($var, $depth = 10, $highlight = false) public static function dump($var, $depth = 10, $highlight = false)
{ {
echo self::dumpAsString($var, $depth, $highlight); echo static::dumpAsString($var, $depth, $highlight);
} }
/** /**
......
...@@ -89,7 +89,7 @@ abstract class Target extends \yii\base\Component ...@@ -89,7 +89,7 @@ abstract class Target extends \yii\base\Component
*/ */
public function collect($messages, $final) 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); $count = count($this->_messages);
if ($count > 0 && ($final || $this->exportInterval > 0 && $count >= $this->exportInterval)) { if ($count > 0 && ($final || $this->exportInterval > 0 && $count >= $this->exportInterval)) {
if (($context = $this->getContextMessage()) !== '') { if (($context = $this->getContextMessage()) !== '') {
......
...@@ -192,11 +192,11 @@ class FileValidator extends Validator ...@@ -192,11 +192,11 @@ class FileValidator extends Validator
break; break;
case UPLOAD_ERR_CANT_WRITE: case UPLOAD_ERR_CANT_WRITE:
$this->addError($object, $attribute, $this->message); $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; break;
case UPLOAD_ERR_EXTENSION: case UPLOAD_ERR_EXTENSION:
$this->addError($object, $attribute, $this->message); $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; break;
default: default:
break; break;
......
...@@ -144,7 +144,7 @@ class AccessRule extends Component ...@@ -144,7 +144,7 @@ class AccessRule extends Component
return true; return true;
} elseif ($role === '@' && !$user->getIsGuest()) { } elseif ($role === '@' && !$user->getIsGuest()) {
return true; return true;
} elseif ($user->hasAccess($role)) { } elseif ($user->checkAccess($role)) {
return true; return true;
} }
} }
......
...@@ -53,8 +53,8 @@ class AssetConverter extends Component implements IAssetConverter ...@@ -53,8 +53,8 @@ class AssetConverter extends Component implements IAssetConverter
)); ));
exec($command, $output); exec($command, $output);
Yii::info("Converted $asset into $result: " . implode("\n", $output), __METHOD__); Yii::info("Converted $asset into $result: " . implode("\n", $output), __METHOD__);
return "$baseUrl/$result";
} }
return "$baseUrl/$result";
} }
} }
return "$baseUrl/$asset"; return "$baseUrl/$asset";
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace yii\web; namespace yii\web;
use yii\widgets\ActiveForm; use yii\widgets\Html;
/** /**
* @author Qiang Xue <qiang.xue@gmail.com> * @author Qiang Xue <qiang.xue@gmail.com>
...@@ -66,7 +66,7 @@ class UploadedFile extends \yii\base\Object ...@@ -66,7 +66,7 @@ class UploadedFile extends \yii\base\Object
*/ */
public static function getInstance($model, $attribute) public static function getInstance($model, $attribute)
{ {
$name = ActiveForm::getInputName($model, $attribute); $name = Html::getInputName($model, $attribute);
return static::getInstanceByName($name); return static::getInstanceByName($name);
} }
...@@ -80,7 +80,7 @@ class UploadedFile extends \yii\base\Object ...@@ -80,7 +80,7 @@ class UploadedFile extends \yii\base\Object
*/ */
public static function getInstances($model, $attribute) public static function getInstances($model, $attribute)
{ {
$name = ActiveForm::getInputName($model, $attribute); $name = Html::getInputName($model, $attribute);
return static::getInstancesByName($name); return static::getInstancesByName($name);
} }
......
...@@ -51,7 +51,7 @@ class UrlManager extends Component ...@@ -51,7 +51,7 @@ class UrlManager extends Component
* @var boolean whether to show entry script name in the constructed URL. Defaults to true. * @var boolean whether to show entry script name in the constructed URL. Defaults to true.
* This property is used only if [[enablePrettyUrl]] is 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. * @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 ...@@ -174,7 +174,7 @@ class UrlManager extends Component
public function createUrl($route, $params = array()) public function createUrl($route, $params = array())
{ {
$anchor = isset($params['#']) ? '#' . $params['#'] : ''; $anchor = isset($params['#']) ? '#' . $params['#'] : '';
unset($params['#']); unset($params['#'], $params[$this->routeVar]);
$route = trim($route, '/'); $route = trim($route, '/');
$baseUrl = $this->getBaseUrl(); $baseUrl = $this->getBaseUrl();
......
...@@ -447,4 +447,21 @@ class User extends Component ...@@ -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;
}
}
} }
...@@ -17,6 +17,8 @@ class ApcCacheTest extends CacheTest ...@@ -17,6 +17,8 @@ class ApcCacheTest extends CacheTest
{ {
if(!extension_loaded("apc")) { if(!extension_loaded("apc")) {
$this->markTestSkipped("APC not installed. Skipping."); $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) { if($this->_cacheInstance === null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment