Commit e9aca9b2 authored by Christian Kuhn's avatar Christian Kuhn Committed by Benni Mack
Browse files

[!!!][TASK] Deprecate ext:backend class AbstractModule

The internal / experimental class ext:backend/Module/AbstractModule
doesn't do much useful stuff: It only instantiates ModuleTemplate
in it's constructor which forces all inheriting classes to call
parent::__construct(). The processRequest() method with its
dispatcher code is never used in core, but superseeded by routing
configuration via Configuration/Backend/Routes.php.

The patch removes given AbstractModule usages and markes the
class as deprecated. The patch is slightly breaking in cases
an extension extends AbstractWizardController and additionally
uses the initialized moduleTemplate property.

Change-Id: Iee36e1787a6dc2a1affb3625983ccb6450589481
Resolves: #82689
Releases: master
Reviewed-on: https://review.typo3.org/54312


Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <typo3@scripting-base.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 851bac6e
......@@ -17,8 +17,8 @@ namespace TYPO3\CMS\Backend\Controller\ContentElement;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\History\RecordHistory;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\History\RecordHistoryStore;
use TYPO3\CMS\Core\Imaging\Icon;
......@@ -30,7 +30,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
* Controller for showing the history module of TYPO3s backend
* @see \TYPO3\CMS\Backend\History\RecordHistory
*/
class ElementHistoryController extends AbstractModule
class ElementHistoryController
{
/**
* @var ServerRequestInterface
......@@ -59,12 +59,19 @@ class ElementHistoryController extends AbstractModule
*/
protected $recordCache = [];
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->view = $this->initializeView();
}
......
......@@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Controller\ContentElement;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Tree\View\ContentMovingPagePositionMap;
use TYPO3\CMS\Backend\Tree\View\PageMovingPagePositionMap;
use TYPO3\CMS\Backend\Utility\BackendUtility;
......@@ -27,7 +27,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Script Class for rendering the move-element wizard display
*/
class MoveElementController extends AbstractModule
class MoveElementController
{
/**
* @var int
......@@ -78,12 +78,19 @@ class MoveElementController extends AbstractModule
*/
public $content;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf');
$GLOBALS['SOBE'] = $this;
$this->init();
......
......@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Backend\Controller\ContentElement;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Backend\Wizard\NewContentElementWizardHookInterface;
......@@ -30,7 +30,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Script Class for the New Content element wizard
*/
class NewContentElementController extends AbstractModule
class NewContentElementController
{
/**
* Page id
......@@ -125,12 +125,19 @@ class NewContentElementController extends AbstractModule
*/
protected $menuItemView;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->view = $this->getFluidTemplateObject();
$this->menuItemView = $this->getFluidTemplateObject('MenuItem.html');
......
......@@ -22,8 +22,8 @@ use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord;
use TYPO3\CMS\Backend\Form\FormResultCompiler;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Form\Utility\FormEngineUtility;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\Restriction\BackendWorkspaceRestriction;
......@@ -48,7 +48,7 @@ use TYPO3\CMS\Frontend\Page\PageRepository;
* Script Class: Drawing the editing form for editing records in TYPO3.
* Notice: It does NOT use tce_db.php to submit data to, rather it handles submissions itself
*/
class EditDocumentController extends AbstractModule
class EditDocumentController
{
const DOCUMENT_CLOSE_MODE_DEFAULT = 0;
const DOCUMENT_CLOSE_MODE_REDIRECT = 1; // works like DOCUMENT_CLOSE_MODE_DEFAULT
......@@ -399,12 +399,19 @@ class EditDocumentController extends AbstractModule
*/
protected $previewData = [];
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->moduleTemplate->setUiBlock(true);
$GLOBALS['SOBE'] = $this;
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_alt_doc.xlf');
......
......@@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Controller\File;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
......@@ -31,7 +31,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
*
* Displays forms for creating folders (1 to 10), a media asset or a new file.
*/
class CreateFolderController extends AbstractModule
class CreateFolderController
{
/**
* @var int
......@@ -83,12 +83,19 @@ class CreateFolderController extends AbstractModule
*/
public $content;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->init();
}
......
......@@ -18,9 +18,9 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Form\FormResultCompiler;
use TYPO3\CMS\Backend\Form\NodeFactory;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Messaging\FlashMessage;
......@@ -34,7 +34,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Script Class for rendering the file editing screen
*/
class EditFileController extends AbstractModule
class EditFileController
{
/**
* Module content accumulated.
......@@ -83,12 +83,19 @@ class EditFileController extends AbstractModule
*/
protected $fileObject;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->init();
}
......
......@@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Controller\File;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException;
......@@ -26,7 +26,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Script Class for display up to 10 upload fields
*/
class FileUploadController extends AbstractModule
class FileUploadController
{
/**
* Name of the filemount
......@@ -63,12 +63,19 @@ class FileUploadController extends AbstractModule
*/
protected $folderObject;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf');
$this->init();
......
......@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Backend\Controller\File;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Resource\DuplicationBehavior;
......@@ -29,7 +29,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Script Class for the rename-file form.
*/
class RenameFileController extends AbstractModule
class RenameFileController
{
/**
* Name of the filemount
......@@ -68,12 +68,19 @@ class RenameFileController extends AbstractModule
*/
public $content;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->init();
}
......
......@@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Controller\File;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Localization\LanguageService;
......@@ -29,7 +29,7 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
/**
* Script Class for the rename-file form
*/
class ReplaceFileController extends AbstractModule
class ReplaceFileController
{
/**
* Document template object
......@@ -73,12 +73,19 @@ class ReplaceFileController extends AbstractModule
*/
public $content;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->init();
}
......
......@@ -16,8 +16,8 @@ namespace TYPO3\CMS\Backend\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Tree\View\NewRecordPageTreeView;
use TYPO3\CMS\Backend\Tree\View\PagePositionMap;
use TYPO3\CMS\Backend\Utility\BackendUtility;
......@@ -33,7 +33,7 @@ use TYPO3\CMS\Frontend\Page\PageRepository;
/**
* Script class for 'db_new'
*/
class NewRecordController extends AbstractModule
class NewRecordController
{
/**
* @var array
......@@ -146,12 +146,19 @@ class NewRecordController extends AbstractModule
*/
public $tRows;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$GLOBALS['SOBE'] = $this;
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_misc.xlf');
$this->init();
......
......@@ -14,7 +14,6 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
* The TYPO3 project - inspiring people to share!
*/
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
......@@ -24,7 +23,7 @@ use TYPO3\CMS\Core\Type\Bitmask\Permission;
/**
* Class AbstractWizardController
*/
class AbstractWizardController extends AbstractModule
class AbstractWizardController
{
/**
* Checks access for element
......
......@@ -85,7 +85,6 @@ class AddController extends AbstractWizardController
*/
public function __construct()
{
parent::__construct();
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_wizards.xlf');
$GLOBALS['SOBE'] = $this;
......
......@@ -53,7 +53,6 @@ class EditController extends AbstractWizardController
*/
public function __construct()
{
parent::__construct();
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_wizards.xlf');
$GLOBALS['SOBE'] = $this;
......
......@@ -56,7 +56,6 @@ class ListController extends AbstractWizardController
*/
public function __construct()
{
parent::__construct();
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_wizards.xlf');
$GLOBALS['SOBE'] = $this;
$this->P = GeneralUtility::_GP('P');
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Backend\Controller\Wizard;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools;
use TYPO3\CMS\Core\DataHandling\DataHandler;
......@@ -103,12 +104,19 @@ class TableController extends AbstractWizardController
*/
protected $iconFactory;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->getLanguageService()->includeLLFile('EXT:lang/Resources/Private/Language/locallang_wizards.xlf');
$GLOBALS['SOBE'] = $this;
......
......@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
* template and comes with a simple dispatcher method.
*
* @internal Experimental for now
* @deprecated
*/
class AbstractModule
{
......@@ -40,6 +41,11 @@ class AbstractModule
*/
public function __construct()
{
trigger_error(
'Class AbstractModule is deprecated since TYPO3 v9 and will be removed with TYPO3 v10.'
. ' Instantiate ModuleTemplate yourself if needed and use routing registered in Routes.php.',
E_USER_DEPRECATED
);
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
}
......
.. include:: ../../Includes.txt
==============================================================================
Breaking: #82689 - Backend AbstractWizardController not extends AbstractModule
==============================================================================
See :issue:`82689`
Description
===========
The PHP class :php:`TYPO3\CMS\Backend\Controller\Wizard\AbstractWizardController` no
longer extends class :php:`TYPO3\CMS\Backend\Module\AbstractModule`. This can be breaking
if wizard classes of extensions depend on method :php:`processRequest()` or the initialized
property :php:`moduleTemplate`.
PHP class :php:`TYPO3\CMS\Backend\Module\AbstractModule` has been deprecated and should not be used any longer.
Impact
======
* Using class :php:`AbstractModule` will throw a deprecation warning
* Extensions with wizards extending class :php:`AbstractWizardController`
may fatal if they use property :php:`moduleTemplate`
* Extensions with wizards extending class :php:`AbstractWizardController`
may fatal if they use they registered routes to method :php:`processRequest`
Affected Installations
======================
Installations with extensions with one of the above described patterns.
Migration
=========
Extensions that extend :php:`AbstractModule` should initialize :php:`moduleTemplate`
at an appropriate place instead. Instead of :php:`processRequest()`, routes should be
registered in an extensions :file:`Configuration/Backend/Routes.php` and
:file:`Configuration/Backend/AjaxRoutes.php`.
.. index:: Backend, PHP-API, PartiallyScanned
\ No newline at end of file
......@@ -384,6 +384,11 @@ return [
'Breaking-82406-RoutingBackendModulesRunThroughRegularDispatcher.rst',
],
],
'TYPO3\CMS\Backend\Module\AbstractModule' => [
'restFiles' => [
'Breaking-82689-BackendAbstractWizardControllerNotExtendsAbstractModule.rst',
],
],
// Removed interfaces
'TYPO3\CMS\Backend\Form\DatabaseFileIconsHookInterface' => [
......
......@@ -226,8 +226,6 @@ class LinkValidatorReport extends \TYPO3\CMS\Backend\Module\AbstractFunctionModu
];
}
// @todo: Use $this-moduleTemplate as soon as this class extends from AbstractModule
/** @var ModuleTemplate $moduleTemplate */
$moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
return $moduleTemplate->getDynamicTabMenu($menuItems, 'report-linkvalidator');
}
......
......@@ -17,7 +17,6 @@ namespace TYPO3\CMS\Recordlist;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Clipboard\Clipboard;
use TYPO3\CMS\Backend\Module\AbstractModule;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\DocumentTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
......@@ -37,7 +36,7 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Script Class for the Web > List module; rendering the listing of records on a page
*/
class RecordList extends AbstractModule
class RecordList
{
/**
* Page Id for which to make the listing
......@@ -187,12 +186,19 @@ class RecordList extends AbstractModule
*/
protected $iconFactory;
/**
* ModuleTemplate object
*
* @var ModuleTemplate
*/
protected $moduleTemplate;
/**
* Constructor
*/
public function __construct()
{