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/Invitation/CreateBulk.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CreateBulk extends Command {
*/
public function handle() {
$numCodes = trim($this->argument('numCodes'));
$helper = new InviteHelper;
$helper = new InviteHelper();

for ($i = 0; $i < $numCodes; $i++) {
$code = $helper->generate();
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/ScheduleStatsUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function handle() {
Bus::batch($siteStatsUpdateJobs)
->allowFailures()
->finally(function (): void {
dispatch(new PlatformStatsSummaryJob);
dispatch(new PlatformStatsSummaryJob());
})->dispatch();

return 0;
Expand Down
24 changes: 12 additions & 12 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,33 @@ protected function schedule(Schedule $schedule): void {
$schedule->job(new ProvisionQueryserviceNamespaceJob(null, 10))->everyMinute()->withoutOverlapping();

// Slowly cleanup some tables
$schedule->job(new ExpireOldUserVerificationTokensJob)->hourly()->withoutOverlapping();
$schedule->job(new PruneEventPageUpdatesTable)->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new PruneQueryserviceBatchesTable)->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new CreateQueryserviceBatchesJob)->everyMinute()->withoutOverlapping();
$schedule->job(new RequeuePendingQsBatchesJob)->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new FailStalledEntityImportsJob)->hourly();
$schedule->job(new ExpireOldUserVerificationTokensJob())->hourly()->withoutOverlapping();
$schedule->job(new PruneEventPageUpdatesTable())->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new PruneQueryserviceBatchesTable())->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new CreateQueryserviceBatchesJob())->everyMinute()->withoutOverlapping();
$schedule->job(new RequeuePendingQsBatchesJob())->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new FailStalledEntityImportsJob())->hourly();

// Sandbox
// TODO this should maybe only be run when sandbox as a whole is loaded?
// TODO instead of using LOAD ROUTES, we should just have different modes?
$schedule->job(new SandboxCleanupJob)->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new SandboxCleanupJob())->everyFifteenMinutes()->withoutOverlapping();

// Schedule site stat updates for each wiki and platform-summary
$schedule->command('schedule:stats')->dailyAt('7:00');

// https://laravel.com/docs/10.x/upgrade#redis-cache-tags
$schedule->command('cache:prune-stale-tags')->hourly()->withoutOverlapping();

$schedule->job(new PollForMediaWikiJobsJob)->everyFifteenMinutes()->withoutOverlapping();
$schedule->job(new PollForMediaWikiJobsJob())->everyFifteenMinutes()->withoutOverlapping();

$schedule->job(new UpdateWikiSiteStatsJob)->dailyAt('19:00');
$schedule->job(new UpdateWikiSiteStatsJob())->dailyAt('19:00');

$schedule->job(new SendEmptyWikiNotificationsJob)->dailyAt('21:00');
$schedule->job(new SendEmptyWikiNotificationsJob())->dailyAt('21:00');

$schedule->job(new UpdateWikiDailyMetricJob)->dailyAt('23:00');
$schedule->job(new UpdateWikiDailyMetricJob())->dailyAt('23:00');

$schedule->job(new UpdateQueryserviceAllowList)->weeklyOn(Schedule::MONDAY, '01:00');
$schedule->job(new UpdateQueryserviceAllowList())->weeklyOn(Schedule::MONDAY, '01:00');

}

