38 private bool $allowBrokenRedirects;
40 private Content $originalContent;
42 private string $submitButtonLabel;
43 private string $result;
52 bool $allowBrokenRedirects,
56 string $submitButtonLabel
58 $this->allowBrokenRedirects = $allowBrokenRedirects;
59 $this->newContent = $newContent;
60 $this->originalContent = $originalContent;
61 $this->title = $title;
62 $this->submitButtonLabel = $submitButtonLabel;
66 if ( !$this->allowBrokenRedirects ) {
67 $newRedirectTarget = $this->newContent->getRedirectTarget();
69 if ( $newRedirectTarget !==
null && !$newRedirectTarget->isKnown() &&
70 !$newRedirectTarget->equals( $this->title ) ) {
71 $currentTarget = $this->originalContent->getRedirectTarget();
75 if ( !$currentTarget || $currentTarget->isKnown() ) {
76 $this->result = self::CONSTRAINT_FAILED;
78 return self::CONSTRAINT_FAILED;
83 $this->result = self::CONSTRAINT_PASSED;
85 return self::CONSTRAINT_PASSED;
91 if ( $this->result === self::CONSTRAINT_FAILED ) {
92 $statusValue->
fatal( MessageValue::new(
'edit-constraint-brokenredirect',
93 [ MessageValue::new( $this->submitButtonLabel ) ] ) );
94 $statusValue->value = self::AS_BROKEN_REDIRECT;
if(!defined('MW_SETUP_CALLBACK'))
Verify the page does not redirect to an unknown page unless.
__construct(bool $allowBrokenRedirects, Content $newContent, Content $originalContent, LinkTarget $title, string $submitButtonLabel)
getLegacyStatus()
Get the legacy status for failure (or success)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Content objects represent page content, e.g.
Interface for all constraints that can prevent edits.