mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-03 05:48:11 +08:00
Scrutinizer fixes (#18685)
* https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/filters/AccessRule.php?selectedLabels%5B0%5D=2&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/helpers/BaseFileHelper.php?selectedLabels%5B0%5D=2&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/base/Application.php?selectedLabels%5B0%5D=7&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/base/Module.php?selectedLabels%5B0%5D=7&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/web/MultipartFormDataParser.php?selectedLabels%5B0%5D=7&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/web/Session.php?selectedLabels%5B0%5D=7&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/base/Controller.php?selectedLabels%5B0%5D=6&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/console/controllers/MigrateController.php?selectedLabels%5B0%5D=6&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * Added vardocs, and small refactor * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/db/conditions/InConditionBuilder.php?selectedLabels%5B0%5D=6&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/db/Connection.php?selectedLabels%5B0%5D=6&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/db/mssql/QueryBuilder.php?selectedLabels%5B0%5D=6&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/log/Logger.php?selectedLabels%5B0%5D=6&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/console/controllers/BaseMigrateController.php?selectedLabels%5B0%5D=18&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * Adding space between type * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/console/controllers/CacheController.php?selectedLabels%5B0%5D=18&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/console/controllers/FixtureController.php?selectedLabels%5B0%5D=18&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * https://scrutinizer-ci.com/g/yiisoft/yii2/issues/master/files/framework/console/controllers/MigrateController.php?selectedLabels%5B0%5D=18&selectedSeverities%5B0%5D=10&selectedSeverities%5B1%5D=5&orderField=path&order=asc&honorSelectedPaths=0 * Update framework/console/controllers/CacheController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/CacheController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/FixtureController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/FixtureController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/FixtureController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/FixtureController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/FixtureController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> * Update framework/console/controllers/FixtureController.php Co-authored-by: Alexander Makarov <sam@rmcreative.ru> Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
This commit is contained in:
@ -68,7 +68,7 @@ class BaseYii
|
||||
*/
|
||||
public static $classMap = [];
|
||||
/**
|
||||
* @var \yii\console\Application|\yii\web\Application the application instance
|
||||
* @var \yii\console\Application|\yii\web\Application|\yii\base\Application the application instance
|
||||
*/
|
||||
public static $app;
|
||||
/**
|
||||
@ -124,7 +124,7 @@ class BaseYii
|
||||
* @param string $alias the alias to be translated.
|
||||
* @param bool $throwException whether to throw an exception if the given alias is invalid.
|
||||
* If this is false and an invalid alias is given, false will be returned by this method.
|
||||
* @return string|bool the path corresponding to the alias, false if the root alias is not previously registered.
|
||||
* @return string|false the path corresponding to the alias, false if the root alias is not previously registered.
|
||||
* @throws InvalidArgumentException if the alias is invalid while $throwException is true.
|
||||
* @see setAlias()
|
||||
*/
|
||||
@ -162,7 +162,7 @@ class BaseYii
|
||||
* A root alias is an alias that has been registered via [[setAlias()]] previously.
|
||||
* If a given alias matches multiple root aliases, the longest one will be returned.
|
||||
* @param string $alias the alias
|
||||
* @return string|bool the root alias, or false if no root alias is found
|
||||
* @return string|false the root alias, or false if no root alias is found
|
||||
*/
|
||||
public static function getRootAlias($alias)
|
||||
{
|
||||
|
||||
@ -514,6 +514,7 @@ class Controller extends Component implements ViewContextInterface
|
||||
public function findLayoutFile($view)
|
||||
{
|
||||
$module = $this->module;
|
||||
$layout = null;
|
||||
if (is_string($this->layout)) {
|
||||
$layout = $this->layout;
|
||||
} elseif ($this->layout === null) {
|
||||
@ -525,7 +526,7 @@ class Controller extends Component implements ViewContextInterface
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($layout)) {
|
||||
if ($layout === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -238,7 +238,7 @@ class Module extends ServiceLocator
|
||||
{
|
||||
$path = Yii::getAlias($path);
|
||||
$p = strncmp($path, 'phar://', 7) === 0 ? $path : realpath($path);
|
||||
if ($p !== false && is_dir($p)) {
|
||||
if (is_string($p) && is_dir($p)) {
|
||||
$this->_basePath = $p;
|
||||
} else {
|
||||
throw new InvalidArgumentException("The directory does not exist: $path");
|
||||
|
||||
@ -132,7 +132,7 @@ class AttributeTypecastBehavior extends Behavior
|
||||
* 'price' => 'float',
|
||||
* 'is_active' => 'boolean',
|
||||
* 'date' => function ($value) {
|
||||
* return ($value instanceof \DateTime) ? $value->getTimestamp(): (int)$value;
|
||||
* return ($value instanceof \DateTime) ? $value->getTimestamp(): (int) $value;
|
||||
* },
|
||||
* ]
|
||||
* ```
|
||||
|
||||
@ -587,9 +587,7 @@ abstract class BaseMigrateController extends Controller
|
||||
*/
|
||||
public function actionNew($limit = 10)
|
||||
{
|
||||
if ($limit === 'all') {
|
||||
$limit = null;
|
||||
} else {
|
||||
if ($limit !== 'all') {
|
||||
$limit = (int) $limit;
|
||||
if ($limit < 1) {
|
||||
throw new Exception('The limit must be greater than 0.');
|
||||
@ -602,7 +600,7 @@ abstract class BaseMigrateController extends Controller
|
||||
$this->stdout("No new migrations found. Your system is up-to-date.\n", Console::FG_GREEN);
|
||||
} else {
|
||||
$n = count($migrations);
|
||||
if ($limit && $n > $limit) {
|
||||
if ($limit !== 'all' && $n > $limit) {
|
||||
$migrations = array_slice($migrations, 0, $limit);
|
||||
$this->stdout("Showing $limit out of $n new " . ($n === 1 ? 'migration' : 'migrations') . ":\n", Console::FG_YELLOW);
|
||||
} else {
|
||||
|
||||
@ -84,11 +84,11 @@ class CacheController extends Controller
|
||||
$foundCaches = array_keys($caches);
|
||||
$notFoundCaches = array_diff($cachesInput, array_keys($caches));
|
||||
|
||||
if ($notFoundCaches) {
|
||||
if ($notFoundCaches !== []) {
|
||||
$this->notifyNotFoundCaches($notFoundCaches);
|
||||
}
|
||||
|
||||
if (!$foundCaches) {
|
||||
if ($foundCaches === []) {
|
||||
$this->notifyNoCachesFound();
|
||||
return ExitCode::OK;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ class FixtureController extends Controller
|
||||
$foundFixtures = $this->findFixtures($fixtures);
|
||||
$notFoundFixtures = array_diff($fixtures, $foundFixtures);
|
||||
|
||||
if ($notFoundFixtures) {
|
||||
if ($notFoundFixtures !== []) {
|
||||
$this->notifyNotFound($notFoundFixtures);
|
||||
}
|
||||
} else {
|
||||
@ -138,7 +138,7 @@ class FixtureController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
if (!$fixturesToLoad) {
|
||||
if ($fixturesToLoad === []) {
|
||||
$this->notifyNothingToLoad($foundFixtures, $except);
|
||||
return ExitCode::OK;
|
||||
}
|
||||
@ -198,23 +198,23 @@ class FixtureController extends Controller
|
||||
$foundFixtures = $this->findFixtures($fixtures);
|
||||
$notFoundFixtures = array_diff($fixtures, $foundFixtures);
|
||||
|
||||
if ($notFoundFixtures) {
|
||||
if ($notFoundFixtures !== []) {
|
||||
$this->notifyNotFound($notFoundFixtures);
|
||||
}
|
||||
} else {
|
||||
$foundFixtures = $this->findFixtures();
|
||||
}
|
||||
|
||||
$fixturesToUnload = array_diff($foundFixtures, $except);
|
||||
|
||||
if (!$foundFixtures) {
|
||||
if ($foundFixtures === []) {
|
||||
throw new Exception(
|
||||
'No files were found for: "' . implode(', ', $fixturesInput) . "\".\n" .
|
||||
"Check that files exist under fixtures path: \n\"" . $this->getFixturePath() . '".'
|
||||
);
|
||||
}
|
||||
|
||||
if (!$fixturesToUnload) {
|
||||
$fixturesToUnload = array_diff($foundFixtures, $except);
|
||||
|
||||
if ($fixturesToUnload === []) {
|
||||
$this->notifyNothingToUnload($foundFixtures, $except);
|
||||
return ExitCode::OK;
|
||||
}
|
||||
@ -225,7 +225,7 @@ class FixtureController extends Controller
|
||||
|
||||
$fixtures = $this->getFixturesConfig(array_merge($this->globalFixtures, $fixturesToUnload));
|
||||
|
||||
if (!$fixtures) {
|
||||
if ($fixtures === []) {
|
||||
throw new Exception('No fixtures were found in namespace: ' . $this->namespace . '".');
|
||||
}
|
||||
|
||||
|
||||
@ -485,7 +485,7 @@ class HelpController extends Controller
|
||||
}
|
||||
if (is_bool($defaultValue)) {
|
||||
// show as integer to avoid confusion
|
||||
$defaultValue = (int)$defaultValue;
|
||||
$defaultValue = (int) $defaultValue;
|
||||
}
|
||||
if (is_string($defaultValue)) {
|
||||
$defaultValue = "'" . $defaultValue . "'";
|
||||
|
||||
@ -301,11 +301,9 @@ class MigrateController extends BaseMigrateController
|
||||
|
||||
// First drop all foreign keys,
|
||||
foreach ($schemas as $schema) {
|
||||
if ($schema->foreignKeys) {
|
||||
foreach ($schema->foreignKeys as $name => $foreignKey) {
|
||||
$db->createCommand()->dropForeignKey($name, $schema->name)->execute();
|
||||
$this->stdout("Foreign key $name dropped.\n");
|
||||
}
|
||||
foreach ($schema->foreignKeys as $name => $foreignKey) {
|
||||
$db->createCommand()->dropForeignKey($name, $schema->name)->execute();
|
||||
$this->stdout("Foreign key $name dropped.\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,10 +578,10 @@ class MigrateController extends BaseMigrateController
|
||||
*/
|
||||
protected function splitFieldIntoChunks($field)
|
||||
{
|
||||
$hasDoubleQuotes = false;
|
||||
$originalDefaultValue = null;
|
||||
$defaultValue = null;
|
||||
preg_match_all('/defaultValue\(["\'].*?:?.*?["\']\)/', $field, $matches, PREG_SET_ORDER, 0);
|
||||
if (isset($matches[0][0])) {
|
||||
$hasDoubleQuotes = true;
|
||||
$originalDefaultValue = $matches[0][0];
|
||||
$defaultValue = str_replace(':', '{{colon}}', $originalDefaultValue);
|
||||
$field = str_replace($originalDefaultValue, $defaultValue, $field);
|
||||
@ -591,7 +589,7 @@ class MigrateController extends BaseMigrateController
|
||||
|
||||
$chunks = preg_split('/\s?:\s?/', $field);
|
||||
|
||||
if (is_array($chunks) && $hasDoubleQuotes) {
|
||||
if (is_array($chunks) && $defaultValue !== null && $originalDefaultValue !== null) {
|
||||
foreach ($chunks as $key => $chunk) {
|
||||
$chunks[$key] = str_replace($defaultValue, $originalDefaultValue, $chunk);
|
||||
}
|
||||
|
||||
@ -1294,6 +1294,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
*/
|
||||
public function link($name, $model, $extraColumns = [])
|
||||
{
|
||||
/* @var $relation ActiveQueryInterface|ActiveQuery */
|
||||
$relation = $this->getRelation($name);
|
||||
|
||||
if ($relation->via !== null) {
|
||||
@ -1330,16 +1331,16 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
$record->insert(false);
|
||||
} else {
|
||||
/* @var $viaTable string */
|
||||
static::getDb()->createCommand()
|
||||
->insert($viaTable, $columns)->execute();
|
||||
static::getDb()->createCommand()->insert($viaTable, $columns)->execute();
|
||||
}
|
||||
} else {
|
||||
$p1 = $model->isPrimaryKey(array_keys($relation->link));
|
||||
$p2 = static::isPrimaryKey(array_values($relation->link));
|
||||
if ($p1 && $p2) {
|
||||
if ($this->getIsNewRecord() && $model->getIsNewRecord()) {
|
||||
throw new InvalidCallException('Unable to link models: at most one model can be newly created.');
|
||||
} elseif ($this->getIsNewRecord()) {
|
||||
if ($this->getIsNewRecord()) {
|
||||
if ($model->getIsNewRecord()) {
|
||||
throw new InvalidCallException('Unable to link models: at most one model can be newly created.');
|
||||
}
|
||||
$this->bindModels(array_flip($relation->link), $this, $model);
|
||||
} else {
|
||||
$this->bindModels($relation->link, $model, $this);
|
||||
@ -1492,6 +1493,7 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
*/
|
||||
public function unlinkAll($name, $delete = false)
|
||||
{
|
||||
/* @var $relation ActiveQueryInterface|ActiveQuery */
|
||||
$relation = $this->getRelation($name);
|
||||
|
||||
if ($relation->via !== null) {
|
||||
|
||||
@ -694,20 +694,24 @@ class Connection extends Component
|
||||
{
|
||||
$pdoClass = $this->pdoClass;
|
||||
if ($pdoClass === null) {
|
||||
$pdoClass = 'PDO';
|
||||
$driver = null;
|
||||
if ($this->_driverName !== null) {
|
||||
$driver = $this->_driverName;
|
||||
} elseif (($pos = strpos($this->dsn, ':')) !== false) {
|
||||
$driver = strtolower(substr($this->dsn, 0, $pos));
|
||||
}
|
||||
if (isset($driver)) {
|
||||
if ($driver === 'mssql') {
|
||||
switch ($driver) {
|
||||
case 'mssql':
|
||||
$pdoClass = 'yii\db\mssql\PDO';
|
||||
} elseif ($driver === 'dblib') {
|
||||
break;
|
||||
case 'dblib':
|
||||
$pdoClass = 'yii\db\mssql\DBLibPDO';
|
||||
} elseif ($driver === 'sqlsrv') {
|
||||
break;
|
||||
case 'sqlsrv':
|
||||
$pdoClass = 'yii\db\mssql\SqlsrvPDO';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$pdoClass = 'PDO';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,18 +54,16 @@ class InConditionBuilder implements ExpressionBuilderInterface
|
||||
if (is_array($column)) {
|
||||
if (count($column) > 1) {
|
||||
return $this->buildCompositeInCondition($operator, $column, $values, $params);
|
||||
} else {
|
||||
$column = reset($column);
|
||||
}
|
||||
$column = reset($column);
|
||||
}
|
||||
|
||||
if ($column instanceof \Traversable) {
|
||||
if (iterator_count($column) > 1) {
|
||||
return $this->buildCompositeInCondition($operator, $column, $values, $params);
|
||||
} else {
|
||||
$column->rewind();
|
||||
$column = $column->current();
|
||||
}
|
||||
$column->rewind();
|
||||
$column = $column->current();
|
||||
}
|
||||
|
||||
if (is_array($values)) {
|
||||
@ -74,6 +72,8 @@ class InConditionBuilder implements ExpressionBuilderInterface
|
||||
$rawValues = $this->getRawValuesFromTraversableObject($values);
|
||||
}
|
||||
|
||||
$nullCondition = null;
|
||||
$nullConditionOperator = null;
|
||||
if (isset($rawValues) && in_array(null, $rawValues, true)) {
|
||||
$nullCondition = $this->getNullCondition($operator, $column);
|
||||
$nullConditionOperator = $operator === 'IN' ? 'OR' : 'AND';
|
||||
@ -81,7 +81,7 @@ class InConditionBuilder implements ExpressionBuilderInterface
|
||||
|
||||
$sqlValues = $this->buildValues($expression, $values, $params);
|
||||
if (empty($sqlValues)) {
|
||||
if (!isset($nullCondition)) {
|
||||
if ($nullCondition === null) {
|
||||
return $operator === 'IN' ? '0=1' : '';
|
||||
}
|
||||
return $nullCondition;
|
||||
@ -97,7 +97,9 @@ class InConditionBuilder implements ExpressionBuilderInterface
|
||||
$sql = $column . $operator . reset($sqlValues);
|
||||
}
|
||||
|
||||
return isset($nullCondition) ? sprintf('%s %s %s', $sql, $nullConditionOperator, $nullCondition) : $sql;
|
||||
return $nullCondition !== null && $nullConditionOperator !== null
|
||||
? sprintf('%s %s %s', $sql, $nullConditionOperator, $nullCondition)
|
||||
: $sql;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -11,6 +11,7 @@ use yii\base\InvalidArgumentException;
|
||||
use yii\base\NotSupportedException;
|
||||
use yii\db\Constraint;
|
||||
use yii\db\Expression;
|
||||
use yii\db\TableSchema;
|
||||
|
||||
/**
|
||||
* QueryBuilder is the query builder for MS SQL Server databases (version 2008 and above).
|
||||
@ -483,10 +484,11 @@ class QueryBuilder extends \yii\db\QueryBuilder
|
||||
$version2005orLater = version_compare($this->db->getSchema()->getServerVersion(), '9', '>=');
|
||||
|
||||
list($names, $placeholders, $values, $params) = $this->prepareInsertValues($table, $columns, $params);
|
||||
$cols = [];
|
||||
$columns = [];
|
||||
if ($version2005orLater) {
|
||||
/* @var $schema TableSchema */
|
||||
$schema = $this->db->getTableSchema($table);
|
||||
$cols = [];
|
||||
$columns = [];
|
||||
foreach ($schema->columns as $column) {
|
||||
if ($column->isComputed) {
|
||||
continue;
|
||||
|
||||
@ -394,9 +394,9 @@ SQL;
|
||||
}
|
||||
if (!empty($matches[2])) {
|
||||
$values = explode(',', $matches[2]);
|
||||
$column->size = $column->precision = (int)$values[0];
|
||||
$column->size = $column->precision = (int) $values[0];
|
||||
if (isset($values[1])) {
|
||||
$column->scale = (int)$values[1];
|
||||
$column->scale = (int) $values[1];
|
||||
}
|
||||
if ($column->size === 1 && ($type === 'tinyint' || $type === 'bit')) {
|
||||
$column->type = 'boolean';
|
||||
|
||||
@ -607,7 +607,7 @@ SQL;
|
||||
$column->precision = $info['numeric_precision'];
|
||||
$column->scale = $info['numeric_scale'];
|
||||
$column->size = $info['size'] === null ? null : (int) $info['size'];
|
||||
$column->dimension = (int)$info['dimension'];
|
||||
$column->dimension = (int) $info['dimension'];
|
||||
// pg_get_serial_sequence() doesn't track DEFAULT value change. GENERATED BY IDENTITY columns always have null default value
|
||||
if (isset($column->defaultValue) && preg_match("/nextval\\('\"?\\w+\"?\.?\"?\\w+\"?'(::regclass)?\\)/", $column->defaultValue) === 1) {
|
||||
$column->sequenceName = preg_replace(['/nextval/', '/::/', '/regclass/', '/\'\)/', '/\(\'/'], '', $column->defaultValue);
|
||||
|
||||
@ -66,10 +66,10 @@ class AccessRule extends Component
|
||||
* @see $roleParams
|
||||
*/
|
||||
public $roles;
|
||||
/**
|
||||
/**
|
||||
* @var array list of RBAC (Role-Based Access Control) permissions that this rules applies to.
|
||||
* [[User::can()]] will be called to check access.
|
||||
*
|
||||
*
|
||||
* If this property is not set or empty, it means this rule applies regardless of permissions.
|
||||
* @since 2.0.12
|
||||
* @see $roles
|
||||
@ -264,16 +264,17 @@ class AccessRule extends Component
|
||||
return true;
|
||||
}
|
||||
foreach ($this->ips as $rule) {
|
||||
if ($rule === '*' ||
|
||||
$rule === $ip ||
|
||||
(
|
||||
$ip !== null &&
|
||||
($pos = strpos($rule, '*')) !== false &&
|
||||
strncmp($ip, $rule, $pos) === 0
|
||||
) ||
|
||||
(
|
||||
($pos = strpos($rule, '/')) !== false &&
|
||||
IpHelper::inRange($ip, $rule) === true
|
||||
if (
|
||||
$rule === '*'
|
||||
|| $rule === $ip
|
||||
|| (
|
||||
$ip !== null
|
||||
&& ($pos = strpos($rule, '*')) !== false
|
||||
&& strncmp($ip, $rule, $pos) === 0
|
||||
)
|
||||
|| (
|
||||
strpos($rule, '/') !== false
|
||||
&& IpHelper::inRange($ip, $rule) === true
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
|
||||
@ -596,19 +596,15 @@ class BaseFileHelper
|
||||
|
||||
$path = str_replace('\\', '/', $path);
|
||||
|
||||
if (!empty($options['except'])) {
|
||||
if (($except = self::lastExcludeMatchingFromList($options['basePath'], $path, $options['except'])) !== null) {
|
||||
return $except['flags'] & self::PATTERN_NEGATIVE;
|
||||
}
|
||||
if (
|
||||
!empty($options['except'])
|
||||
&& ($except = self::lastExcludeMatchingFromList($options['basePath'], $path, $options['except'])) !== null
|
||||
) {
|
||||
return $except['flags'] & self::PATTERN_NEGATIVE;
|
||||
}
|
||||
|
||||
if (!empty($options['only']) && !is_dir($path)) {
|
||||
if (($except = self::lastExcludeMatchingFromList($options['basePath'], $path, $options['only'])) !== null) {
|
||||
// don't check PATTERN_NEGATIVE since those entries are not prefixed with !
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return self::lastExcludeMatchingFromList($options['basePath'], $path, $options['only']) !== null;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -218,11 +218,15 @@ class Logger extends Component
|
||||
return $timings;
|
||||
}
|
||||
|
||||
foreach ($timings as $i => $timing) {
|
||||
foreach ($timings as $outerIndex => $outerTimingItem) {
|
||||
$currentIndex = $outerIndex;
|
||||
$matched = empty($categories);
|
||||
foreach ($categories as $category) {
|
||||
$prefix = rtrim($category, '*');
|
||||
if (($timing['category'] === $category || $prefix !== $category) && strpos($timing['category'], $prefix) === 0) {
|
||||
if (
|
||||
($outerTimingItem['category'] === $category || $prefix !== $category)
|
||||
&& strpos($outerTimingItem['category'], $prefix) === 0
|
||||
) {
|
||||
$matched = true;
|
||||
break;
|
||||
}
|
||||
@ -231,8 +235,12 @@ class Logger extends Component
|
||||
if ($matched) {
|
||||
foreach ($excludeCategories as $category) {
|
||||
$prefix = rtrim($category, '*');
|
||||
foreach ($timings as $i => $timing) {
|
||||
if (($timing['category'] === $category || $prefix !== $category) && strpos($timing['category'], $prefix) === 0) {
|
||||
foreach ($timings as $innerIndex => $innerTimingItem) {
|
||||
$currentIndex = $innerIndex;
|
||||
if (
|
||||
($innerTimingItem['category'] === $category || $prefix !== $category)
|
||||
&& strpos($innerTimingItem['category'], $prefix) === 0
|
||||
) {
|
||||
$matched = false;
|
||||
break;
|
||||
}
|
||||
@ -241,7 +249,7 @@ class Logger extends Component
|
||||
}
|
||||
|
||||
if (!$matched) {
|
||||
unset($timings[$i]);
|
||||
unset($timings[$currentIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -109,7 +109,7 @@ class MultipartFormDataParser extends BaseObject implements RequestParserInterfa
|
||||
public function getUploadFileMaxCount()
|
||||
{
|
||||
if ($this->_uploadFileMaxCount === null) {
|
||||
$this->_uploadFileMaxCount = ini_get('max_file_uploads');
|
||||
$this->_uploadFileMaxCount = (int)ini_get('max_file_uploads');
|
||||
}
|
||||
|
||||
return $this->_uploadFileMaxCount;
|
||||
|
||||
@ -105,7 +105,7 @@ class Session extends Component implements \IteratorAggregate, \ArrayAccess, \Co
|
||||
*/
|
||||
private $_cookieParams = ['httponly' => true];
|
||||
/**
|
||||
* @var $frozenSessionData array|null is used for saving session between recreations due to session parameters update.
|
||||
* @var array|null is used for saving session between recreations due to session parameters update.
|
||||
*/
|
||||
private $frozenSessionData;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user