Expand Down
2 changes: 1 addition & 1 deletion app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Handler extends ExceptionHandler {
*/
public function register(): void {
$this->reportable(function (Throwable $e): void {
(new ErrorReporting)->report($e);
(new ErrorReporting())->report($e);
});
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/Backend/MediaWikiHostsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class MediaWikiHostsController extends Controller {
public function getWikiHostsForDomain(Request $request): JsonResponse {
$mediawikiHostResolver = new MediaWikiHostResolver;
$mediawikiHostResolver = new MediaWikiHostResolver();
$domain = $request->query('domain');
try {
$hosts = $mediawikiHostResolver->getHostsForDomain($domain);
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 @@ -40,7 +40,7 @@ public function sendMessage(Request $request): JsonResponse {

$validated = $validator->safe();

$complaintRecord = new ComplaintRecord;
$complaintRecord = new ComplaintRecord();
$complaintRecord->name = $validated['name'];
$complaintRecord->mail_address = $validated['email'];
$complaintRecord->reason = $validated['message'];
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 @@ -114,7 +114,7 @@ private function generateUnusedDomain() {
}

private function generateDomain(): string {
$generator = new HumanPasswordGenerator;
$generator = new HumanPasswordGenerator();

$generator
->setWordList(__DIR__ . '/words')
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/WikiProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __construct(ProfileValidator $profileValidator) {
public function create(Request $request): JsonResponse {
$wiki = $request->attributes->get('wiki');
$validatedInput = $request->validate([
'profile' => ['required', 'json', new NonEmptyJsonRule],
'profile' => ['required', 'json', new NonEmptyJsonRule()],
]);

$rawProfile = json_decode($validatedInput['profile'], true);
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/WikiSettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ private function getSettingValidations(): array {
'wwWikibaseStringLengthMonolingualText' => ['required', 'integer', 'between:400,2500'],
'wwWikibaseStringLengthMultilang' => ['required', 'integer', 'between:250,2500'],
'wikibaseFedPropsEnable' => ['required', 'boolean'],
'wikibaseManifestEquivEntities' => ['required', 'json', new SettingWikibaseManifestEquivEntities],
'wikibaseManifestEquivEntities' => ['required', 'json', new SettingWikibaseManifestEquivEntities()],
'wwUseQuestyCaptcha' => ['required', 'boolean'],
'wwCaptchaQuestions' => ['required', 'json', new SettingCaptchaQuestions],
'wwCaptchaQuestions' => ['required', 'json', new SettingCaptchaQuestions()],
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/UpdateWikiDailyMetricJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class UpdateWikiDailyMetricJob extends Job implements ShouldBeUnique {
public function handle(): void {
$wikis = Wiki::withTrashed()->get();
foreach ($wikis as $wiki) {
(new WikiMetrics)->saveMetrics($wiki);
(new WikiMetrics())->saveMetrics($wiki);
}
}
}
2 changes: 1 addition & 1 deletion app/Notifications/ComplaintNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function toMail($notifiable) {
$mailFrom = config('app.complaint-mail-sender');
$mailSubject = config('app.name') . ': Report of Illegal Content';

return (new MailMessage)
return (new MailMessage())
->from($mailFrom)
->subject($mailSubject)
->line(Lang::get('A message via the wikibase.cloud form for reporting illegal content has been submitted.'))
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/ComplaintNotificationExternal.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function toMail($notifiable) {
$mailFrom = config('app.complaint-mail-sender');
$mailSubject = config('app.name') . ': Report of Illegal Content';

return (new MailMessage)
return (new MailMessage())
->from($mailFrom)
->subject($mailSubject)
->line(Lang::get('Your message via the wikibase.cloud form for reporting illegal content has been submitted.'))
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/ContactNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function toMail($notifiable) {
$mailFrom = str_replace('<subject>', $this->subject, config('app.contact-mail-sender'));
$mailSubject = config('app.name') . Lang::get(' contact form message: ') . $subject;

return (new MailMessage)
return (new MailMessage())
->from($mailFrom)
->subject($mailSubject)
->line(Lang::get('A message via the wikibase.cloud contact form has been submitted.'))
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/EmailReverificationNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function toMail($notifiable) {

$verifyEmailLink = config('wbstack.ui_url') . '/emailVerification/' . $this->token;

return (new MailMessage)
return (new MailMessage())
->subject(Lang::get('Please verify your email'))
->line(Lang::get('Someone, probably you, has requested another link to verify the email associated with your Wikibase.cloud account. You’re just one step away from taking advantage of all that the platform has to offer. To complete your registration, verify your email address by clicking below.'))
->action(Lang::get('Verify Email'), $verifyEmailLink)
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/EmptyWikiNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function via($notifiable) {
public function toMail($notifiable) {
$days = intval(config('wbstack.wiki_empty_notification_threshold'));

return (new MailMessage)
return (new MailMessage())
->from('noreply@wikibase.cloud', 'Wikibase Cloud')
->subject(Lang::get('Need some help with your Wikibase?'))
->line(Lang::get('Thanks for creating a Wikibase instance on Wikibase Cloud! That was at least ' . $days . ' days ago. We couldn’t help but notice that your Wikibase instance `' . $this->sitename . '` remains empty, so we’re checking in to see if we can help.'))
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/ResetPasswordNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function toMail($notifiable) {
$queryPart = "?token=$this->token&email={$encodedEmail}";
$resetPasswordLink = config('wbstack.ui_url') . '/reset-password' . $queryPart;

return (new MailMessage)
return (new MailMessage())
->subject(Lang::get('Please reset your password'))
->line(Lang::get('You are receiving this email because we received a password reset request for your account.'))
->action(Lang::get('Reset Password'), $resetPasswordLink)
Expand Down
2 changes: 1 addition & 1 deletion app/Notifications/UserCreationNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function toMail($notifiable) {

$verifyEmailLink = config('wbstack.ui_url') . '/emailVerification/' . $this->token;

return (new MailMessage)
return (new MailMessage())
->subject(Lang::get('Action Needed: Please verify your email'))
->line(Lang::get('Welcome to Wikibase.cloud! You’re just one step away from taking advantage of all that the platform has to offer. To complete your registration, verify your email address by clicking below.'))
->action(Lang::get('Verify Email'), $verifyEmailLink)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
Expand Down
3 changes: 2 additions & 1 deletion pint.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"concat_space": {
"spacing": "one"
},
"not_operator_with_successor_space": false
"not_operator_with_successor_space": false,
"new_with_parentheses": true
}
}
4 changes: 2 additions & 2 deletions tests/Helper/ProfileValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ProfileValidatorTest extends TestCase {
* @dataProvider validProfileProvider
*/
public function testProfileValidatorWorksWithValidProfile($profile): void {
$validatorFactory = new ProfileValidator;
$validatorFactory = new ProfileValidator();
$validator = $validatorFactory->getValidator($profile);
$this->assertTrue($validator->passes());
}
Expand All @@ -19,7 +19,7 @@ public function testProfileValidatorWorksWithValidProfile($profile): void {
* @dataProvider invalidProfileProvider
*/
public function testProfileValidatorWorksWithInvalidProfile($profile): void {
$validatorFactory = new ProfileValidator;
$validatorFactory = new ProfileValidator();
$validator = $validatorFactory->getValidator($profile);
$this->assertFalse($validator->passes());
}
Expand Down
16 changes: 8 additions & 8 deletions tests/Http/Controllers/PublicWikiControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ public function testShowLoadsWikiLatestProfileForResource(): void {
'audience' => 'wide',
]);

$controller = new PublicWikiController;
$controller = new PublicWikiController();
$resource = $controller->show($wiki->id);

$this->assertInstanceOf(PublicWikiResource::class, $resource);
$this->assertSame(true, $resource->toArray(new Request)['reuse_prototype']);
$this->assertSame(true, $resource->toArray(new Request())['reuse_prototype']);
}

public function testIndexReusePrototypeOnlyRequiresOneAdditionalDatabaseQuery(): void {
Expand All @@ -57,8 +57,8 @@ public function testIndexReusePrototypeOnlyRequiresOneAdditionalDatabaseQuery():
}
});

$controller = new PublicWikiController;
$resourceCollection = $controller->index(new Request);
$controller = new PublicWikiController();
$resourceCollection = $controller->index(new Request());

$this->assertSame(1, $wikiProfilesQueryCount);
$this->assertTrue($resourceCollection->first()->relationLoaded('wikiLatestProfile'));
Expand All @@ -70,8 +70,8 @@ public function testIndexReusePrototypeIsFalseWhenWikiHasNoLatestProfile(): void
'sitename' => 'No Profile Test Site',
]);

$controller = new PublicWikiController;
$request = new Request;
$controller = new PublicWikiController();
$request = new Request();
$resourceCollection = $controller->index($request);

$resource = $resourceCollection->firstWhere('id', $wikiWithoutProfile->id);
Expand All @@ -91,8 +91,8 @@ public function testIndexReusePrototypeIsFalseWhenWikiIsNotIntendedForReuse(): v
'temporality' => 'temporary',
]);

$controller = new PublicWikiController;
$request = new Request;
$controller = new PublicWikiController();
$request = new Request();
$resourceCollection = $controller->index($request);

$resource = $resourceCollection->firstWhere('id', $wiki->id);
Expand Down
2 changes: 1 addition & 1 deletion tests/Jobs/CreateFirstTermsOfUseVersionJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CreateFirstTermsOfUseVersionJobTest extends TestCase {
public function testCreateFirstTermsOfUseVersionJob(): void {
$this->assertDatabaseCount('tou_versions', 0);

(new CreateFirstTermsOfUseVersionJob)->handle();
(new CreateFirstTermsOfUseVersionJob())->handle();

$this->assertDatabaseHas('tou_versions', [
'version' => '2022-01-01',
Expand Down
16 changes: 8 additions & 8 deletions tests/Jobs/CreateQueryserviceBatchesJobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function tearDown(): void {

public function testEmpty(): void {
$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -64,7 +64,7 @@ public function testBatchCreation(): void {
EventPageUpdate::factory()->create(['id' => 6, 'wiki_id' => 1, 'namespace' => MediawikiNamespace::item, 'title' => 'Q152']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -89,7 +89,7 @@ public function testBatchMerging(): void {
EventPageUpdate::factory()->create(['id' => 234, 'wiki_id' => 99, 'namespace' => MediawikiNamespace::item, 'title' => 'Q34']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -115,7 +115,7 @@ public function testBigBatches(): void {
EventPageUpdate::factory()->create(['id' => 124, 'wiki_id' => 99, 'namespace' => MediawikiNamespace::item, 'title' => 'Q11']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -140,7 +140,7 @@ public function testBigBatches(): void {
EventPageUpdate::factory()->create(['id' => 125, 'wiki_id' => 99, 'namespace' => MediawikiNamespace::item, 'title' => 'Q999']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -166,7 +166,7 @@ public function testBackpressure(): void {
EventPageUpdate::factory()->create(['id' => 134, 'wiki_id' => 99, 'namespace' => MediawikiNamespace::item, 'title' => 'Q12']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -189,7 +189,7 @@ public function testCheckpoints(): void {
EventPageUpdate::factory()->create(['id' => 188, 'wiki_id' => 99, 'namespace' => MediawikiNamespace::item, 'title' => 'Q12']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand All @@ -201,7 +201,7 @@ public function testCheckpoints(): void {
EventPageUpdate::factory()->create(['id' => 198, 'wiki_id' => 99, 'namespace' => MediawikiNamespace::item, 'title' => 'Q126']);

$mockJob = $this->createMock(Job::class);
$job = new CreateQueryserviceBatchesJob;
$job = new CreateQueryserviceBatchesJob();
$job->setJob($mockJob);
$mockJob->expects($this->never())
->method('fail');
Expand Down
Loading
Loading