diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..f5708ed1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +root = true + +[*] +indent_style = tab +indent_size = tab +tab_width = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Ensure text editors don't turn leading spaces into tabs, +# e.g. in multi-line bullet list items +[*.md] +indent_style = space +indent_size = 2 + +[.git/**] +indent_style = space +indent_size = 2 diff --git a/extension.json b/extension.json index 36847d88..9d7164bf 100644 --- a/extension.json +++ b/extension.json @@ -57,6 +57,9 @@ "ExtensionMessagesFiles": { "ConfirmAccountAliases": "ConfirmAccount.alias.php" }, + "AutoloadNamespaces": { + "MediaWiki\\Extension\\ConfirmAccount\\": "src/" + }, "AutoloadClasses": { "ConfirmAccountHooks": "includes/ConfirmAccountHooks.php", "ConfirmAccountUIHooks": "includes/frontend/ConfirmAccountUI.hooks.php", diff --git a/includes/backend/UserAccountRequest.php b/includes/backend/UserAccountRequest.php index b54bebf5..a1d746c7 100644 --- a/includes/backend/UserAccountRequest.php +++ b/includes/backend/UserAccountRequest.php @@ -49,8 +49,8 @@ public static function newFromRow( $row ) { $req->notes = $row->acr_notes; $req->urls = $row->acr_urls; $req->type = (int)$row->acr_type; - $req->areas = self::expandAreas( $row->acr_areas ); - $req->fileName = strlen( $row->acr_filename ) + $req->areas = self::expandAreas( $row->acr_areas ?? '' ); + $req->fileName = strlen( $row->acr_filename ?? '' ) ? $row->acr_filename : null; $req->fileStorageKey = $row->acr_storage_key; @@ -87,37 +87,25 @@ public static function newFromArray( array $fields ) { $req->notes = $fields['notes']; $req->urls = $fields['urls']; $req->type = (int)$fields['type']; - $req->areas = is_string( $fields['areas'] ) - ? self::expandAreas( $fields['areas'] ) // DB format + $req->areas = is_string( $fields['areas'] ?? '' ) + ? self::expandAreas( $fields['areas'] ?? '' ) // DB format : $fields['areas']; // already expanded - $req->fileName = strlen( $fields['filename'] ) + $req->fileName = strlen( $fields['filename'] ?? '' ) ? $fields['filename'] : null; - $req->fileStorageKey = $fields['storage_key']; - $req->ip = $fields['ip']; - $req->xff = $fields['xff']; - $req->agent = $fields['agent']; - $req->emailToken = $fields['email_token']; // MD5 of token - $req->emailTokenExpires = wfTimestampOrNull( TS_MW, $fields['email_token_expires'] ); + $req->fileStorageKey = $fields['storage_key'] ?? ''; + $req->ip = $fields['ip'] ?? ''; + $req->xff = $fields['xff'] ?? ''; + $req->agent = $fields['agent'] ?? ''; + $req->emailToken = $fields['email_token'] ?? ''; // MD5 of token + $req->emailTokenExpires = wfTimestampOrNull( TS_MW, $fields['email_token_expires'] ?? '' ); // These fields are typically left to default on insertion... - $req->emailAuthTimestamp = isset( $fields['email_authenticated'] ) - ? wfTimestampOrNull( TS_MW, $fields['email_authenticated'] ) - : null; - $req->deleted = isset( $fields['deleted'] ) - ? $fields['deleted'] - : false; - $req->rejectedTimestamp = isset( $fields['rejected'] ) - ? wfTimestampOrNull( TS_MW, $fields['rejected'] ) - : null; - $req->heldTimestamp = isset( $fields['held'] ) - ? wfTimestampOrNull( TS_MW, $fields['held'] ) - : null; - $req->user = isset( $fields['user'] ) - ? (int)$fields['user'] - : 0; - $req->comment = isset( $fields['comment'] ) - ? $fields['comment'] - : ''; + $req->emailAuthTimestamp = wfTimestampOrNull( TS_MW, $fields['email_authenticated'] ?? null ); + $req->deleted = $fields['deleted'] ?? false; + $req->rejectedTimestamp = wfTimestampOrNull( TS_MW, $fields['rejected'] ?? null ); + $req->heldTimestamp = wfTimestampOrNull( TS_MW, $fields['held'] ?? null ); + $req->user = (int)( $fields['user'] ?? 0 ); + $req->comment = $fields['comment'] ?? ''; return $req; } diff --git a/includes/business/AccountRequestSubmission.php b/includes/business/AccountRequestSubmission.php index d7046d01..c6bc1374 100644 --- a/includes/business/AccountRequestSubmission.php +++ b/includes/business/AccountRequestSubmission.php @@ -1,10 +1,13 @@ requester = $requester; + $this->params = $params; $this->userName = trim( $params['userName'] ); $this->realName = trim( $params['realName'] ); $this->tosAccepted = $params['tosAccepted']; @@ -232,6 +236,14 @@ public function submit( IContextSource $context ) { $context->msg( 'filecopyerror', $this->attachmentTempPath, $pathRel )->escaped() ]; } } + + $hookRunner = new HookRunner( MediaWikiServices::getInstance()->getHookContainer() ); + $message = ""; + if ( $hookRunner->onConfirmAccount__checkRequest( $u, $this->params, $message ) === false ) { + $dbw->cancelAtomic( __METHOD__ ); + return [ 'acct_request_check_request_error', $message ]; + } + $expires = null; // passed by reference $token = ConfirmAccount::getConfirmationToken( $u, $expires ); diff --git a/includes/frontend/specialpages/actions/ConfirmAccount_body.php b/includes/frontend/specialpages/actions/ConfirmAccount_body.php index bfd68c03..7c2fa438 100644 --- a/includes/frontend/specialpages/actions/ConfirmAccount_body.php +++ b/includes/frontend/specialpages/actions/ConfirmAccount_body.php @@ -516,7 +516,7 @@ protected function showAccountConfirmForm( $msg = '' ) { $form .= "
" . $this->msg( 'confirmaccount-reason' )->escaped() . "
\n"; $form .= "
" . Xml::submitButton( $this->msg( 'confirmaccount-submit' )->text() ) . "
\n"; $form .= ''; diff --git a/includes/frontend/specialpages/actions/ConfirmAccountsPager.php b/includes/frontend/specialpages/actions/ConfirmAccountsPager.php index d9228abb..cb07bd4b 100644 --- a/includes/frontend/specialpages/actions/ConfirmAccountsPager.php +++ b/includes/frontend/specialpages/actions/ConfirmAccountsPager.php @@ -5,6 +5,7 @@ */ class ConfirmAccountsPager extends ReverseChronologicalPager { public $mForm, $mConds; + public $rejects, $stale; function __construct( $form, $conds, $type, $rejects = false, $showHeld = false, $showStale = false diff --git a/src/ConfirmAccount__checkRequestHook.php b/src/ConfirmAccount__checkRequestHook.php new file mode 100644 index 00000000..da1b0bf4 --- /dev/null +++ b/src/ConfirmAccount__checkRequestHook.php @@ -0,0 +1,34 @@ +. + * + * @author Mark A. Hershberger