31 private readonly
Title $title,
32 private readonly
bool $allowRecreation,
33 private readonly ?
string $startTime,
34 private readonly ?
string $submitButtonLabel,
39 if ( $this->allowRecreation ) {
42 $deletion = $this->getDeletionSinceLastEdit();
44 if ( $this->submitButtonLabel ) {
45 $logFormatter = $this->logFormatterFactory->newFromEntry( $deletion );
46 $username = $deletion->isDeleted( LogPage::DELETED_USER )
47 ? MessageValue::new(
'rev-deleted-user' )
48 : $deletion->getPerformerIdentity()->
getName();
49 $commentHtml = $logFormatter->getComment();
55 ?
'edit-constraint-confirmrecreate-noreason'
56 :
'edit-constraint-confirmrecreate',
58 Message::rawParam( $commentHtml ),
64 ->warning(
'deletedwhileediting' );
74 private function getDeletionSinceLastEdit(): ?DatabaseLogEntry {
75 if ( !$this->title->exists() && $this->title->hasDeletedEdits() ) {
76 $lastDelete = $this->getLastDelete();
77 if ( $lastDelete && $lastDelete->getTimestamp() > $this->startTime ) {
88 private function getLastDelete(): ?DatabaseLogEntry {
89 $dbr = $this->connectionProvider->getReplicaDatabase();
90 $row = DatabaseLogEntry::newSelectQueryBuilder( $dbr )
92 'log_namespace' => $this->title->getNamespace(),
93 'log_title' => $this->title->getDBkey(),
94 'log_type' =>
'delete',
95 'log_action' =>
'delete',
97 ->orderBy( [
'log_timestamp',
'log_id' ], SelectQueryBuilder::SORT_DESC )
98 ->caller( __METHOD__ )
101 return $row ? DatabaseLogEntry::newFromRow( $row ) : null;
if(!defined('MW_SETUP_CALLBACK'))
Make sure user doesn't accidentally recreate a page deleted after they started editing.
__construct(private readonly IConnectionProvider $connectionProvider, private readonly LogFormatterFactory $logFormatterFactory, private readonly Title $title, private readonly bool $allowRecreation, private readonly ?string $startTime, private readonly ?string $submitButtonLabel,)
Abstract class for all constraints that can prevent edits.
Status returned by edit constraints and other page editing checks.
A value class to process existing log entries.
Class to simplify the use of log pages.
static newGood( $value=null)
Factory function for good results.