Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Divide By Zero Error After 11.43.0 Upgrade #54679

Closed
damiantw opened this issue Feb 18, 2025 · 4 comments · Fixed by #54685
Closed

Divide By Zero Error After 11.43.0 Upgrade #54679

damiantw opened this issue Feb 18, 2025 · 4 comments · Fixed by #54685
Labels

Comments

@damiantw
Copy link

Laravel Version

11.43.0

PHP Version

8.4

Database Driver & Version

PostgreSQL 15

Description

One of our tests started failing after receiving the Shift for Laravel v11.43.0.

We're seeing a divide-by-zero error in the LengthAwarePaginator constructor.

array:5 [
  "message" => "Division by zero"
  "exception" => "DivisionByZeroError"
  "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pagination/LengthAwarePaginator.php"
  "line" => 62
  "trace" => array:79 [
    0 => array:3 [
      "function" => "__construct"
      "class" => "Illuminate\Pagination\LengthAwarePaginator"
      "type" => "->"
    ]
    1 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Container/Container.php"
      "line" => 1004
      "function" => "newInstanceArgs"
      "class" => "ReflectionClass"
      "type" => "->"
    ]
    2 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Container/Container.php"
      "line" => 832
      "function" => "build"
      "class" => "Illuminate\Container\Container"
      "type" => "->"
    ]
    3 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
      "line" => 1078
      "function" => "resolve"
      "class" => "Illuminate\Container\Container"
      "type" => "->"
    ]
    4 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Container/Container.php"
      "line" => 763
      "function" => "resolve"
      "class" => "Illuminate\Foundation\Application"
      "type" => "->"
    ]
    5 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Application.php"
      "line" => 1058
      "function" => "make"
      "class" => "Illuminate\Container\Container"
      "type" => "->"
    ]
    6 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Container/Container.php"
      "line" => 747
      "function" => "make"
      "class" => "Illuminate\Foundation\Application"
      "type" => "->"
    ]
    7 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Database/Concerns/BuildsQueries.php"
      "line" => 529
      "function" => "makeWith"
      "class" => "Illuminate\Container\Container"
      "type" => "->"
    ]
    8 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php"
      "line" => 1037
      "function" => "paginator"
      "class" => "Illuminate\Database\Eloquent\Builder"
      "type" => "->"
    ]
    9 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/app/Repositories/LoanRepository.php"
      "line" => 52
      "function" => "paginate"
      "class" => "Illuminate\Database\Eloquent\Builder"
      "type" => "->"
    ]
    10 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/app/Http/Controllers/LoanController.php"
      "line" => 60
      "function" => "historicalPaginated"
      "class" => "App\Repositories\LoanRepository"
      "type" => "->"
    ]
    11 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php"
      "line" => 47
      "function" => "index"
      "class" => "App\Http\Controllers\LoanController"
      "type" => "->"
    ]
    12 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Route.php"
      "line" => 266
      "function" => "dispatch"
      "class" => "Illuminate\Routing\ControllerDispatcher"
      "type" => "->"
    ]
    13 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Route.php"
      "line" => 212
      "function" => "runController"
      "class" => "Illuminate\Routing\Route"
      "type" => "->"
    ]
    14 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Router.php"
      "line" => 808
      "function" => "run"
      "class" => "Illuminate\Routing\Route"
      "type" => "->"
    ]
    15 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 170
      "function" => "{closure:Illuminate\Routing\Router::runRouteWithinStack():807}"
      "class" => "Illuminate\Routing\Router"
      "type" => "->"
    ]
    16 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php"
      "line" => 202
      "function" => "{closure:Illuminate\Pipeline\Pipeline::prepareDestination():168}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    17 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "class@anonymous\x00/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php:198$d7"
      "type" => "->"
    ]
    18 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php"
      "line" => 51
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    19 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Routing\Middleware\SubstituteBindings"
      "type" => "->"
    ]
    20 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequestsWithRedis.php"
      "line" => 65
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    21 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php"
      "line" => 127
      "function" => "handleRequest"
      "class" => "Illuminate\Routing\Middleware\ThrottleRequestsWithRedis"
      "type" => "->"
    ]
    22 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php"
      "line" => 89
      "function" => "handleRequestUsingNamedLimiter"
      "class" => "Illuminate\Routing\Middleware\ThrottleRequests"
      "type" => "->"
    ]
    23 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Routing\Middleware\ThrottleRequests"
      "type" => "->"
    ]
    24 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php"
      "line" => 64
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    25 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Auth\Middleware\Authenticate"
      "type" => "->"
    ]
    26 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 127
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    27 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Router.php"
      "line" => 807
      "function" => "then"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    28 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Router.php"
      "line" => 786
      "function" => "runRouteWithinStack"
      "class" => "Illuminate\Routing\Router"
      "type" => "->"
    ]
    29 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Router.php"
      "line" => 750
      "function" => "runRoute"
      "class" => "Illuminate\Routing\Router"
      "type" => "->"
    ]
    30 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Routing/Router.php"
      "line" => 739
      "function" => "dispatchToRoute"
      "class" => "Illuminate\Routing\Router"
      "type" => "->"
    ]
    31 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php"
      "line" => 201
      "function" => "dispatch"
      "class" => "Illuminate\Routing\Router"
      "type" => "->"
    ]
    32 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 170
      "function" => "{closure:Illuminate\Foundation\Http\Kernel::dispatchToRouter():198}"
      "class" => "Illuminate\Foundation\Http\Kernel"
      "type" => "->"
    ]
    33 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/vapor-core/src/Http/Middleware/ServeStaticAssets.php"
      "line" => 21
      "function" => "{closure:Illuminate\Pipeline\Pipeline::prepareDestination():168}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    34 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Laravel\Vapor\Http\Middleware\ServeStaticAssets"
      "type" => "->"
    ]
    35 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/app/Http/Monitor/Monitoring.php"
      "line" => 21
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    36 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "App\Http\Monitor\Monitoring"
      "type" => "->"
    ]
    37 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/app/Http/Middleware/PotentiallyRecordRequestingDevice.php"
      "line" => 28
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    38 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 210
      "function" => "__invoke"
      "class" => "App\Http\Middleware\PotentiallyRecordRequestingDevice"
      "type" => "->"
    ]
    39 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php"
      "line" => 21
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    40 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php"
      "line" => 31
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Middleware\TransformsRequest"
      "type" => "->"
    ]
    41 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull"
      "type" => "->"
    ]
    42 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php"
      "line" => 21
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    43 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php"
      "line" => 51
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Middleware\TransformsRequest"
      "type" => "->"
    ]
    44 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Middleware\TrimStrings"
      "type" => "->"
    ]
    45 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php"
      "line" => 27
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    46 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Http\Middleware\ValidatePostSize"
      "type" => "->"
    ]
    47 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php"
      "line" => 110
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    48 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance"
      "type" => "->"
    ]
    49 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php"
      "line" => 62
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    50 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Http\Middleware\HandleCors"
      "type" => "->"
    ]
    51 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php"
      "line" => 58
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    52 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Http\Middleware\TrustProxies"
      "type" => "->"
    ]
    53 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/InvokeDeferredCallbacks.php"
      "line" => 22
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    54 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 209
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Middleware\InvokeDeferredCallbacks"
      "type" => "->"
    ]
    55 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php"
      "line" => 127
      "function" => "{closure:{closure:Illuminate\Pipeline\Pipeline::carry():184}:185}"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    56 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php"
      "line" => 176
      "function" => "then"
      "class" => "Illuminate\Pipeline\Pipeline"
      "type" => "->"
    ]
    57 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php"
      "line" => 145
      "function" => "sendRequestThroughRouter"
      "class" => "Illuminate\Foundation\Http\Kernel"
      "type" => "->"
    ]
    58 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php"
      "line" => 607
      "function" => "handle"
      "class" => "Illuminate\Foundation\Http\Kernel"
      "type" => "->"
    ]
    59 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php"
      "line" => 573
      "function" => "call"
      "class" => "Illuminate\Foundation\Testing\TestCase"
      "type" => "->"
    ]
    60 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php"
      "line" => 381
      "function" => "json"
      "class" => "Illuminate\Foundation\Testing\TestCase"
      "type" => "->"
    ]
    61 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/tests/Feature/Http/Controllers/LoanControllerTest.php"
      "line" => 96
      "function" => "getJson"
      "class" => "Illuminate\Foundation\Testing\TestCase"
      "type" => "->"
    ]
    62 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Factories/TestCaseMethodFactory.php"
      "line" => 168
      "function" => "{closure:/Users/damian/PhpstormProjects/core-flex/tests/Feature/Http/Controllers/LoanControllerTest.php:39}"
      "class" => "P\Tests\Feature\Http\Controllers\LoanControllerTest"
      "type" => "->"
    ]
    63 => array:3 [
      "function" => "{closure:Pest\Factories\TestCaseMethodFactory::getClosure():158}"
      "class" => "P\Tests\Feature\Http\Controllers\LoanControllerTest"
      "type" => "->"
    ]
    64 => array:3 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Concerns/Testable.php"
      "line" => 419
      "function" => "call_user_func_array"
    ]
    65 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Support/ExceptionTrace.php"
      "line" => 26
      "function" => "{closure:Pest\Concerns\Testable::__callClosure():419}"
      "class" => "P\Tests\Feature\Http\Controllers\LoanControllerTest"
      "type" => "->"
    ]
    66 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Concerns/Testable.php"
      "line" => 419
      "function" => "ensure"
      "class" => "Pest\Support\ExceptionTrace"
      "type" => "::"
    ]
    67 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Concerns/Testable.php"
      "line" => 321
      "function" => "__callClosure"
      "class" => "P\Tests\Feature\Http\Controllers\LoanControllerTest"
      "type" => "->"
    ]
    68 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Factories/TestCaseFactory.php(169) : eval()'d code"
      "line" => 17
      "function" => "__runTest"
      "class" => "P\Tests\Feature\Http\Controllers\LoanControllerTest"
      "type" => "->"
    ]
    69 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/Framework/TestCase.php"
      "line" => 1235
      "function" => "__pest_evaluable_approve_originate_and_instant_disburse_loan"
      "class" => "P\Tests\Feature\Http\Controllers\LoanControllerTest"
      "type" => "->"
    ]
    70 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/Framework/TestCase.php"
      "line" => 514
      "function" => "runTest"
      "class" => "PHPUnit\Framework\TestCase"
      "type" => "->"
    ]
    71 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/Framework/TestRunner/TestRunner.php"
      "line" => 87
      "function" => "runBare"
      "class" => "PHPUnit\Framework\TestCase"
      "type" => "->"
    ]
    72 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/Framework/TestCase.php"
      "line" => 361
      "function" => "run"
      "class" => "PHPUnit\Framework\TestRunner"
      "type" => "->"
    ]
    73 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/Framework/TestSuite.php"
      "line" => 369
      "function" => "run"
      "class" => "PHPUnit\Framework\TestCase"
      "type" => "->"
    ]
    74 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/TextUI/TestRunner.php"
      "line" => 64
      "function" => "run"
      "class" => "PHPUnit\Framework\TestSuite"
      "type" => "->"
    ]
    75 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/phpunit/phpunit/src/TextUI/Application.php"
      "line" => 210
      "function" => "run"
      "class" => "PHPUnit\TextUI\TestRunner"
      "type" => "->"
    ]
    76 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/src/Kernel.php"
      "line" => 103
      "function" => "run"
      "class" => "PHPUnit\TextUI\Application"
      "type" => "->"
    ]
    77 => array:5 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/bin/pest"
      "line" => 184
      "function" => "handle"
      "class" => "Pest\Kernel"
      "type" => "->"
    ]
    78 => array:3 [
      "file" => "/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/bin/pest"
      "line" => 192
      "function" => "{closure:/Users/damian/PhpstormProjects/core-flex/vendor/pestphp/pest/bin/pest:18}"
    ]
  ]
]

