Outils pour utilisateurs

Outils du site


devweb:laravel:upgrade (lu 10759 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
ligne: 876

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 771:
count(): Parameter must be an array or an object that implements Countable
vi vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php
ligne: 771

cherche

 769     public function addNestedWhereQuery($query, $boolean = 'and')
 770     {
 771         if (count($query->wheres)) {
 772             $type = 'Nested';
 773
 774             $this->wheres[] = compact('type', 'query', 'boolean');
 775
 776             $this->addBinding($query->getBindings(), 'where');
 777         }
 778
 779         return $this;
 780     }

et remplace

 769     public function addNestedWhereQuery($query, $boolean = 'and')
 770     {
 771         if (count((array)$query->wheres)) {
 772             $type = 'Nested';
 773
 774             $this->wheres[] = compact('type', 'query', 'boolean');
 775
 776             $this->addBinding($query->getBindings(), 'where');
 777         }
 778
 779         return $this;
 780     }
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
ligne: 1231

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     }
ErrorException in Collection.php line 1099:
A non-numeric value encountered
vi vendor/laravel/framework/src/Illuminate/Support/Collection.php
ligne: 1099

cherche

1090     public function sum($callback = null)
1091     {
1092         if (is_null($callback)) {
1093             return array_sum($this->items);
1094         }
1095
1096         $callback = $this->valueRetriever($callback);
1097
1098         return $this->reduce(function ($result, $item) use ($callback) {
1099             return $result + $callback($item);
1100         }, 0);
1101     }

remplace

1090     public function sum($callback = null)
1091     {
1092         if (is_null($callback)) {
1093             return array_sum($this->items);
1094         }
1095
1096         $callback = $this->valueRetriever($callback);
1097
1098         return $this->reduce(function ($result, $item) use ($callback) {
1099             return (int)$result + (int)$callback($item);
1100         }, 0);
1101     }
devweb/laravel/upgrade.1618235270.txt.gz · Dernière modification: 12-04-2021 15:47 de edmc73