X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiEditPage.php;h=83f72e54c12c0645f734f8b4bfb9cd422182095e;hb=077d8f78139037e6f724ab24df8bde10b8708ce0;hp=4360b4d782bbf6d51df59ad418de0dad979e4de4;hpb=237d3271fd313ebe09858a5c442a91216a7b61cf;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php index 4360b4d782..83f72e54c1 100644 --- a/includes/api/ApiEditPage.php +++ b/includes/api/ApiEditPage.php @@ -1,9 +1,5 @@ @gmail.com" * * This program is free software; you can redistribute it and/or modify @@ -137,7 +133,7 @@ class ApiEditPage extends ApiBase { } try { - $content = ContentHandler::makeContent( $text, $this->getTitle() ); + $content = ContentHandler::makeContent( $text, $titleObj ); } catch ( MWContentSerializationException $ex ) { $this->dieWithException( $ex, [ 'wrap' => ApiMessage::create( 'apierror-contentserializationexception', 'parseerror' ) @@ -266,6 +262,7 @@ class ApiEditPage extends ApiBase { 'wpIgnoreBlankArticle' => true, 'wpIgnoreSelfRedirect' => true, 'bot' => $params['bot'], + 'wpUnicodeCheck' => EditPage::UNICODE_CHECK, ]; if ( !is_null( $params['summary'] ) ) { @@ -333,7 +330,7 @@ class ApiEditPage extends ApiBase { } // Apply change tags - if ( count( $params['tags'] ) ) { + if ( $params['tags'] ) { $tagStatus = ChangeTags::canAddTagsAccompanyingChange( $params['tags'], $user ); if ( $tagStatus->isOK() ) { $requestArray['wpChangeTags'] = implode( ',', $params['tags'] ); @@ -405,10 +402,17 @@ class ApiEditPage extends ApiBase { return; } if ( !$status->getErrors() ) { - $status->fatal( 'hookaborted' ); + // This appears to be unreachable right now, because all + // code paths will set an error. Could change, though. + $status->fatal( 'hookaborted' ); //@codeCoverageIgnore } $this->dieStatus( $status ); + // These two cases will normally have been caught earlier, and will + // only occur if something blocks the user between the earlier + // check and the check in EditPage (presumably a hook). It's not + // obvious that this is even possible. + // @codeCoverageIgnoreStart case EditPage::AS_BLOCKED_PAGE_FOR_USER: $this->dieWithError( 'apierror-blocked', @@ -418,6 +422,7 @@ class ApiEditPage extends ApiBase { case EditPage::AS_READ_ONLY_PAGE: $this->dieReadOnly(); + // @codeCoverageIgnoreEnd case EditPage::AS_SUCCESS_NEW_ARTICLE: $r['new'] = true; @@ -449,7 +454,7 @@ class ApiEditPage extends ApiBase { $status->fatal( 'apierror-noimageredirect-anon' ); break; case EditPage::AS_IMAGE_REDIRECT_LOGGED: - $status->fatal( 'apierror-noimageredirect-logged' ); + $status->fatal( 'apierror-noimageredirect' ); break; case EditPage::AS_CONTENT_TOO_BIG: case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED: @@ -471,6 +476,7 @@ class ApiEditPage extends ApiBase { // Currently shouldn't be needed, but here in case // hooks use them without setting appropriate // errors on the status. + // @codeCoverageIgnoreStart case EditPage::AS_SPAM_ERROR: $status->fatal( 'apierror-spamdetected', $result['spam'] ); break; @@ -496,10 +502,10 @@ class ApiEditPage extends ApiBase { wfWarn( __METHOD__ . ": Unknown EditPage code {$status->value} with no message" ); $status->fatal( 'apierror-unknownerror-editpage', $status->value ); break; + // @codeCoverageIgnoreEnd } } $this->dieStatus( $status ); - break; } $apiResult->addValue( null, $this->getModuleName(), $r ); } @@ -569,10 +575,14 @@ class ApiEditPage extends ApiBase { ApiBase::PARAM_TYPE => 'text', ], 'undo' => [ - ApiBase::PARAM_TYPE => 'integer' + ApiBase::PARAM_TYPE => 'integer', + ApiBase::PARAM_MIN => 0, + ApiBase::PARAM_RANGE_ENFORCE => true, ], 'undoafter' => [ - ApiBase::PARAM_TYPE => 'integer' + ApiBase::PARAM_TYPE => 'integer', + ApiBase::PARAM_MIN => 0, + ApiBase::PARAM_RANGE_ENFORCE => true, ], 'redirect' => [ ApiBase::PARAM_TYPE => 'boolean',