Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/Console/Commands/ScheduleStatsUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function handle() {

Bus::batch($siteStatsUpdateJobs)
->allowFailures()
->finally(function () {
->finally(function (): void {
dispatch(new PlatformStatsSummaryJob);
})->dispatch();

Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Handler extends ExceptionHandler {
* Register the exception handling callbacks for the application.
*/
public function register(): void {
$this->reportable(function (Throwable $e) {
$this->reportable(function (Throwable $e): void {
(new ErrorReporting)->report($e);
});
}
Expand Down
2 changes: 1 addition & 1 deletion app/Helper/DomainValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function __construct(string $subDomainSuffix, array $subdomainRules) {
$this->subdomainRules = $subdomainRules;
}

public function getValidator($domain): \Illuminate\Validation\Validator {
public function getValidator($domain): \Illuminate\Contracts\Validation\Validator {

$isSubdomain = WikiController::isSubDomain($domain, $this->subDomainSuffix);

Expand Down
2 changes: 1 addition & 1 deletion app/Helper/ProfileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Illuminate\Support\Facades\Validator;

class ProfileValidator {
public function getValidator($profile): \Illuminate\Validation\Validator {
public function getValidator($profile): \Illuminate\Contracts\Validation\Validator {

return Validator::make($profile, [
'purpose' => 'in:data_hub,data_lab,tool_lab,test_drive,decide_later,other',
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/ForgotPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ForgotPasswordController extends Controller {
/*
Expand All @@ -29,7 +30,7 @@ public function __construct() {
$this->middleware('guest');
}

protected function sendResetLinkResponse(): JsonResponse {
protected function sendResetLinkResponse(?Request $request = null): JsonResponse {
return response()->json('Success', 200);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Auth/RegisterController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function register(Request $request) {
$this->validator($request->all())->validate();

$user = null;
DB::transaction(function () use (&$user, $request) {
DB::transaction(function () use (&$user, $request): void {
$user = (new UserCreateJob(
$request->input('email'),
$request->input('password')
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Controllers/Auth/ResetPasswordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ResetPasswordController extends Controller {
/*
Expand Down Expand Up @@ -36,7 +37,7 @@ public function __construct() {
$this->middleware('guest');
}

protected function sendResetResponse(): JsonResponse {
protected function sendResetResponse(?Request $request = null): JsonResponse {
return response()->json('Success', 200);
}

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ComplaintController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function sendMessage(Request $request): JsonResponse {
/**
* Get a validator for an incoming complaint report page request.
*/
protected function validator(array $data): \Illuminate\Validation\Validator {
protected function validator(array $data): \Illuminate\Contracts\Validation\Validator {
$data['name'] = $data['name'] ?? '';
$data['email'] = $data['email'] ?? '';

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function sendMessage(Request $request): JsonResponse {
/**
* Get a validator for an incoming contact page request.
*/
protected function validator(array $data): \Illuminate\Validation\Validator {
protected function validator(array $data): \Illuminate\Contracts\Validation\Validator {
if (!isset($data['contactDetails'])) {
$data['contactDetails'] = ''; // could we skip this using some feature of the validator?
}
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Sandbox/SandboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function create(Request $request): Response {
$dataSet = $request->get('dataSet');

$wiki = null;
DB::transaction(function () use (&$wiki, $domain) {
DB::transaction(function () use (&$wiki, $domain): void {
$wikiDbCondition = ['wiki_id' => null, 'version' => self::MW_VERSION];

// Fail if there is not enough storage ready
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/WikiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function create(Request $request): Response {
$dbAssignment = null;

// TODO create with some sort of owner etc?
DB::transaction(function () use ($user, $request, &$wiki, &$dbAssignment, $submittedDomain, $rawProfile, $rawKnowledgeEquityResponse) {
DB::transaction(function () use ($user, $request, &$wiki, &$dbAssignment, $submittedDomain, $rawProfile, $rawKnowledgeEquityResponse): void {
$dbVersion = Config::get('wbstack.wiki_db_use_version');
$wikiDbCondition = ['wiki_id' => null, 'version' => $dbVersion];

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/WikiEntityImportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function get(Request $request): JsonResponse {
public function create(Request $request): JsonResponse {
$validatedInput = $request->validate([
'source_wiki_url' => ['required', 'url'],
'entity_ids' => ['required', 'string', function (string $attr, mixed $value, \Closure $fail) {
'entity_ids' => ['required', 'string', function (string $attr, mixed $value, \Closure $fail): void {
$chunks = explode(',', $value);
foreach ($chunks as $chunk) {
if (!preg_match("/^[A-Z]\d+(@\d+)?$/", $chunk)) {
Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/CreateQueryserviceBatchesJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct() {
}

public function handle(): void {
DB::transaction(function () {
DB::transaction(function (): void {
$latestCheckpoint = QsCheckpoint::get();

[$newEntities, $latestEventId] = $this->getNewEntities($latestCheckpoint);
Expand Down Expand Up @@ -53,7 +53,7 @@ private function getNewEntities(int $latestCheckpoint): array {
)
->whereIn('namespace', [MediawikiNamespace::item, MediawikiNamespace::property, MediawikiNamespace::lexeme])
->has('wiki')
->chunk(100, function (Collection $chunk) use (&$newEntitiesFromEvents, &$latestEventId) {
->chunk(100, function (Collection $chunk) use (&$newEntitiesFromEvents, &$latestEventId): void {
foreach ($chunk as $event) {
$newEntitiesFromEvents[$event->wiki_id][] = $event->title;
$latestEventId = max($event->id, $latestEventId);
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/DeleteWikiDispatcherJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function handle() {

Bus::chain([
...$jobs,
])->catch(function (Throwable $e) use ($wiki) {
])->catch(function (Throwable $e) use ($wiki): void {
Log::error(__METHOD__ . "An error occured when deleting {$wiki->id}: " . $e->getMessage());
})->dispatch();

Expand Down
7 changes: 2 additions & 5 deletions app/Jobs/FailStalledEntityImportsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
use App\WikiEntityImport;
use App\WikiEntityImportStatus;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Log;

class FailStalledEntityImportsJob implements ShouldQueue {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

public function handle(): void {
$deadline = Carbon::now()->subHours(24);
Expand Down
7 changes: 2 additions & 5 deletions app/Jobs/GenerateOAuth2KeysJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

use App\Wiki;
use App\WikiSetting;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Log;

class GenerateOAuth2KeysJob extends Job implements ShouldQueue {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

public function handle() {
$allWikis = Wiki::all();
Expand Down
4 changes: 2 additions & 2 deletions app/Jobs/UpdateWikiSiteStatsJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private function updateLifecycleEvents(Wiki $wiki): void {
$update['last_edited'] = Carbon::parse($lastEdited);
}

DB::transaction(function () use ($wiki, $update) {
DB::transaction(function () use ($wiki, $update): void {
$wiki->wikiLifecycleEvents()->lockForUpdate()->updateOrCreate(['wiki_id' => $wiki->id], $update);
});
}
Expand All @@ -74,7 +74,7 @@ private function updateSiteStats(Wiki $wiki): void {
$update[$field] = $value;
}
}
DB::transaction(function () use ($wiki, $update) {
DB::transaction(function () use ($wiki, $update): void {
$wiki->wikiSiteStats()->lockForUpdate()->updateOrCreate(['wiki_id' => $wiki->id], $update);
});
}
Expand Down
7 changes: 2 additions & 5 deletions app/Jobs/WikiEntityImportJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@
use App\WikiEntityImport;
use App\WikiEntityImportStatus;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;
use Maclof\Kubernetes\Client;
use Maclof\Kubernetes\Models\Job as KubernetesJob;

class WikiEntityImportJob implements ShouldQueue {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Queueable;

/**
* Create a new job instance.
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function register(): void {
* Bootstrap any application services.
*/
public function boot(): void {
Queue::failing(function (JobFailed $event) {
Queue::failing(function (JobFailed $event): void {
$name = data_get($event->job->payload(), 'data.commandName');
$wrappedException = new \Exception("Executing Job '$name' failed.", 1, $event->exception);
report($wrappedException);
Expand Down
10 changes: 6 additions & 4 deletions app/QsBatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ class QsBatch extends Model {
'processing_attempts',
];

protected $casts = [
'pending_since' => 'datetime',
];

public function wiki(): BelongsTo {
return $this->belongsTo(Wiki::class);
}

protected function casts(): array {
return [
'pending_since' => 'datetime',
];
}
}
12 changes: 7 additions & 5 deletions app/TermsOfUseVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ class TermsOfUseVersion extends Model {

protected $visible = self::FIELDS;

protected $casts = [
'version' => 'string',
'active' => 'boolean',
];

public static function latestActiveVersion(): ?self {
return self::query()->where('active', true)->latest()->first();
}

protected function casts(): array {
return [
'version' => 'string',
'active' => 'boolean',
];
}
}
22 changes: 12 additions & 10 deletions app/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ class User extends Authenticatable implements MustVerifyEmail {
'card_last_four',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];

public function sendPasswordResetNotification($token) {
$this->notify(new ResetPasswordNotification($token));
}
Expand Down Expand Up @@ -129,4 +119,16 @@ public function sendEmailVerificationNotification() {
public function getEmailForVerification() {
return $this->email;
}

/**
* The attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array {
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}
12 changes: 7 additions & 5 deletions app/UserTermsOfUseAcceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ class UserTermsOfUseAcceptance extends Model {

protected $visible = self::FIELDS;

protected $casts = [
'tou_version' => 'string',
'tou_accepted_at' => 'datetime',
];

protected $table = 'tou_acceptances';

public function user(): BelongsTo {
return $this->belongsTo(User::class);
}

protected function casts(): array {
return [
'tou_version' => 'string',
'tou_accepted_at' => 'datetime',
];
}
}
17 changes: 11 additions & 6 deletions app/Wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App;

use App\Helper\DomainHelper;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
Expand Down Expand Up @@ -69,10 +70,6 @@ class Wiki extends Model {
'domain_decoded',
];

protected $casts = [
'deleted_at' => 'datetime',
];

public function wikiDbVersion() {
return $this->hasOne(WikiDb::class)->select(['id', 'wiki_id', 'version']);
}
Expand Down Expand Up @@ -156,8 +153,10 @@ public static function getSiteDirectory(int $wiki_id): string {
/**
* Convert the IDN formatted domain name to it's Unicode representation.
*/
public function getDomainDecodedAttribute(): string {
return DomainHelper::decode($this->domain);
protected function domainDecoded(): Attribute {
return Attribute::make(get: function () {
return DomainHelper::decode($this->domain);
});
}

public function wikiLatestProfile() {
Expand All @@ -174,4 +173,10 @@ public function setSetting(string $name, string $value): void {
public function deleteSetting(string $name): ?string {
return $this->settings()->where('name', $name)->delete();
}

protected function casts(): array {
return [
'deleted_at' => 'datetime',
];
}
}
10 changes: 6 additions & 4 deletions app/WikiEntityImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ class WikiEntityImport extends Model {

protected $visible = self::FIELDS;

protected $casts = [
'status' => WikiEntityImportStatus::class,
'payload' => 'array',
];
protected function casts(): array {
return [
'status' => WikiEntityImportStatus::class,
'payload' => 'array',
];
}
}
Loading
Loading