37 private bool $allowBrokenRedirects;
39 private Content $originalContent;
41 private string $result;
50 bool $allowBrokenRedirects,
55 $this->allowBrokenRedirects = $allowBrokenRedirects;
56 $this->newContent = $newContent;
57 $this->originalContent = $originalContent;
58 $this->title = $title;
62 if ( !$this->allowBrokenRedirects ) {
63 $newRedirectTarget = $this->newContent->getRedirectTarget();
65 if ( $newRedirectTarget !==
null && !$newRedirectTarget->exists() &&
66 !$newRedirectTarget->equals( $this->title ) ) {
67 $currentTarget = $this->originalContent->getRedirectTarget();
71 if ( !$currentTarget || $currentTarget->exists() ) {
72 $this->result = self::CONSTRAINT_FAILED;
74 return self::CONSTRAINT_FAILED;
79 $this->result = self::CONSTRAINT_PASSED;
81 return self::CONSTRAINT_PASSED;
86 if ( $this->result === self::CONSTRAINT_FAILED ) {
87 $statusValue->
fatal(
'edit-constraint-brokenredirect' );
88 $statusValue->value = self::AS_BROKEN_REDIRECT;
if(!defined('MW_SETUP_CALLBACK'))
Verify the page does not redirect to a nonexistent page unless.
__construct(bool $allowBrokenRedirects, Content $newContent, Content $originalContent, LinkTarget $title)
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.
Base interface for representing page content.
Interface for all constraints that can prevent edits.