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

unsupported operand types int - string php 8.1 #1109

Closed
farmani opened this issue Jan 1, 2022 · 0 comments
Closed

unsupported operand types int - string php 8.1 #1109

farmani opened this issue Jan 1, 2022 · 0 comments

Comments

@farmani
Copy link
Contributor

farmani commented Jan 1, 2022

  • Horizon Version: 5.7.17
  • Laravel Version: 8.77.1
  • PHP Version: 8.1.0
  • Redis Driver & Version: predis/phpredis #.#.#
  • Database Driver & Version:

Description:

[2022-01-01 13:10:46] local.ERROR: Unsupported operand types: int - string {"exception":"[object] (TypeError(code: 0): Unsupported operand types: int - string at /var/www/html/vendor/laravel/horizon/src/Repositories/RedisMetricsRepository.php:338)
[stacktrace]
#0 /var/www/html/vendor/laravel/horizon/src/Repositories/RedisMetricsRepository.php(67): Laravel\\Horizon\\Repositories\\RedisMetricsRepository->minutesSinceLastSnapshot()
#1 /var/www/html/vendor/laravel/horizon/src/Http/Controllers/DashboardStatsController.php(22): Laravel\\Horizon\\Repositories\\RedisMetricsRepository->jobsProcessedPerMinute()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Laravel\\Horizon\\Http\\Controllers\\DashboardStatsController->index()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
/**
 * Get the number of minutes passed since the last snapshot.
 *
 * @return float
 */
protected function minutesSinceLastSnapshot()
{
    $lastSnapshotAt = $this->connection()->get('last_snapshot_at')
        ?: $this->storeSnapshotTimestamp();

    return max(
        (CarbonImmutable::now()->getTimestamp() - $lastSnapshotAt) / 60, 1
    );
}

it seems in the given block $lastSnapshotAt is string the workaround is casting it to int but the bug is probably in get() method which is probably return string value for last_snapshot_at and it must be converted to int

Steps To Reproduce:

farmani added a commit to farmani/horizon that referenced this issue Jan 1, 2022
taylorotwell added a commit that referenced this issue Jan 2, 2022
* Resolve issue with php strict type

related to the issue #1109

* Update RedisMetricsRepository.php

Co-authored-by: Taylor Otwell <[email protected]>
@farmani farmani closed this as completed Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant