Skip to content

Commit

Permalink
php 7.2 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicGD committed Mar 30, 2018
1 parent 7e3d2c2 commit ce0a7af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
10 changes: 4 additions & 6 deletions CacheActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ public function all($db = null)
if ($fromCache) {

$resultFromCache = [];
if($this->with)
{
if ($this->with) {
$primaryModel = reset($fromCache);
$relations = $this->normalizeRelations($primaryModel, $this->with);
/* @var $relation ActiveQuery */
foreach ($relations as $name => $relation)
{
foreach ($relations as $name => $relation) {
if ($relation->asArray === null) {
// inherit asArray from primary query
$relation->asArray($this->asArray);
Expand Down Expand Up @@ -193,7 +191,7 @@ private function insertInCache($key, $toCache)
private function generateCacheKey($sql, $mode)
{
$key = $mode . strtolower($this->modelClass) . $sql;
if (count($this->where) === 0 && count($this->dropConditions) === 0) {
if ((!$this->where || \count($this->where) === 0) && (!$this->dropConditions || \count($this->dropConditions) === 0)) {
$this->dropCacheOnCreate();
}
//pagination
Expand Down Expand Up @@ -331,7 +329,7 @@ private function fillDropConditions()
if (!array_key_exists($tableName, $this->dropConditions)) {
$this->dropConditions[$tableName] = [];
}
if (count($this->where) !== 0) {
if ($this->where && \count($this->where) !== 0) {
$where = $this->getParsedWhere();
foreach ($where as list($column, $operator, $value)) {
if (in_array(
Expand Down
21 changes: 10 additions & 11 deletions WhereParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function parseCondition($condition, $params)
/**
* Creates a condition based on column-value pairs.
* @param array $condition the condition specification.
* @param array $params the binding parameters to be populated
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
*/
public function parseHashCondition($condition, &$params)
Expand All @@ -83,7 +83,7 @@ public function parseHashCondition($condition, &$params)
* Connects two or more SQL expressions with the `AND` or `OR` operator.
* @param string $operator the operator to use for connecting the given operands
* @param array $operands the SQL expressions to connect.
* @param array $params the binding parameters to be populated
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
*/
public function parseAndCondition($operator, $operands, &$params)
Expand All @@ -101,7 +101,7 @@ public function parseAndCondition($operator, $operands, &$params)
* Inverts an SQL expressions with `NOT` operator.
* @param string $operator the operator to use for connecting the given operands
* @param array $operands the SQL expressions to connect.
* @param array $params the binding parameters to be populated
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
* @throws InvalidParamException if wrong number of operands have been given.
*/
Expand All @@ -115,8 +115,8 @@ public function parseNotCondition($operator, $operands, &$params)
* Creates an SQL expressions with the `BETWEEN` operator.
* @param string $operator the operator to use (e.g. `BETWEEN` or `NOT BETWEEN`)
* @param array $operands the first operand is the column name. The second and third operands
* describe the interval that column value should be in.
* @param array $params the binding parameters to be populated
* describe the interval that column value should be in.
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
* @throws InvalidParamException if wrong number of operands have been given.
*/
Expand Down Expand Up @@ -151,12 +151,11 @@ public function parseInCondition($operator, $operands, &$params)

$values = (array)$values;

if (count($column) > 1) {
return $this->parseCompositeInCondition($operator, $column, $values, $params);
}

if (is_array($column)) {
$column = reset($column);
if (\count($column) > 1) {
return $this->parseCompositeInCondition($operator, $column, $values, $params);
}
}
foreach ($values as $i => $value) {
if (is_array($value)) {
Expand Down Expand Up @@ -227,7 +226,7 @@ public function parseLikeCondition($operator, $operands, &$params)
* Creates an SQL expressions with the `EXISTS` operator.
* @param string $operator the operator to use (e.g. `EXISTS` or `NOT EXISTS`)
* @param array $operands contains only one element which is a [[Query]] object representing the sub-query.
* @param array $params the binding parameters to be populated
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
* @throws InvalidParamException if the operand is not a [[Query]] object.
*/
Expand All @@ -241,7 +240,7 @@ public function parseExistsCondition($operator, $operands, &$params)
* Creates an SQL expressions like `"column" operator value`.
* @param string $operator the operator to use. Anything could be used e.g. `>`, `<=`, etc.
* @param array $operands contains two column names.
* @param array $params the binding parameters to be populated
* @param array $params the binding parameters to be populated
* @return string the generated SQL expression
* @throws InvalidParamException if wrong number of operands have been given.
*/
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"minimum-stability": "stable",
"require": {
"php": ">=5.4.0",
"php": ">=7.0.0",
"yiisoft/yii2-redis": "~2.0.6"
},
"autoload": {
Expand Down

0 comments on commit ce0a7af

Please sign in to comment.