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

Laravel11 #1558

Merged
merged 49 commits into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
a1e313c
Update forum
DariusIII Apr 26, 2024
3988ecf
Update config files
DariusIII Apr 26, 2024
73f445a
Add vite config
DariusIII Apr 26, 2024
77ee96b
Update to carbon 3
DariusIII Apr 26, 2024
f3a8951
Update package.json
DariusIII Apr 26, 2024
67ec851
Use Faker methods
laravel-shift Apr 27, 2024
0daa15e
Remove unnecessary `$model` property
laravel-shift Apr 27, 2024
755ba85
Move `resources/lang` folder
laravel-shift Apr 27, 2024
5de0e71
Remove default `app` files
laravel-shift Apr 27, 2024
1a3ffa9
Shift core files
laravel-shift Apr 27, 2024
d7e65c0
Streamline config files
laravel-shift Apr 27, 2024
40284c5
Set new `ENV` variables
laravel-shift Apr 27, 2024
091edeb
Default new `bootstrap/app.php`
laravel-shift Apr 27, 2024
44dd8ea
Re-register HTTP middleware
laravel-shift Apr 27, 2024
f9d0381
Consolidate service providers
laravel-shift Apr 27, 2024
099db99
Re-register service providers
laravel-shift Apr 27, 2024
424b56d
Re-register routes
laravel-shift Apr 27, 2024
70d242d
Re-register scheduled commands
laravel-shift Apr 27, 2024
62e68c9
Bump Composer dependencies
laravel-shift Apr 27, 2024
fe64204
Adopt Laravel type hints
laravel-shift Apr 27, 2024
6a8d56d
Mark base controller as `abstract`
laravel-shift Apr 27, 2024
95253c0
Remove `CreatesApplication` testing trait
laravel-shift Apr 27, 2024
c4ea89c
Merge pull request #1557 from NNTmux/shift-117502
DariusIII Apr 27, 2024
a06eba2
Update paths
DariusIII Apr 27, 2024
d50153a
CS fixes
DariusIII Apr 27, 2024
bed8028
Cast cache time to int
DariusIII Apr 27, 2024
c27bb50
Update .env.example
DariusIII Apr 27, 2024
4fc0d29
Add missing migration
DariusIII Apr 27, 2024
7a71f2e
Streamline config files
laravel-shift Apr 27, 2024
33d7996
Update config and views
DariusIII Apr 27, 2024
80a65a9
CS fixes
DariusIII Apr 27, 2024
262d4e5
Merge branch 'laravel11' of https://github.com/NNTmux/newznab-tmux in…
DariusIII Apr 27, 2024
44c9405
Update config
DariusIII Apr 27, 2024
b2b52e3
CS fixes
DariusIII Apr 27, 2024
1bb7251
Update breeze related parts
DariusIII Apr 28, 2024
adfa6bd
Add new files
DariusIII Apr 28, 2024
d804b5d
Fix CategoryPolicy
DariusIII Apr 28, 2024
656fb14
CS fixes
DariusIII Apr 28, 2024
4cd1ab1
Update used packages to their latest versions
DariusIII Apr 28, 2024
d189a82
CHeck if table exists before migration
DariusIII Apr 28, 2024
311c766
Add mariadb connection and driver
DariusIII Apr 28, 2024
0e62ff1
Use APP_TIMEZONE
DariusIII Apr 28, 2024
36ac4ac
Update laravel.yml
DariusIII Apr 28, 2024
c2b838d
Revert to mariadb 10
DariusIII Apr 28, 2024
56011c1
Remove bookstest as it is unreliable
DariusIII Apr 28, 2024
7b1dbcb
Update tests
DariusIII Apr 28, 2024
9360ca8
Update composer.json
DariusIII Apr 28, 2024
ae647d0
Fix error in config/database
DariusIII Apr 28, 2024
2c3b95c
Fix schema name
DariusIII Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,24 @@ ADMIN_EMAIL=
APP_NAME=NNTmux
APP_ENV=production
APP_DEBUG=false
APP_TIMEZONE=UTC
APP_URL=
APP_TZ=Europe/Paris

APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US

APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database

BCRYPT_ROUNDS=12
APP_KEY=
LOG_CHANNEL=stack
LOG_STACK=single
PASSWORD_HASH=argon2id

BROADCAST_DRIVER=log
CACHE_DRIVER=redis
BROADCAST_CONNECTION=log
CACHE_STORE=redis
QUEUE_CONNECTION=sync

REDIS_HOST=127.0.0.1
Expand All @@ -61,10 +71,11 @@ REDIS_PORT=6379
REDIS_CLIENT=phpredis

SESSION_DRIVER=redis
SESSION_DOMAIN=
SESSION_DOMAIN=null
SESSION_SECURE_COOKIE=false
SESSION_ENCRYPT=false
SESSION_COOKIE=nntmux
SESSION_PATH=/

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
Expand Down
23 changes: 14 additions & 9 deletions .github/workflows/laravel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ on: [push]

jobs:
tests:
name: Run tests
runs-on: ubuntu-latest

strategy:
fail-fast: true
matrix:
php: [ 8.2, 8.3 ]

name: PHP ${{ matrix.php }}
services:
mysql:
image: mariadb:10
Expand All @@ -18,25 +24,24 @@ jobs:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, bcmath, soap, intl, gd, exif, iconv
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
coverage: none

