* @ingroup Content
*/
abstract class ContentHandler {
- /**
- * Switch for enabling deprecation warnings. Used by ContentHandler::deprecated()
- * and ContentHandler::runLegacyHooks().
- *
- * Once the ContentHandler code has settled in a bit, this should be set to true to
- * make extensions etc. show warnings when using deprecated functions and hooks.
- */
- protected static $enableDeprecationWarnings = false;
-
/**
* Convenience function for getting flat text from a Content object. This
* should only be used in the context of backwards compatibility with code
}
// Hook can force JS/CSS
- Hooks::run( 'TitleIsCssOrJsPage', [ $title, &$isCodePage ], '1.25' );
+ Hooks::run( 'TitleIsCssOrJsPage', [ $title, &$isCodePage ], '1.21' );
// Is this a user subpage containing code?
$isCodeSubpage = NS_USER == $ns
$isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage;
// Hook can override $isWikitext
- Hooks::run( 'TitleIsWikitextPage', [ $title, &$isWikitext ], '1.25' );
+ Hooks::run( 'TitleIsWikitextPage', [ $title, &$isWikitext ], '1.21' );
if ( !$isWikitext ) {
switch ( $ext ) {
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 );
}
/**
if ( $title->getNamespace() == NS_MEDIAWIKI ) {
// Parse mediawiki messages with correct target language
list( /* $unused */, $lang ) = MessageCache::singleton()->figureMessage( $title->getText() );
- $pageLang = wfGetLangObj( $lang );
+ $pageLang = Language::factory( $lang );
}
Hooks::run( 'PageContentLanguage', [ $title, &$pageLang, $wgLang ] );
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.
return $this->supportsDirectEditing();
}
- /**
- * Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if
- * self::$enableDeprecationWarnings is set to true.
- *
- * @param string $func The name of the deprecated function
- * @param string $version The version since the method is deprecated. Usually 1.21
- * for ContentHandler related stuff.
- * @param string|bool $component : Component to which the function belongs.
- * If false, it is assumed the function is in MediaWiki core.
- *
- * @see ContentHandler::$enableDeprecationWarnings
- * @see wfDeprecated
- */
- public static function deprecated( $func, $version, $component = false ) {
- if ( self::$enableDeprecationWarnings ) {
- wfDeprecated( $func, $version, $component, 3 );
- }
- }
-
/**
* Call a legacy hook that uses text instead of Content objects.
* Will log a warning when a matching hook function is registered.