public function __construct( $modelId, $formats ) {
$this->mModelID = $modelId;
$this->mSupportedFormats = $formats;
-
- $this->mModelName = preg_replace( '/(Content)?Handler$/', '', get_class( $this ) );
- $this->mModelName = preg_replace( '/[_\\\\]/', '', $this->mModelName );
- $this->mModelName = strtolower( $this->mModelName );
}
/**
* have it / want it.
*/
public function getAutoDeleteReason( Title $title, &$hasHistory ) {
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
// Get the last revision
$rev = Revision::newFromTitle( $title );
return false; // no content to undo
}
- $this->checkModelID( $cur_content->getModel() );
- $this->checkModelID( $undo_content->getModel() );
- $this->checkModelID( $undoafter_content->getModel() );
+ try {
+ $this->checkModelID( $cur_content->getModel() );
+ $this->checkModelID( $undo_content->getModel() );
+ if ( $current->getId() !== $undo->getId() ) {
+ // If we are undoing the most recent revision,
+ // its ok to revert content model changes. However
+ // if we are undoing a revision in the middle, then
+ // doing that will be confusing.
+ $this->checkModelID( $undoafter_content->getModel() );
+ }
+ } catch ( MWException $e ) {
+ // If the revisions have different content models
+ // just return false
+ return false;
+ }
if ( $cur_content->equals( $undo_content ) ) {
// No use doing a merge if it's just a straight revert.