diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 5e697737ab3..885e854a895 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -137,11 +137,16 @@ jobs:
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
+ - name: Get current date
+ id: current-date
+ run: echo "today=$(date '+%Y%m%d')" >> "$GITHUB_OUTPUT"
+
- name: Cache ip2asn
uses: actions/cache@v4
with:
path: database/ip2asn/
- key: ip2asn
+ key: ip2asn-${{ steps.current-date.outputs.today }}
+ restore-keys: ip2asn-
- run: ./build.sh
diff --git a/app/Http/Controllers/UserCoverPresetsController.php b/app/Http/Controllers/UserCoverPresetsController.php
index 87bdfa70122..2a8302b0cbe 100644
--- a/app/Http/Controllers/UserCoverPresetsController.php
+++ b/app/Http/Controllers/UserCoverPresetsController.php
@@ -82,6 +82,6 @@ public function update(string $id): Response
$item->update(['active' => $params['active']]);
}
- return ujs_redirect(route('user-cover-presets.index').'#cover-'.$item->getKey());
+ return response(null, 204);
}
}
diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php
index 605f995b851..cd72c10642a 100644
--- a/app/Http/Controllers/UsersController.php
+++ b/app/Http/Controllers/UsersController.php
@@ -17,7 +17,6 @@
use App\Libraries\UserRegistration;
use App\Models\Beatmap;
use App\Models\BeatmapDiscussion;
-use App\Models\Country;
use App\Models\IpBan;
use App\Models\Log;
use App\Models\User;
@@ -983,9 +982,8 @@ private function storeUser(array $rawParams)
'username',
], ['null_missing' => true]);
$countryCode = request_country();
- $country = Country::find($countryCode);
$params['user_ip'] = $ip;
- $params['country_acronym'] = $country === null ? '' : $country->getKey();
+ $params['country_acronym'] = $countryCode;
$params['user_lang'] = \App::getLocale();
$registration = new UserRegistration($params);
@@ -1009,7 +1007,11 @@ private function storeUser(array $rawParams)
$user = $registration->user();
// report unknown country code but ignore non-country from cloudflare
- if ($countryCode !== null && $country === null && $countryCode !== 'T1') {
+ if (
+ $countryCode !== null
+ && $countryCode !== 'T1'
+ && app('countries')->byCode($countryCode) === null
+ ) {
app('sentry')->getClient()->captureMessage(
'User registered from unknown country',
null,
diff --git a/app/Libraries/User/CountryChange.php b/app/Libraries/User/CountryChange.php
index d8304baab04..f28943cc94b 100644
--- a/app/Libraries/User/CountryChange.php
+++ b/app/Libraries/User/CountryChange.php
@@ -9,7 +9,6 @@
use App\Exceptions\InvariantException;
use App\Models\Beatmap;
-use App\Models\Country;
use App\Models\User;
use App\Models\UserAccountHistory;
@@ -18,7 +17,7 @@ class CountryChange
public static function handle(User $user, string $newCountry, string $reason): void
{
// Assert valid country acronym
- $country = Country::find($newCountry);
+ $country = app('countries')->byCode($newCountry);
if ($country === null) {
throw new InvariantException('invalid country specified');
}
diff --git a/app/Models/User.php b/app/Models/User.php
index 66951d35108..29297a6f14e 100644
--- a/app/Models/User.php
+++ b/app/Models/User.php
@@ -2320,11 +2320,12 @@ public function isValid()
if ($this->isDirty('country_acronym')) {
if (present($this->country_acronym)) {
- if (($country = Country::find($this->country_acronym)) !== null) {
+ $country = app('countries')->byCode($this->country_acronym);
+ if ($country === null) {
+ $this->validationErrors()->add('country', '.invalid_country');
+ } else {
// ensure matching case
$this->country_acronym = $country->getKey();
- } else {
- $this->validationErrors()->add('country', '.invalid_country');
}
} else {
$this->country_acronym = Country::UNKNOWN;
diff --git a/database/factories/CountryFactory.php b/database/factories/CountryFactory.php
index e3ca111fd94..a3ac82f6c6c 100644
--- a/database/factories/CountryFactory.php
+++ b/database/factories/CountryFactory.php
@@ -13,6 +13,11 @@ class CountryFactory extends Factory
{
protected $model = Country::class;
+ public function configure(): static
+ {
+ return $this->afterCreating(fn () => app('countries')->resetMemoized());
+ }
+
public function definition(): array
{
return [
diff --git a/resources/js/setup-turbo.ts b/resources/js/setup-turbo.ts
index f6c0e566b4d..b2f7bb2eb67 100644
--- a/resources/js/setup-turbo.ts
+++ b/resources/js/setup-turbo.ts
@@ -3,6 +3,7 @@
import '@hotwired/turbo';
import { hideLoadingOverlay, showLoadingOverlay } from 'utils/loading-overlay';
+import { reloadPage } from 'utils/turbolinks';
Turbo.config.drive.progressBarDelay = 0;
@@ -17,6 +18,11 @@ document.addEventListener('turbo:submit-start', (e) => {
}
});
document.addEventListener('turbo:submit-end', hideLoadingOverlay);
+document.addEventListener('turbo:submit-end', (e) => {
+ if (e.detail.success && e.detail.formSubmission.formElement.dataset.reloadOnSuccess === '1') {
+ reloadPage();
+ }
+});
// disable turbo navigation for old webs
document.addEventListener('turbo:click', (event) => {
diff --git a/resources/views/layout/ujs-redirect.blade.php b/resources/views/layout/ujs-redirect.blade.php
index 84052e14c6a..fe651fb8e7a 100644
--- a/resources/views/layout/ujs-redirect.blade.php
+++ b/resources/views/layout/ujs-redirect.blade.php
@@ -2,7 +2,6 @@
Copyright (c) ppy Pty Ltd