From 2011e13dcd6efb57c53369146d24fe704cf18768 Mon Sep 17 00:00:00 2001 From: BlankEclair Date: Sat, 22 Mar 2025 10:48:42 +1100 Subject: [PATCH 1/5] T13396: Link and name the wiki when an email is being sent out to bureaucrats --- i18n/en.json | 2 +- i18n/qqq.json | 2 +- maintenance/ManageInactiveWikis.php | 23 ++++++++++++++++++----- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/i18n/en.json b/i18n/en.json index 22fa7dcbd9..c9de265836 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -12,7 +12,7 @@ "action-createwiki-suppressrequest": "suppress wiki requests", "action-requestwiki": "request wikis", "createwiki": "Create a wiki", - "createwiki-close-email-body": "Hello,\n\nThis email is to inform you that your wiki has been closed.", + "createwiki-close-email-body": "Hello,\n\nThis email is to inform you that your wiki ([$2 $3]) has been closed.", "createwiki-close-email-sender": "noreply", "createwiki-close-email-subject": "Your wiki ($1) has been closed", "createwiki-comment-success": "Comment successfully added to this request.", diff --git a/i18n/qqq.json b/i18n/qqq.json index e8489debed..b1575895c2 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -19,7 +19,7 @@ "action-createwiki-suppressrequest": "{{doc-action|createwiki-suppressrequest}}", "action-requestwiki": "{{doc-action|requestwiki}}", "createwiki": "{{doc-special}}", - "createwiki-close-email-body": "Email body sent to the user when their wiki is closed.", + "createwiki-close-email-body": "Email body sent to the user when their wiki is closed.\n\nParameters:\n* $1: The database name of the wiki (e.g. metawiki)\n* $2: The URL to the wiki (e.g. meta.example.com)\n* $3: The sitename of the wiki", "createwiki-close-email-sender": "{{optional}}", "createwiki-close-email-subject": "Subject of the email sent when a wiki is closed.", "createwiki-comment-success": "Success message displayed when a comment is added to a wiki request.", diff --git a/maintenance/ManageInactiveWikis.php b/maintenance/ManageInactiveWikis.php index 2df9ecff6b..70817b0421 100644 --- a/maintenance/ManageInactiveWikis.php +++ b/maintenance/ManageInactiveWikis.php @@ -99,7 +99,7 @@ private function checkLastActivity( if ( $lastActivityTimestamp < date( 'YmdHis', strtotime( "-{$closeTime} days" ) ) ) { if ( $canWrite ) { $remoteWiki->markClosed(); - $this->notifyBureaucrats( $dbname ); + $this->notifyBureaucrats( $dbname, $remoteWiki ); $this->output( "{$dbname} has been closed. Last activity: {$lastActivityTimestamp}\n" ); } else { $this->output( "{$dbname} should be closed. Last activity: {$lastActivityTimestamp}\n" ); @@ -154,7 +154,7 @@ private function handleInactiveWiki( if ( $isInactive && $inactiveTimestamp < date( 'YmdHis', strtotime( "-{$closeDays} days" ) ) ) { if ( $canWrite ) { $remoteWiki->markClosed(); - $this->notifyBureaucrats( $dbname ); + $this->notifyBureaucrats( $dbname, $remoteWiki ); $this->output( "{$dbname} was marked as inactive on {$inactiveTimestamp} and is now closed. " . "Last activity: {$lastActivityTimestamp}.\n" @@ -203,13 +203,26 @@ private function handleClosedWiki( } } - private function notifyBureaucrats( string $dbname ): void { + private function notifyBureaucrats( string $dbname, RemoteWikiFactory $remoteWiki ): void { + $url = $remoteWiki->getServerName(); + if ( $url === '' ) { + $baseDomain = $this->getConfig()->get( ConfigNames::Subdomain ); + $databaseSuffix = $this->getConfig()->get( ConfigNames::DatabaseSuffix ); + $subdomain = substr( $dbname, 0, -strlen( $databaseSuffix ) ); + $url = "https://{$subdomain}.{$baseDomain}"; + } + + $body = wfMessage( 'createwiki-close-email-body', $dbname, $url, $remoteWiki->getSitename() )->inContentLanguage(); + $notificationData = [ 'type' => 'closure', 'subject' => wfMessage( 'createwiki-close-email-subject', $dbname )->inContentLanguage()->text(), 'body' => [ - 'html' => wfMessage( 'createwiki-close-email-body' )->inContentLanguage()->parse(), - 'text' => wfMessage( 'createwiki-close-email-body' )->inContentLanguage()->text(), + 'html' => $body->parse(), + // Yes, this sends out the wikitext if the user is reading plaintext emails by default. + // However, I anticipate that those who are would be able to read (or at least glean the + // URLs from) the wikitext, especially if they are the bureaucrat of a wiki. + 'text' => $body->text(), ], ]; From 444d085838fe5788e2a2c0d3252a835c51d777c6 Mon Sep 17 00:00:00 2001 From: BlankEclair Date: Sat, 22 Mar 2025 10:55:23 +1100 Subject: [PATCH 2/5] Appease CI --- maintenance/ManageInactiveWikis.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/maintenance/ManageInactiveWikis.php b/maintenance/ManageInactiveWikis.php index 70817b0421..5ddc54fdfa 100644 --- a/maintenance/ManageInactiveWikis.php +++ b/maintenance/ManageInactiveWikis.php @@ -212,7 +212,8 @@ private function notifyBureaucrats( string $dbname, RemoteWikiFactory $remoteWik $url = "https://{$subdomain}.{$baseDomain}"; } - $body = wfMessage( 'createwiki-close-email-body', $dbname, $url, $remoteWiki->getSitename() )->inContentLanguage(); + $body = wfMessage( 'createwiki-close-email-body', $dbname, $url, $remoteWiki->getSitename() ) + ->inContentLanguage(); $notificationData = [ 'type' => 'closure', From 930257e1d913171b0f80c93186efb57a4dddf68b Mon Sep 17 00:00:00 2001 From: BlankEclair Date: Sun, 23 Mar 2025 12:30:23 +1100 Subject: [PATCH 3/5] Use CreateWikiValidator::getValidUrl() --- maintenance/ManageInactiveWikis.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/maintenance/ManageInactiveWikis.php b/maintenance/ManageInactiveWikis.php index 5ddc54fdfa..058dd690a1 100644 --- a/maintenance/ManageInactiveWikis.php +++ b/maintenance/ManageInactiveWikis.php @@ -204,13 +204,8 @@ private function handleClosedWiki( } private function notifyBureaucrats( string $dbname, RemoteWikiFactory $remoteWiki ): void { - $url = $remoteWiki->getServerName(); - if ( $url === '' ) { - $baseDomain = $this->getConfig()->get( ConfigNames::Subdomain ); - $databaseSuffix = $this->getConfig()->get( ConfigNames::DatabaseSuffix ); - $subdomain = substr( $dbname, 0, -strlen( $databaseSuffix ) ); - $url = "https://{$subdomain}.{$baseDomain}"; - } + $validator = $this->getServiceContainer()->get( 'CreateWikiValidator' ); + $url = $remoteWiki->getServerName() ?: $validator->getValidUrl( $dbname ); $body = wfMessage( 'createwiki-close-email-body', $dbname, $url, $remoteWiki->getSitename() ) ->inContentLanguage(); From e4c9bdeda270748874d7d81f543b53534a1ccfa1 Mon Sep 17 00:00:00 2001 From: The-Voidwalker Date: Tue, 19 May 2026 00:36:23 -0400 Subject: [PATCH 4/5] swap RemoteWikiFactory for RemoteWiki don't think this was intended --- maintenance/ManageInactiveWikis.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maintenance/ManageInactiveWikis.php b/maintenance/ManageInactiveWikis.php index 44d133a546..13a536cc70 100644 --- a/maintenance/ManageInactiveWikis.php +++ b/maintenance/ManageInactiveWikis.php @@ -219,7 +219,7 @@ private function handleClosedWiki( } } - private function notifyBureaucrats( string $dbname, RemoteWikiFactory $remoteWiki ): void { + private function notifyBureaucrats( string $dbname, RemoteWiki $remoteWiki ): void { $validator = $this->getServiceContainer()->get( 'CreateWikiValidator' ); $url = $remoteWiki->getServerName() ?: $validator->getValidUrl( $dbname ); From 3649f029f500c5b41b798a8ebd1d3ba755798253 Mon Sep 17 00:00:00 2001 From: The-Voidwalker Date: Tue, 19 May 2026 00:51:38 -0400 Subject: [PATCH 5/5] teach phan what a CreateWikiValidator is --- maintenance/ManageInactiveWikis.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/maintenance/ManageInactiveWikis.php b/maintenance/ManageInactiveWikis.php index 13a536cc70..adf0959536 100644 --- a/maintenance/ManageInactiveWikis.php +++ b/maintenance/ManageInactiveWikis.php @@ -8,6 +8,7 @@ use Miraheze\CreateWiki\Services\CreateWikiDatabaseUtils; use Miraheze\CreateWiki\Services\CreateWikiDataStore; use Miraheze\CreateWiki\Services\CreateWikiNotificationsManager; +use Miraheze\CreateWiki\Services\CreateWikiValidator; use Miraheze\CreateWiki\Services\RemoteWikiFactory; use function date; use function strtotime; @@ -220,7 +221,10 @@ private function handleClosedWiki( } private function notifyBureaucrats( string $dbname, RemoteWiki $remoteWiki ): void { + /** @var CreateWikiValidator $validator */ $validator = $this->getServiceContainer()->get( 'CreateWikiValidator' ); + '@phan-var CreateWikiValidator $validator'; + $url = $remoteWiki->getServerName() ?: $validator->getValidUrl( $dbname ); $body = wfMessage( 'createwiki-close-email-body', $dbname, $url, $remoteWiki->getSitename() )