cp6 / my-idlers

Web app for displaying, organizing and storing information about servers (VPS), shared hosting, reseller hosting, domains and more.
https://demo.myidlers.com
MIT License
213 stars 30 forks source link

Failed to add YABS result #75

Closed imlonghao closed 1 year ago

imlonghao commented 1 year ago

Trackback

TypeError:
App\Models\Settings::orderByProcess(): Argument #1 ($value) must be of type int, null given, called in /**REDACTED**/app/Models/Server.php on line 36

  at /**REDACTED**/app/Models/Settings.php:48
  at App\Models\Settings::orderByProcess()
     (/**REDACTED**/app/Models/Server.php:36)
  at App\Models\Server::App\Models\{closure}()
     (/**REDACTED**/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1267)
...

For those API requests, they didn't init Session data so Session::get('sort_on') will be null

https://github.com/cp6/my-idlers/blob/d0d2cc71ace07d3fd24feed890b19faffa64f5dd/app/Models/Server.php#L36

I manually modify this line to the following, then YABS result can be added successfully.

$array = Settings::orderByProcess(Session::get('sort_on') ? Session::get('sort_on') != null : 1)
cp6 commented 1 year ago

Thanks for a solution i altered it slightly https://github.com/cp6/my-idlers/commit/10e2d7dbbabee7ad787f67c6f009fc5acb5f0ad9