MediaWiki REL1_39
AccidentalRecreationConstraint.php
Go to the documentation of this file.
1<?php
22
23use StatusValue;
24
33
35 private $deletedSinceLastEdit;
36
38 private $allowRecreation;
39
44 public function __construct(
45 bool $deletedSinceLastEdit,
46 bool $allowRecreation
47 ) {
48 $this->deletedSinceLastEdit = $deletedSinceLastEdit;
49 $this->allowRecreation = $allowRecreation;
50 }
51
52 public function checkConstraint(): string {
53 if ( $this->deletedSinceLastEdit && !$this->allowRecreation ) {
54 return self::CONSTRAINT_FAILED;
55 }
56 return self::CONSTRAINT_PASSED;
57 }
58
59 public function getLegacyStatus(): StatusValue {
60 $statusValue = StatusValue::newGood();
61 if ( $this->deletedSinceLastEdit && !$this->allowRecreation ) {
62 $statusValue->setResult( false, self::AS_ARTICLE_WAS_DELETED );
63 }
64 return $statusValue;
65 }
66
67}
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
Make sure user doesn't accidentally recreate a page deleted after they started editing.
__construct(bool $deletedSinceLastEdit, bool $allowRecreation)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
setResult( $ok, $value=null)
Change operation result.
Interface for all constraints that can prevent edits.