Outils pour utilisateurs

Outils du site


devweb:laravel:upgrade (lu 10748 fois)

Ceci est une ancienne révision du document !


Upgrade

Sur changement de version de php

ErrorException in Builder.php line 876:
compact(): Undefined variable: operator
vi vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php

cherche

 872     public function addWhereExistsQuery(Builder $query, $boolean = 'and', $not = false)
 873     {
 874         $type = $not ? 'NotExists' : 'Exists';
 875
 876         $this->wheres[] = compact('type', 'operator', 'query', 'boolean');
 877
 878         $this->addBinding($query->getBindings(), 'where');
 879
 880         return $this;
 881     }

et remplace

 872     public function addWhereExistsQuery(Builder $query, $boolean = 'and', $not = false)
 873     {
 874         $type = $not ? 'NotExists' : 'Exists';
 875
 876         $this->wheres[] = compact('type', 'query', 'boolean');
 877
 878         $this->addBinding($query->getBindings(), 'where');
 879
 880         return $this;
 881     }
ErrorException in Builder.php line 1231:
count(): Parameter must be an array or an object that implements Countable
vi vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php

cherche

1222     protected function callScope(callable $scope, $parameters = [])
1223     {
1224         array_unshift($parameters, $this);
1225
1226         $query = $this->getQuery();
1227
1228         // We will keep track of how many wheres are on the query before running the
1229         // scope so that we can properly group the added scope constraints in the
1230         // query as their own isolated nested where statement and avoid issues.
1231         $originalWhereCount = count($query->wheres);
1232
1233         $result = $scope(...array_values($parameters)) ?: $this;
1234
1235         if ($this->shouldNestWheresForScope($query, $originalWhereCount)) {
1236             $this->nestWheresForScope($query, $originalWhereCount);
1237         }
1238
1239         return $result;
1240     }

et remplace

1222     protected function callScope(callable $scope, $parameters = [])
1223     {
1224         array_unshift($parameters, $this);
1225
1226         $query = $this->getQuery();
1227
1228         // We will keep track of how many wheres are on the query before running the
1229         // scope so that we can properly group the added scope constraints in the
1230         // query as their own isolated nested where statement and avoid issues.
1231         $originalWhereCount = count((array)$query->wheres);
1232
1233         $result = $scope(...array_values($parameters)) ?: $this;
1234
1235         if ($this->shouldNestWheresForScope($query, $originalWhereCount)) {
1236             $this->nestWheresForScope($query, $originalWhereCount);
1237         }
1238
1239         return $result;
1240     }
devweb/laravel/upgrade.1618214776.txt.gz · Dernière modification: 12-04-2021 10:06 de edmc73