From a8b66dda41431c2280a9d36bfebf0c3731ee9a03 Mon Sep 17 00:00:00 2001
From: Wouter Wolters <typo3@wouterwolters.nl>
Date: Mon, 2 Mar 2015 22:42:23 +0100
Subject: [PATCH] [TASK] Make db_new.php dispatched

Use dispatching for db_new.php

Resolves: #65288
Releases: master
Change-Id: Ie3ef5c8e4df8dc0181ed5e85dd780c769c2801ca
Reviewed-on: http://review.typo3.org/37479
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
---
 typo3/db_new.php                              |  4 +++
 .../components/pagetree/javascript/actions.js |  2 +-
 .../backend/Classes/ClickMenu/ClickMenu.php   | 15 +++++++----
 .../Classes/Controller/BackendController.php  |  1 +
 .../Controller/NewRecordController.php        |  2 +-
 .../PageTreeNavigationController.php          |  2 +-
 .../Tree/View/NewRecordPageTreeView.php       |  2 +-
 .../backend/Classes/View/PageLayoutView.php   |  8 ++++--
 .../sysext/backend/Modules/NewRecord/conf.php |  3 +++
 .../backend/Modules/NewRecord/index.php       | 26 +++++++++++++++++++
 typo3/sysext/backend/ext_tables.php           |  6 +++++
 ...ion-65288-DeprecateNewRecordEntryPoint.rst | 25 ++++++++++++++++++
 .../feedit/Classes/FrontendEditPanel.php      |  5 ++--
 .../frontend/Classes/View/AdminPanelView.php  | 14 +++++-----
 .../Classes/RecordList/DatabaseRecordList.php |  6 ++---
 15 files changed, 98 insertions(+), 23 deletions(-)
 create mode 100644 typo3/sysext/backend/Modules/NewRecord/conf.php
 create mode 100644 typo3/sysext/backend/Modules/NewRecord/index.php
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst

diff --git a/typo3/db_new.php b/typo3/db_new.php
index 8fabbe1515e4..fd28c707219b 100644
--- a/typo3/db_new.php
+++ b/typo3/db_new.php
@@ -22,6 +22,10 @@
  */
 require __DIR__ . '/init.php';
 
+\TYPO3\CMS\Core\Utility\GeneralUtility::deprecationLog(
+	'The entry point to create a new database entry was moved to an own module. Please use BackendUtility::getModuleUrl(\'db_new\') to link to db_new.php. This script will be removed in TYPO3 CMS 8.'
+);
+
 $newRecordController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\NewRecordController::class);
 $newRecordController->main();
 $newRecordController->printContent();
