From 77ee96bb9d4e37702dde9b5dc1f75cdb6731d07c Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 26 Apr 2024 22:40:03 +0200 Subject: [PATCH] Update to carbon 3 --- Blacklight/Backfill.php | 2 +- Blacklight/Binaries.php | 16 +-- Blacklight/Music.php | 2 +- Blacklight/NameFixer.php | 2 +- Blacklight/ReleaseRemover.php | 4 +- Blacklight/libraries/Forking.php | 2 +- Blacklight/processing/ProcessReleases.php | 18 +-- app/Models/User.php | 2 +- composer.json | 2 +- composer.lock | 160 ++++++++++++++++------ misc/testing/Releases/recategorize.php | 2 +- misc/update/tmux/bin/update_groups.php | 2 +- 12 files changed, 143 insertions(+), 71 deletions(-) diff --git a/Blacklight/Backfill.php b/Blacklight/Backfill.php index 141a752d8..be71f1944 100755 --- a/Blacklight/Backfill.php +++ b/Blacklight/Backfill.php @@ -103,7 +103,7 @@ class Backfill $counter++; } - $dMessage = 'Backfilling completed in '.now()->diffInSeconds($allTime).' seconds.'; + $dMessage = 'Backfilling completed in '.now()->diffInSeconds($allTime, true).' seconds.'; if ($this->_echoCLI) { $this->colorCli->primary($dMessage); diff --git a/Blacklight/Binaries.php b/Blacklight/Binaries.php index 9bd0df9bc..e090f7caf 100644 --- a/Blacklight/Binaries.php +++ b/Blacklight/Binaries.php @@ -227,7 +227,7 @@ class Binaries $counter++; } - $endTime = now()->diffInSeconds($allTime); + $endTime = now()->diffInSeconds($allTime, true); $this->log( 'Updating completed in '.$endTime.Str::plural(' second', $endTime), __FUNCTION__, @@ -458,7 +458,7 @@ class Binaries } if ($this->_echoCLI) { - $endGroup = now()->diffInSeconds($startGroup); + $endGroup = now()->diffInSeconds($startGroup, true); $this->colorCli->primary( PHP_EOL.'Group '.$groupMySQL['name'].' processed in '. $endGroup.Str::plural(' second', $endGroup) @@ -547,7 +547,7 @@ class Binaries $this->startCleaning = now(); // End of the getting data from usenet. - $this->timeHeaders = $this->startCleaning->diffInSeconds($this->startLoop); + $this->timeHeaders = $this->startCleaning->diffInSeconds($this->startLoop, true); // Check if we got headers. $msgCount = \count($headers); @@ -636,7 +636,7 @@ class Binaries $this->startPR = now(); // End of inserting. - $this->timeInsert = $this->startPR->diffInSeconds($this->startUpdate); + $this->timeInsert = $this->startPR->diffInSeconds($this->startUpdate, true); if ($partRepair && \count($headersRepaired) > 0) { $this->removeRepairedParts($headersRepaired, $this->groupMySQL['id']); @@ -853,7 +853,7 @@ class Binaries $this->startUpdate = now(); // End of processing headers. - $this->timeCleaning = $this->startUpdate->diffInSeconds($this->startCleaning); + $this->timeCleaning = $this->startUpdate->diffInSeconds($this->startCleaning, true); $binariesQuery = $binariesCheck = 'INSERT INTO binaries (id, partsize, currentparts) VALUES '; foreach ($binariesUpdate as $binaryID => $binary) { $binariesQuery .= '('.$binaryID.','.$binary['Size'].','.$binary['Parts'].'),'; @@ -944,9 +944,9 @@ class Binaries $this->colorCli->primaryOver(' to process collections, '). $this->colorCli->alternateOver($this->timeInsert.'s'). $this->colorCli->primaryOver(' to insert binaries/parts, '). - $this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startPR).'s'). + $this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startPR, true).'s'). $this->colorCli->primaryOver(' for part repair, '). - $this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startLoop).'s'). + $this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startLoop, true).'s'). $this->colorCli->primary(' total.'); } } @@ -1236,7 +1236,7 @@ class Binaries if ($this->_echoCLI) { $this->colorCli->primary( PHP_EOL.'Found article #'.$wantedArticle.' which has a date of '.date('r', $articleTime). - ', vs wanted date of '.date('r', $goalTime).'. Difference from goal is '.Carbon::createFromTimestamp($goalTime)->diffInDays(Carbon::createFromTimestamp($articleTime)).'days.' + ', vs wanted date of '.date('r', $goalTime).'. Difference from goal is '.Carbon::createFromTimestamp($goalTime)->diffInDays(Carbon::createFromTimestamp($articleTime), true).'days.' ); } diff --git a/Blacklight/Music.php b/Blacklight/Music.php index c0111bacf..0b7868463 100755 --- a/Blacklight/Music.php +++ b/Blacklight/Music.php @@ -452,7 +452,7 @@ class Music // Sleep to not flood amazon. $sleeptime = $this->sleeptime / 1000; - $diff = now()->diffInSeconds($startTime); + $diff = now()->diffInSeconds($startTime, true); if ($sleeptime - $diff > 0 && $usedAmazon === true) { sleep($sleeptime - $diff); } diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index f46b31193..2fe3b6b8c 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -1125,7 +1125,7 @@ class NameFixer $this->colorCLI->climate()->info('Renamed Releases: ['.number_format($counted).'] '.(new ConsoleTools())->percentString(++$counter, $total)); } } - $this->colorCLI->climate()->info(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart).' seconds'.'.'); + $this->colorCLI->climate()->info(PHP_EOL.'Renamed '.number_format($counted).' releases in '.now()->diffInSeconds($timeStart, true).' seconds'.'.'); } else { $this->colorCLI->climate()->info('Nothing to do.'); } diff --git a/Blacklight/ReleaseRemover.php b/Blacklight/ReleaseRemover.php index 04baea3ab..134d05ca7 100755 --- a/Blacklight/ReleaseRemover.php +++ b/Blacklight/ReleaseRemover.php @@ -119,7 +119,7 @@ class ReleaseRemover if ($this->echoCLI) { $this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for '); - $this->colorCLI->header(now()->diffInSeconds($timeStart).' seconds', true); + $this->colorCLI->header(now()->diffInSeconds($timeStart, true).' seconds', true); } return true; @@ -239,7 +239,7 @@ class ReleaseRemover if ($this->echoCLI) { $this->colorCLI->headerOver(($this->delete ? 'Deleted ' : 'Would have deleted ').$this->deletedCount.' release(s). This script ran for '); - $this->colorCLI->header(now()->diffInSeconds($timeStart).' seconds', true); + $this->colorCLI->header(now()->diffInSeconds($timeStart, true).' seconds', true); } return true; diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index e8bd77e70..b1d900221 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -323,7 +323,7 @@ class Forking if ($backfill_days === 1) { $backfilldays = 'g.backfill_target'; } elseif ($backfill_days === 2) { - $backfilldays = now()->diffInDays(Carbon::createFromFormat('Y-m-d', Settings::settingValue('..safebackfilldate'))); + $backfilldays = now()->diffInDays(Carbon::createFromFormat('Y-m-d', Settings::settingValue('..safebackfilldate')), true); } $data = DB::select( diff --git a/Blacklight/processing/ProcessReleases.php b/Blacklight/processing/ProcessReleases.php index 2c48d9ff7..4e7fc45e6 100755 --- a/Blacklight/processing/ProcessReleases.php +++ b/Blacklight/processing/ProcessReleases.php @@ -236,7 +236,7 @@ class ProcessReleases } $count = $countQuery->count('id'); - $totalTime = now()->diffInSeconds($startTime); + $totalTime = now()->diffInSeconds($startTime, true); $this->colorCLI->primary( ($count ?? 0).' collections were found to be complete. Time: '. @@ -282,7 +282,7 @@ class ProcessReleases $checked.' collections set to filecheck = 3(size calculated)', true ); - $totalTime = now()->diffInSeconds($startTime); + $totalTime = now()->diffInSeconds($startTime, true); $this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime), true); } }, 10); @@ -366,7 +366,7 @@ class ProcessReleases } } - $totalTime = now()->diffInSeconds($startTime); + $totalTime = now()->diffInSeconds($startTime, true); if ($this->echoCLI) { $this->colorCLI->primary('Deleted '.($minSizeDeleted + $maxSizeDeleted + $minFilesDeleted).' collections: '.PHP_EOL.$minSizeDeleted.' smaller than, '.$maxSizeDeleted.' bigger than, '.$minFilesDeleted.' with less files than site/group settings in: '.$totalTime.Str::plural(' second', $totalTime), true); @@ -535,7 +535,7 @@ class ProcessReleases } } - $totalTime = now()->diffInSeconds($startTime); + $totalTime = now()->diffInSeconds($startTime, true); if ($this->echoCLI) { $this->colorCLI->primary( @@ -587,7 +587,7 @@ class ProcessReleases } } - $totalTime = now()->diffInSeconds($startTime); + $totalTime = now()->diffInSeconds($startTime, true); if ($this->echoCLI) { $this->colorCLI->primary( @@ -625,7 +625,7 @@ class ProcessReleases $groupID ); - $totalTime = now()->diffInSeconds($startTime); + $totalTime = now()->diffInSeconds($startTime, true); if ($this->echoCLI) { $this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime)); @@ -682,7 +682,7 @@ class ProcessReleases } $firstQuery = $fourthQuery = now(); - $totalTime = $firstQuery->diffInSeconds($startTime); + $totalTime = $firstQuery->diffInSeconds($startTime, true); if ($this->echoCLI) { $this->colorCLI->primary( @@ -729,8 +729,8 @@ class ProcessReleases } $deletedCount += $deleted; - $colDelTime = now()->diffInSeconds($fourthQuery); - $totalTime = $fourthQuery->diffInSeconds($startTime); + $colDelTime = now()->diffInSeconds($fourthQuery, true); + $totalTime = $fourthQuery->diffInSeconds($startTime, true); if ($this->echoCLI) { $this->colorCLI->primary('Finished deleting '.$deleted.' collections missed after NZB creation in '.$colDelTime.Str::plural(' second', $colDelTime).PHP_EOL.'Removed '.number_format($deletedCount).' parts/binaries/collection rows in '.$totalTime.Str::plural(' second', $totalTime), true); diff --git a/app/Models/User.php b/app/Models/User.php index e58b60243..8e0cbba2b 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -363,7 +363,7 @@ class User extends Authenticatable foreach ($period as $value) { $users = self::query()->whereDate('rolechangedate', '=', $value)->get(); - $days = $now->diffInDays($value); + $days = $now->diffInDays($value, true); foreach ($users as $user) { SendAccountWillExpireEmail::dispatch($user, $days)->onQueue('emails'); } diff --git a/composer.json b/composer.json index 67280c30f..b00113930 100644 --- a/composer.json +++ b/composer.json @@ -82,7 +82,7 @@ "monicahq/laravel-cloudflare": "^3.5", "monolog/monolog": "^3.5", "mtownsend/xml-to-array": "^2.0", - "nesbot/carbon": "^2.71", + "nesbot/carbon": "^3.3", "opis/closure": "^3.6", "pear/net_nntp": "^1.6.0", "php-ffmpeg/php-ffmpeg": "^1.2", diff --git a/composer.lock b/composer.lock index 600667a49..7a738dc53 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c2de2786c7fe4baa536f6a0c177f329b", + "content-hash": "10739567a859ba1f69e3fd9b1e562e36", "packages": [ { "name": "aharen/omdbapi", @@ -5659,42 +5659,41 @@ }, { "name": "nesbot/carbon", - "version": "2.72.3", + "version": "3.3.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83" + "reference": "7219739c4e01d4680c980545821733b6ed8ee880" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/0c6fd108360c562f6e4fd1dedb8233b423e91c83", - "reference": "0c6fd108360c562f6e4fd1dedb8233b423e91c83", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/7219739c4e01d4680c980545821733b6ed8ee880", + "reference": "7219739c4e01d4680c980545821733b6ed8ee880", "shasum": "" }, "require": { "carbonphp/carbon-doctrine-types": "*", "ext-json": "*", - "php": "^7.1.8 || ^8.0", + "php": "^8.1", "psr/clock": "^1.0", + "symfony/clock": "^6.3 || ^7.0", "symfony/polyfill-mbstring": "^1.0", - "symfony/polyfill-php80": "^1.16", - "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" + "symfony/translation": "^4.4.18 || ^5.2.1|| ^6.0 || ^7.0" }, "provide": { "psr/clock-implementation": "1.0" }, "require-dev": { - "doctrine/dbal": "^2.0 || ^3.1.4 || ^4.0", - "doctrine/orm": "^2.7 || ^3.0", - "friendsofphp/php-cs-fixer": "^3.0", - "kylekatarnls/multi-tester": "^2.0", - "ondrejmirtes/better-reflection": "*", - "phpmd/phpmd": "^2.9", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^0.12.99 || ^1.7.14", - "phpunit/php-file-iterator": "^2.0.5 || ^3.0.6", - "phpunit/phpunit": "^7.5.20 || ^8.5.26 || ^9.5.20", - "squizlabs/php_codesniffer": "^3.4" + "doctrine/dbal": "^3.6.3 || ^4.0", + "doctrine/orm": "^2.15.2 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.52.1", + "kylekatarnls/multi-tester": "^2.5.3", + "ondrejmirtes/better-reflection": "^6.25.0.4", + "phpmd/phpmd": "^2.15.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.10.65", + "phpunit/phpunit": "^10.5.15", + "squizlabs/php_codesniffer": "^3.9.0" }, "bin": [ "bin/carbon" @@ -5702,8 +5701,8 @@ "type": "library", "extra": { "branch-alias": { - "dev-3.x": "3.x-dev", - "dev-master": "2.x-dev" + "dev-master": "3.x-dev", + "dev-2.x": "2.x-dev" }, "laravel": { "providers": [ @@ -5762,7 +5761,7 @@ "type": "tidelift" } ], - "time": "2024-01-25T10:35:09+00:00" + "time": "2024-04-18T16:35:06+00:00" }, { "name": "nette/schema", @@ -10420,6 +10419,80 @@ ], "time": "2024-01-23T13:51:25+00:00" }, + { + "name": "symfony/clock", + "version": "v7.0.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/clock.git", + "reference": "8b9d08887353d627d5f6c3bf3373b398b49051c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/clock/zipball/8b9d08887353d627d5f6c3bf3373b398b49051c2", + "reference": "8b9d08887353d627d5f6c3bf3373b398b49051c2", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/clock": "^1.0", + "symfony/polyfill-php83": "^1.28" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/now.php" + ], + "psr-4": { + "Symfony\\Component\\Clock\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Decouples applications from the system clock", + "homepage": "https://symfony.com", + "keywords": [ + "clock", + "psr20", + "time" + ], + "support": { + "source": "https://github.com/symfony/clock/tree/v7.0.5" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-03-02T12:46:12+00:00" + }, { "name": "symfony/console", "version": "v7.0.6", @@ -13027,33 +13100,32 @@ }, { "name": "symfony/translation", - "version": "v6.4.4", + "version": "v7.0.4", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "bce6a5a78e94566641b2594d17e48b0da3184a8e" + "reference": "5b75e872f7d135d7abb4613809fadc8d9f3d30a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/bce6a5a78e94566641b2594d17e48b0da3184a8e", - "reference": "bce6a5a78e94566641b2594d17e48b0da3184a8e", + "url": "https://api.github.com/repos/symfony/translation/zipball/5b75e872f7d135d7abb4613809fadc8d9f3d30a0", + "reference": "5b75e872f7d135d7abb4613809fadc8d9f3d30a0", "shasum": "" }, "require": { - "php": ">=8.1", - "symfony/deprecation-contracts": "^2.5|^3", + "php": ">=8.2", "symfony/polyfill-mbstring": "~1.0", "symfony/translation-contracts": "^2.5|^3.0" }, "conflict": { - "symfony/config": "<5.4", - "symfony/console": "<5.4", - "symfony/dependency-injection": "<5.4", + "symfony/config": "<6.4", + "symfony/console": "<6.4", + "symfony/dependency-injection": "<6.4", "symfony/http-client-contracts": "<2.5", - "symfony/http-kernel": "<5.4", + "symfony/http-kernel": "<6.4", "symfony/service-contracts": "<2.5", - "symfony/twig-bundle": "<5.4", - "symfony/yaml": "<5.4" + "symfony/twig-bundle": "<6.4", + "symfony/yaml": "<6.4" }, "provide": { "symfony/translation-implementation": "2.3|3.0" @@ -13061,17 +13133,17 @@ "require-dev": { "nikic/php-parser": "^4.18|^5.0", "psr/log": "^1|^2|^3", - "symfony/config": "^5.4|^6.0|^7.0", - "symfony/console": "^5.4|^6.0|^7.0", - "symfony/dependency-injection": "^5.4|^6.0|^7.0", - "symfony/finder": "^5.4|^6.0|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", "symfony/http-client-contracts": "^2.5|^3.0", - "symfony/http-kernel": "^5.4|^6.0|^7.0", - "symfony/intl": "^5.4|^6.0|^7.0", + "symfony/http-kernel": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", "symfony/polyfill-intl-icu": "^1.21", - "symfony/routing": "^5.4|^6.0|^7.0", + "symfony/routing": "^6.4|^7.0", "symfony/service-contracts": "^2.5|^3", - "symfony/yaml": "^5.4|^6.0|^7.0" + "symfony/yaml": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -13102,7 +13174,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.4.4" + "source": "https://github.com/symfony/translation/tree/v7.0.4" }, "funding": [ { @@ -13118,7 +13190,7 @@ "type": "tidelift" } ], - "time": "2024-02-20T13:16:58+00:00" + "time": "2024-02-22T20:27:20+00:00" }, { "name": "symfony/translation-contracts", diff --git a/misc/testing/Releases/recategorize.php b/misc/testing/Releases/recategorize.php index 0e4b0fe2e..91a82f116 100644 --- a/misc/testing/Releases/recategorize.php +++ b/misc/testing/Releases/recategorize.php @@ -39,7 +39,7 @@ function reCategorize($argv): void } $timeStart = now(); $chgCount = categorizeRelease($argv, true); - $time = now()->diffInSeconds($timeStart); + $time = now()->diffInSeconds($timeStart, true); if (! isset($argv[2])) { $colorCli->header('Finished re-categorizing '.number_format($chgCount).' releases in '.$time.' seconds, using the searchname.').PHP_EOL; } else { diff --git a/misc/update/tmux/bin/update_groups.php b/misc/update/tmux/bin/update_groups.php index 8fa4fa41e..2774ebe8e 100644 --- a/misc/update/tmux/bin/update_groups.php +++ b/misc/update/tmux/bin/update_groups.php @@ -48,7 +48,7 @@ try { } } - $colorCli->header('Running time: '.now()->diffInSeconds($start).' seconds'); + $colorCli->header('Running time: '.now()->diffInSeconds($start, true).' seconds'); } catch (ErrorException $e) { echo $e->getMessage(); }