- Minor problem with T326057: No warning on creating broken redirect to red link
- T395768: DoubleRedirectConstraint fails to re-validate when redirect target changes between redirect pages is similar.
Steps to replicate the issue
- Try to create a redirect to a non-existent page, such as [[Foobar1234567890]].
- An error is thrown.
- Change the redirect target to a different non-existent page, such as [[0987654321raboof]] and submit
What happens?:
- No error is thrown, so a redirect is created to a non-existent page.
What should have happened instead?:
- An error should have been thrown instead, to prevent creation of a broken redirect to non-existent page (red link).
Tested and confirmed
This has been checked.
Notes
Fix includes / editpage / Constraint / BrokenRedirectConstraint.php
The key condition in checkConstraint() is:
public function checkConstraint(): string { if ( !$this->allowBrokenRedirects ) { $newRedirectTarget = $this->newContent->getRedirectTarget(); if ( $newRedirectTarget !== null && !$newRedirectTarget->isKnown() && !$newRedirectTarget->equals( $this->title ) ) { $currentTarget = $this->originalContent->getRedirectTarget(); // fail if there was no previous content or the previous content contained // a redirect to a known page if ( !$currentTarget || $currentTarget->isKnown() ) { $this->result = self::CONSTRAINT_FAILED; return self::CONSTRAINT_FAILED; } } } $this->result = self::CONSTRAINT_PASSED; return self::CONSTRAINT_PASSED; } }