diff --git a/typo3/js/extjs/components/pagetree/javascript/actions.js b/typo3/js/extjs/components/pagetree/javascript/actions.js
index 877dcbdd0078..3e49a9f18eea 100644
--- a/typo3/js/extjs/components/pagetree/javascript/actions.js
+++ b/typo3/js/extjs/components/pagetree/javascript/actions.js
@@ -336,7 +336,7 @@ TYPO3.Components.PageTree.Actions = {
 	newPageWizard: function(node) {
 		node.select();
 		TYPO3.Backend.ContentContainer.setUrl(
-			'db_new.php?id=' + node.attributes.nodeData.id + '&pagesOnly=1'
+			TYPO3.settings.NewRecord.moduleUrl + '&id=' + node.attributes.nodeData.id + '&pagesOnly=1'
 		);
 	},
 
diff --git a/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php b/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php
index d1f6e046190e..12006daf4f0f 100644
--- a/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php
+++ b/typo3/sysext/backend/Classes/ClickMenu/ClickMenu.php
@@ -623,7 +623,7 @@ class ClickMenu {
 	}
 
 	/**
-	 * Adding CM element for Create new wizard (either db_new.php or BackendUtility::getModuleUrl('new_content_element') or custom wizard)
+	 * Adding CM element for Create new wizard (either BackendUtility::getModuleUrl('db_new') or BackendUtility::getModuleUrl('new_content_element') or custom wizard)
 	 *
 	 * @param string $table Table name
 	 * @param int $uid UID for the current record.
@@ -637,7 +637,7 @@ class ClickMenu {
 		$tmpTSc = $tmpTSc['properties']['newContentWiz.']['overrideWithExtension'];
 
 		$newContentWizScriptPath = ExtensionManagementUtility::isLoaded($tmpTSc) ? ExtensionManagementUtility::extRelPath($tmpTSc) . 'mod1/db_new_content_el.php?' : BackendUtility::getModuleUrl('new_content_element') . '&';
-		$url = $table === 'pages' ? 'db_new.php?id=' . $uid . '&pagesOnly=1' : $newContentWizScriptPath . 'id=' . $rec['pid'] . '&sys_language_uid=' . (int)$rec['sys_language_uid'];
+		$url = $table === 'pages' ? BackendUtility::getModuleUrl('db_new', ['id' => $uid, 'pagesOnly' => 1]) : $newContentWizScriptPath . 'id=' . $rec['pid'] . '&sys_language_uid=' . (int)$rec['sys_language_uid'];
 		return $this->linkItem($this->languageService->makeEntities($this->languageService->getLL('CM_newWizard')), IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new'), $this->urlRefForCM($url, 'returnUrl'), 0);
 	}
 
@@ -706,9 +706,14 @@ class ClickMenu {
 	 * @internal
 	 */
 	public function DB_new($table, $uid) {
-		$loc = 'top.content.list_frame';
-		$editOnClick = 'if(' . $loc . '){' . $loc . '.location.href=top.TS.PATH_typo3+\'' . ($this->listFrame ? 'alt_doc.php?returnUrl=\'+top.rawurlencode(' . $this->frameLocation(($loc . '.document')) . '.pathname+' . $this->frameLocation(($loc . '.document')) . '.search)+\'&edit[' . $table . '][-' . $uid . ']=new\'' : 'db_new.php?id=' . (int)$uid . '\'') . ';}';
-		return $this->linkItem($this->label('new'), IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new'), $editOnClick . ';');
+		$frame = 'top.content.list_frame';
+		$location = $this->frameLocation($frame . '.document');
+		$module = $this->listFrame
+			? GeneralUtility::quoteJSvalue('alt_doc.php?edit[' . $table . '][-' . $uid . ']=new&returnUrl=') . '+top.rawurlencode(' . $location . '.pathname+' . $location . '.search)'
+			: GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => (int)$uid]));
+		$editOnClick = 'if(' . $frame . '){' . $frame . '.location.href=top.TS.PATH_typo3+' . $module . ';}';
+		$icon = IconUtility::getSpriteIcon('actions-' . ($table === 'pages' ? 'page' : 'document') . '-new');
+		return $this->linkItem($this->label('new'), $icon, $editOnClick);
 	}
 
 	/**
diff --git a/typo3/sysext/backend/Classes/Controller/BackendController.php b/typo3/sysext/backend/Classes/Controller/BackendController.php
index a397ff6e86cd..38675e14ff3e 100644
--- a/typo3/sysext/backend/Classes/Controller/BackendController.php
+++ b/typo3/sysext/backend/Classes/Controller/BackendController.php
@@ -305,6 +305,7 @@ class BackendController {
 				$this->pageRenderer->addJsFile($relativeComponentPath . 'javascript/' . $jsFile);
 			}
 			$this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history'));
+			$this->pageRenderer->addInlineSetting('NewRecord', 'moduleUrl', BackendUtility::getModuleUrl('db_new'));
 		}
 	}
 
diff --git a/typo3/sysext/backend/Classes/Controller/NewRecordController.php b/typo3/sysext/backend/Classes/Controller/NewRecordController.php
index 9c1198c6f774..662af3a899d3 100644
--- a/typo3/sysext/backend/Classes/Controller/NewRecordController.php
+++ b/typo3/sysext/backend/Classes/Controller/NewRecordController.php
@@ -323,7 +323,7 @@ class NewRecordController {
 			$this->code .= $positionMap->positionTree($this->id, $this->pageinfo, $this->perms_clause, $this->R_URI);
 		} else {
 			// No pages yet, no need to prompt for position, redirect to page creation.
-			$javascript = BackendUtility::editOnClick('returnUrl=%2Ftypo3%2Fdb_new.php%3Fid%3D0%26pagesOnly%3D1&edit[pages][0]=new&returnNewPageId=1');
+			$javascript = BackendUtility::editOnClick('&edit[pages][0]=new&returnNewPageId=1', '', BackendUtility::getModuleUrl('db_new', array('id' => $this->id, 'pagesOnly' => '1')));
 			$startPos = strpos($javascript, 'href=\'') + 6;
 			$endPos = strpos($javascript, '\';');
 			$url = substr($javascript, $startPos, $endPos - $startPos);
diff --git a/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php b/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
index 210254b84c43..41e5bca4af0e 100644
--- a/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
+++ b/typo3/sysext/backend/Classes/Controller/PageTreeNavigationController.php
@@ -227,7 +227,7 @@ class PageTreeNavigationController {
 			'refresh' => ''
 		);
 		// New Page
-		$onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+\'db_new.php?pagesOnly=1&amp;id=\'+Tree.pageID;';
+		$onclickNewPageWizard = 'top.content.list_frame.location.href=top.TS.PATH_typo3+' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['pagesOnly' => 1, 'id' => ''])) . '+Tree.pageID;';
 		$buttons['new_page'] = '<a href="#" onclick="' . $onclickNewPageWizard . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:cms/layout/locallang.xlf:newPage', TRUE) . '">' . IconUtility::getSpriteIcon('actions-page-new') . '</a>';
 		// Refresh
 		$buttons['refresh'] = '<a href="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" title="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.refresh', TRUE) . '">' . IconUtility::getSpriteIcon('actions-system-refresh') . '</a>';
diff --git a/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php b/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php
index adb0ccf70783..d1a8e7a7701f 100644
--- a/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php
+++ b/typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php
@@ -16,7 +16,7 @@ namespace TYPO3\CMS\Backend\Tree\View;
 
 /**
  * Extension for the tree class that generates the tree of pages in the page-wizard mode
- * see typo3/db_new.php
+ * see typo3/sysext/backend/Classes/Tree/View/NewRecordPageTreeView.php
  */
 class NewRecordPageTreeView extends PageTreeView {
 
diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php
index 2ca8da7afe64..8fbc43a95f14 100644
--- a/typo3/sysext/backend/Classes/View/PageLayoutView.php
+++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php
@@ -873,9 +873,13 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe
 				);
 			}
 			if ($this->ext_CALC_PERMS & 8) {
+				$parameters = [
+					'id' => $id,
+					'pagesOnly' => 1,
+					'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')
+				];
 				$bArray[2] = $this->getPageLayoutController()->doc->t3Button(
-					'window.location.href=\'' . $this->backPath . 'db_new.php?id=' . $id
-						. '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI')) . '\';',
+					'window.location.href=' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', $parameters, $this->backPath)) . ';',
 					$this->getLanguageService()->getLL('newPage2')
 				);
 			}
