protected function validateNextRevision() { if (!$this->permissions->isAllowed($this->header, 'edit-header')) { $this->addError('permissions', $this->context->msg('flow-error-not-allowed')); return; } if (empty($this->submitted['prev_revision'])) { $this->addError('prev_revision', $this->context->msg('flow-error-missing-prev-revision-identifier')); } elseif ($this->header->getRevisionId()->getAlphadecimal() !== $this->submitted['prev_revision']) { // This is a reasonably effective way to ensure prev revision matches, but for guarantees against race // conditions there also exists a unique index on rev_prev_revision in mysql, meaning if someone else inserts against the // parent we and the submitter think is the latest, our insert will fail. // TODO: Catch whatever exception happens there, make sure the most recent revision is the one in the cache before // handing user back to specific dialog indicating race condition $this->addError('prev_revision', $this->context->msg('flow-error-prev-revision-mismatch')->params($this->submitted['prev_revision'], $this->header->getRevisionId()->getAlphadecimal(), $this->context->getUser()->getName()), array('revision_id' => $this->header->getRevisionId()->getAlphadecimal())); } // this isn't really part of validate, but we want the error-rendering template to see the users edited header $this->newRevision = $this->header->newNextRevision($this->context->getUser(), $this->submitted['content'], isset($this->submitted['format']) ? $this->submitted['format'] : 'wikitext', 'edit-header', $this->workflow->getArticleTitle()); if (!$this->checkSpamFilters($this->header, $this->newRevision)) { return; } }