- name: Copy env file
run:
cp .env.test .env

- name: Run composer install
run: composer install -n --prefer-dist
run: composer install --prefer-dist --no-interaction --no-progress

- name: Prepare Laravel Application
run:
php artisan key:generate
- name: Generate app key
run: php artisan key:generate

- name: Run tests
run: php artisan test
run: vendor/bin/phpunit
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
->in(config_path())
->in(database_path())
->notPath(database_path('migrations'))
->in(resource_path('lang'))
->in(base_path('lang'))
->in(base_path('routes'))
->in(base_path('tests'))
->in(base_path('Blacklight'))
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/Backfill.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function backfillAllGroups(string $groupName = '', int|string $articles =
$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);
Expand Down
16 changes: 8 additions & 8 deletions Blacklight/Binaries.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ public function updateAllGroups(int $maxHeaders = 100000): void
$counter++;
}

$endTime = now()->diffInSeconds($allTime);
$endTime = now()->diffInSeconds($allTime, true);
$this->log(
'Updating completed in '.$endTime.Str::plural(' second', $endTime),
__FUNCTION__,
Expand Down Expand Up @@ -458,7 +458,7 @@ public function updateGroup(array $groupMySQL, int $maxHeaders = 0): void
}

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)
Expand Down Expand Up @@ -547,7 +547,7 @@ public function scan(array $groupMySQL, int $first, int $last, string $type = 'u
$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);
Expand Down Expand Up @@ -636,7 +636,7 @@ public function scan(array $groupMySQL, int $first, int $last, string $type = 'u
$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']);
Expand Down Expand Up @@ -853,7 +853,7 @@ protected function storeHeaders(array $headers = []): void
$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'].'),';
Expand Down Expand Up @@ -944,9 +944,9 @@ protected function outputHeaderDuration(): void
$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.');
}
}
Expand Down Expand Up @@ -1236,7 +1236,7 @@ public function daytopost(int $days, array $data): string
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.'
);
}

Expand Down
2 changes: 1 addition & 1 deletion Blacklight/Music.php
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public function processMusicReleases(bool $local = false)

// 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);
}
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/NameFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ public function getPreFileNames(array $args = []): void
$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.');
}
Expand Down
4 changes: 2 additions & 2 deletions Blacklight/ReleaseRemover.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function removeByCriteria(array $arguments): bool|string

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;
Expand Down Expand Up @@ -239,7 +239,7 @@ public function removeCrap(bool $delete, int|string $time, string $type = '', in

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;
Expand Down
2 changes: 1 addition & 1 deletion Blacklight/libraries/Forking.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ private function safeBackfill(): void
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(
Expand Down
18 changes: 9 additions & 9 deletions Blacklight/processing/ProcessReleases.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public function processIncompleteCollections($groupID): void
}
$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: '.
Expand Down Expand Up @@ -282,7 +282,7 @@ public function processCollectionSizes($groupID): void
$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);
Expand Down Expand Up @@ -366,7 +366,7 @@ public function deleteUnwantedCollections($groupID): void
}
}

$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);
Expand Down Expand Up @@ -535,7 +535,7 @@ public function createReleases(int|string $groupID): array
}
}

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary(
Expand Down Expand Up @@ -587,7 +587,7 @@ public function createNZBs(int|string $groupID): int
}
}

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary(
Expand Down Expand Up @@ -625,7 +625,7 @@ public function categorizeReleases(int $categorize, int|string $groupID = ''): v
$groupID
);

$totalTime = now()->diffInSeconds($startTime);
$totalTime = now()->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary($totalTime.Str::plural(' second', $totalTime));
Expand Down Expand Up @@ -682,7 +682,7 @@ public function deleteCollections($groupID): void
}
$firstQuery = $fourthQuery = now();

$totalTime = $firstQuery->diffInSeconds($startTime);
$totalTime = $firstQuery->diffInSeconds($startTime, true);

if ($this->echoCLI) {
$this->colorCLI->primary(
Expand Down Expand Up @@ -729,8 +729,8 @@ public function deleteCollections($groupID): void
}
$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);
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/CleanNZB.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class CleanNZB extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
// Check if any options are false
if (! $this->option('notindb') && ! $this->option('notondisk')) {
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/ImportNzbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ImportNzbs extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
if ($this->option('folder')) {
if ($this->option('filename')) {
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/RecategorizeReleases.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class RecategorizeReleases extends Command
/**
* Execute the console command.
*/
public function handle()
public function handle(): void
{
$countQuery = Release::query();
if ($this->option('misc')) {
Expand Down
48 changes: 0 additions & 48 deletions app/Console/Kernel.php

This file was deleted.

27 changes: 27 additions & 0 deletions app/Http/Controllers/Auth/VerifyEmailController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Auth\Events\Verified;
use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Http\RedirectResponse;

class VerifyEmailController extends Controller
{
/**
* Mark the authenticated user's email address as verified.
*/
public function __invoke(EmailVerificationRequest $request): RedirectResponse
{
if ($request->user()->hasVerifiedEmail()) {
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}

if ($request->user()->markEmailAsVerified()) {
event(new Verified($request->user()));
}

return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
}
}
Loading