diff --git a/typo3/sysext/backend/Modules/NewRecord/conf.php b/typo3/sysext/backend/Modules/NewRecord/conf.php
new file mode 100644
index 000000000000..17b22fd506ed
--- /dev/null
+++ b/typo3/sysext/backend/Modules/NewRecord/conf.php
@@ -0,0 +1,3 @@
+<?php
+$MCONF['script'] = '_DISPATCH';
+$MCONF['name'] = 'db_new';
\ No newline at end of file
diff --git a/typo3/sysext/backend/Modules/NewRecord/index.php b/typo3/sysext/backend/Modules/NewRecord/index.php
new file mode 100644
index 000000000000..da71f00f7dcd
--- /dev/null
+++ b/typo3/sysext/backend/Modules/NewRecord/index.php
@@ -0,0 +1,26 @@
+<?php
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+/**
+ * New database item menu
+ *
+ * This script lets users choose a new database element to create.
+ * Includes a wizard mode for visually pointing out the position of new pages
+ *
+ * @author Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+
+$newRecordController = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Controller\NewRecordController::class);
+$newRecordController->main();
+$newRecordController->printContent();
\ No newline at end of file
diff --git a/typo3/sysext/backend/ext_tables.php b/typo3/sysext/backend/ext_tables.php
index cb5cf2a9fd48..679aed8220b5 100644
--- a/typo3/sysext/backend/ext_tables.php
+++ b/typo3/sysext/backend/ext_tables.php
@@ -116,6 +116,12 @@ if (TYPO3_MODE === 'BE') {
 		)
 	);
 
+	// Register new record
+	\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
+		'db_new',
+		\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($_EXTKEY) . 'Modules/NewRecord/'
+	);
+
 	// Register new content element module
 	\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addModulePath(
 		'new_content_element',
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst
new file mode 100644
index 000000000000..01e804eb7147
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-65288-DeprecateNewRecordEntryPoint.rst
@@ -0,0 +1,25 @@
+========================================================
+Deprecation: #65288 - Deprecate "new record" entry point
+========================================================
+
+Description
+===========
+
+The following entry point has been marked as deprecated:
+
+* typo3/db_new.php
+
+
+Impact
+======
+
+Using this entry points in a backend module will throw a deprecation message.
+
+
+Migration
+=========
+
+Use ``\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl()`` instead with the according module name.
+
+typo3/db_new.php
+``\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('db_new')``
diff --git a/typo3/sysext/feedit/Classes/FrontendEditPanel.php b/typo3/sysext/feedit/Classes/FrontendEditPanel.php
index 40cf7dfd91d7..0930e54838ac 100644
--- a/typo3/sysext/feedit/Classes/FrontendEditPanel.php
+++ b/typo3/sysext/feedit/Classes/FrontendEditPanel.php
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Feedit;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
 use TYPO3\CMS\Backend\FrontendBackendUserAuthentication;
 use TYPO3\CMS\Core\Database\DatabaseConnection;
@@ -243,7 +244,7 @@ class FrontendEditPanel {
 		} elseif ($cmd == 'new') {
 			$rParts = explode(':', $currentRecord);
 			if ($rParts[0] == 'pages') {
-				$out = $this->editPanelLinkWrap_doWrap($string, $adminURL . 'db_new.php?id=' . $rParts[1] . '&pagesOnly=1', $currentRecord);
+				$out = $this->editPanelLinkWrap_doWrap($string, $adminURL . BackendUtility::getModuleUrl('db_new', ['id' => $rParts[1], 'pagesOnly' => 1]), $currentRecord);
 			} else {
 				if (!(int)$nPid) {
 					$nPid = MathUtility::canBeInterpretedAsInteger($rParts[1]) ? -$rParts[1] : $this->frontendController->id;
@@ -264,7 +265,7 @@ class FrontendEditPanel {
 	}
 
 	/**
-	 * Creates a link to a script (eg. typo3/alt_doc.php or typo3/db_new.php) which either opens in the current frame OR in a pop-up window.
+	 * Creates a link to a script (eg. typo3/alt_doc.php or NewRecordController) which either opens in the current frame OR in a pop-up window.
 	 *
 	 * @param string $string The string to wrap in a link, typ. and image used as button in the edit panel.
 	 * @param string $url The URL of the link. Should be absolute if supposed to work with <base> path set.
diff --git a/typo3/sysext/frontend/Classes/View/AdminPanelView.php b/typo3/sysext/frontend/Classes/View/AdminPanelView.php
index 652f9be454c3..3230d77f3ec8 100644
--- a/typo3/sysext/frontend/Classes/View/AdminPanelView.php
+++ b/typo3/sysext/frontend/Classes/View/AdminPanelView.php
@@ -600,30 +600,30 @@ class AdminPanelView {
 		$perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
 		$langAllowed = $GLOBALS['BE_USER']->checkLanguageAccess($GLOBALS['TSFE']->sys_language_uid);
 		$id = $GLOBALS['TSFE']->id;
-		$returnUrl = '&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
+		$returnUrl = GeneralUtility::getIndpEnv('REQUEST_URI');
 
 		$icon = IconUtility::getSpriteIcon('actions-document-history-open', array('title' => $this->extGetLL('edit_recordHistory', FALSE)));
-		$toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('record_history', array('element' => 'pages:' . $id)) . $returnUrl) . '#latest">' . $icon . '</a>';
+		$toolBar = '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('record_history', array('element' => 'pages:' . $id, 'returnUrl' => $returnUrl))) . '#latest">' . $icon . '</a>';
 		if ($perms & 16 && $langAllowed) {
 			$params = '';
 			if ($GLOBALS['TSFE']->sys_language_uid) {
 				$params = '&sys_language_uid=' . $GLOBALS['TSFE']->sys_language_uid;
 			}
 			$icon = IconUtility::getSpriteIcon('actions-document-new', array('title' => $this->extGetLL('edit_newContentElement', FALSE)));
-			$toolBar .= '<a href="' . htmlspecialchars(($newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>';
+			$toolBar .= '<a href="' . htmlspecialchars($newContentWizScriptPath . 'id=' . $id . $params . '&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>';
 		}
 		if ($perms & 2) {
 			$icon = IconUtility::getSpriteIcon('actions-document-move', array('title' => $this->extGetLL('edit_move_page', FALSE)));
-			$toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . BackendUtility::getModuleUrl('move_element') . '&table=pages&uid=' . $id . '&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>';
+			$toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('move_element', ['table' => 'pages', 'uid' => $id, 'returnUrl' => $returnUrl])) . '">' . $icon . '</a>';
 		}
 		if ($perms & 8) {
 			$icon = IconUtility::getSpriteIcon('actions-page-new', array('title' => $this->extGetLL('edit_newPage', FALSE)));
-			$toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'db_new.php?id=' . $id . '&pagesOnly=1&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>';
+			$toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . BackendUtility::getModuleUrl('db_new', ['id' => $id, 'pagesOnly' => 1, 'returnUrl' => $returnUrl])) . '">' . $icon . '</a>';
 		}
 		if ($perms & 2) {
 			$params = '&edit[pages][' . $id . ']=edit';
 			$icon = IconUtility::getSpriteIcon('actions-document-open', array('title' => $this->extGetLL('edit_editPageProperties', FALSE)));
-			$toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>';
+			$toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>';
 			if ($GLOBALS['TSFE']->sys_language_uid && $langAllowed) {
 				$row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow(
 					'uid,pid,t3ver_state',
@@ -636,7 +636,7 @@ class AdminPanelView {
 				if (is_array($row)) {
 					$params = '&edit[pages_language_overlay][' . $row['uid'] . ']=edit';
 					$icon = IconUtility::getSpriteIcon('mimetypes-x-content-page-language-overlay', array('title' => $this->extGetLL('edit_editPageOverlay', FALSE)));
-					$toolBar .= '<a href="' . htmlspecialchars((TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . $returnUrl)) . '">' . $icon . '</a>';
+					$toolBar .= '<a href="' . htmlspecialchars(TYPO3_mainDir . 'alt_doc.php?' . $params . '&noView=1&returnUrl=' . rawurlencode($returnUrl)) . '">' . $icon . '</a>';
 				}
 			}
 		}
diff --git a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
index 05967b16dbdd..2a7c48596061 100644
--- a/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
+++ b/typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php
@@ -241,7 +241,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
 			}
 			// New record
 			if (!$module->modTSconfig['properties']['noCreateRecordsLink']) {
-				$onClick = htmlspecialchars(('return jumpExt(\'' . $this->backPath . 'db_new.php?id=' . $this->id . '\');'));
+				$onClick = htmlspecialchars('return jumpExt(' . GeneralUtility::quoteJSvalue(BackendUtility::getModuleUrl('db_new', ['id' => $this->id], $this->backPath)) . ');');
 				$buttons['new_record'] = '<a href="#" onclick="' . $onClick . '" title="'
 					. $lang->getLL('newRecordGeneral', TRUE) . '">'
 					. IconUtility::getSpriteIcon('actions-document-new') . '</a>';
@@ -954,8 +954,8 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
 								$icon = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars($onClick) . '" title="'
 									. $lang->getLL('new', TRUE) . '">' . $spriteIcon . '</a>';
 							} elseif ($table == 'pages' && $this->newWizards) {
-								$href = $this->backPath . 'db_new.php?id=' . $this->id
-									. '&pagesOnly=1&returnUrl=' . rawurlencode(GeneralUtility::getIndpEnv('REQUEST_URI'));
+								$parameters = ['id' => $this->id, 'pagesOnly' => 1, 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI')];
+								$href = BackendUtility::getModuleUrl('db_new', $parameters, $this->backPath);
 								$icon = '<a class="btn btn-default" href="' . htmlspecialchars($href) . '" title="' . $lang->getLL('new', TRUE) . '">'
 									. $spriteIcon . '</a>';
 							} else {
-- 
GitLab