This commit seems to be the culprit.

If I manually change the line in src/Illuminate/Database/Eloquent/Builder.php

from...

$perPage = value($perPage, $total) ?? $this->model->getPerPage();

to

$perPage = value($perPage, $total) ?: $this->model->getPerPage();

the test passes.

Steps To Reproduce

Call paginate on an Eloquent query without results on 11.43.0.

@yvoitenko
Copy link

same here, hoping for a fix soon

@rodrigopedra
Copy link
Contributor

@damiantw I am the author of PR #54650 which introduced this bug. Sorry for the inconvenience.

I even commented that changing the ?: operator by the ?? could be a breaking change in theory, but it seemed to me very unlikely to happen. Anyway, this change is already fixed (thanks @crynobone !).

Out of curiosity, could you share the test case which triggered this error?

We could use it to add a test case directly to the framework and prevent any regressions in the future.

Thanks in advance!

@damiantw
Copy link
Author

Hi @rodrigopedra, no problem at all.

Our test calls a controller that executes a pagination query along the lines of the following.

    public function myFunc(Request $request)
    {
        return Loan::query()
            ->where('user_id', $request->user()->id)
            ->paginate($request->integer('perPage'));
    }

So, if the perPage parameter is omitted from the request, we're passing zero to paginate.

Arguably, we should provide a default so we're never passing zero, but that was the reason ?? broke our test.

test('paginate with zero per page', function () {
    expect(Loan::query()->paginate((int) null)->isEmpty())->toBeTrue();
});

^ this test fails on 11.43.0 but passes with patch 1af7e22

@rodrigopedra
Copy link
Contributor

Thanks for sharing, I will try sending a PR to add a test case to prevent future regressions, although I will only be able to do it later this week.

If you want to send a PR before, covering this, be my guest.

The issue is patched on v11.43.1, thanks for sharing, and please apologize for the inconvenience.

Have a nice day =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants