diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index 9b020d27dafcaa87702e841a20ec8ce04609916b..cb00b027b4ebef989e56749816aa7f182f782975 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -1375,7 +1375,9 @@ class DataHandler implements LoggerAwareInterface } } if (!empty($newRecord)) { - $this->newlog2('Shadowing done on fields <i>' . implode(',', array_keys($newRecord)) . '</i> in placeholder record ' . $table . ':' . $liveRec['uid'] . ' (offline version UID=' . $id . ')', $table, $liveRec['uid'], $liveRec['pid']); + if ($this->enableLogging) { + $this->log($table, $liveRec['uid'], 0, 0, 0, 'Shadowing done on fields <i>' . implode(',', array_keys($newRecord)) . '</i> in placeholder record ' . $table . ':' . $liveRec['uid'] . ' (offline version UID=' . $id . ')', -1, [], $this->eventPid($table, $liveRec['uid'], $liveRec['pid'])); + } $this->updateDB($table, $liveRec['uid'], $newRecord); } } @@ -4878,7 +4880,9 @@ class DataHandler implements LoggerAwareInterface // Fetch the live record $parentRecordLocalization = BackendUtility::getRecordLocalization($table, $id, $command['language'], 'AND pid<>-1'); if (empty($parentRecordLocalization)) { - $this->newlog2('Localization for parent record ' . $table . ':' . $id . '" cannot be fetched', $table, $id, $parentRecord['pid']); + if ($this->enableLogging) { + $this->log($table, $id, 0, 0, 0, 'Localization for parent record ' . $table . ':' . $id . '" cannot be fetched', -1, [], $this->eventPid($table, $id, $parentRecord['pid'])); + } return; } $parentRecord = $parentRecordLocalization[0]; @@ -5306,7 +5310,9 @@ class DataHandler implements LoggerAwareInterface { $uid = (int)$uid; if ($uid === 0) { - $this->newlog2('Deleting all pages starting from the root-page is disabled.', 'pages', 0, 0, 2); + if ($this->enableLogging) { + $this->log('pages', $uid, 0, 0, 2, 'Deleting all pages starting from the root-page is disabled.', -1, [], 0); + } return; } // Getting list of pages to delete: @@ -8708,9 +8714,11 @@ class DataHandler implements LoggerAwareInterface * @param int $error Error code, see log() * @return int Log entry UID * @see log() + * @deprecated since TYPO3 v9 will be removed in TYPO3 v10.0, use DataHandler->log() directly instead. */ public function newlog2($message, $table, $uid, $pid = null, $error = 0) { + trigger_error('DataHandler->newlog2() will be removed in TYPO3 v10.0, use the generic log() function instead.', E_USER_DEPRECATED); if (!$this->enableLogging) { return 0; } diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83121-LoggingMethodDataHandler-newlog2.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83121-LoggingMethodDataHandler-newlog2.rst new file mode 100644 index 0000000000000000000000000000000000000000..4cc46cf69157a133d961a97a5a21c06dd8774be1 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-83121-LoggingMethodDataHandler-newlog2.rst @@ -0,0 +1,33 @@ +.. include:: ../../Includes.txt + +=========================================================== +Deprecation: #83121 - Logging method DataHandler->newlog2() +=========================================================== + +See :issue:`83121` + +Description +=========== + +The PHP method :php:`DataHandler->newlog2()` within DataHandler, TYPO3's core persistence API, +has been marked as deprecated. + + +Impact +====== + +Calling this method in PHP will trigger a deprecation warning. + + +Affected Installations +====================== + +Custom extensions calling DataHandler and using the method above directly in PHP. + + +Migration +========= + +Use DataHandlers' log() functionality or the TYPO3 Logging API for logging. + +.. index:: PHP-API, FullyScanned \ No newline at end of file diff --git a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php index ca0c84ab15d9a1b03079c139467e1935ef2537ce..c7900bbb9acb2432b3305067a199b7d3bc14db96 100644 --- a/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php +++ b/typo3/sysext/core/Tests/Unit/DataHandling/DataHandlerTest.php @@ -746,15 +746,15 @@ class DataHandlerTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase { /** @var DataHandler|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface $dataHandlerMock */ $dataHandlerMock = $this->getMockBuilder(DataHandler::class) - ->setMethods(['canDeletePage', 'newlog2']) + ->setMethods(['canDeletePage', 'log']) ->getMock(); $dataHandlerMock ->expects($this->never()) ->method('canDeletePage'); $dataHandlerMock ->expects($this->once()) - ->method('newlog2') - ->with('Deleting all pages starting from the root-page is disabled.', 'pages', 0, 0, 2); + ->method('log') + ->with('pages', 0, 0, 0, 2, 'Deleting all pages starting from the root-page is disabled.', -1, [], 0); $dataHandlerMock->deletePages(0); } diff --git a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php index 1780c888f3a8f4314e7a70dd3c4ce49471036cdb..99ed4e29ffecde591b64c639bf89891752d20d23 100644 --- a/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php +++ b/typo3/sysext/install/Configuration/ExtensionScanner/Php/MethodCallMatcher.php @@ -1402,4 +1402,11 @@ return [ 'Deprecation-82445-PageTranslationRelatedFunctionality.rst', ], ], + 'TYPO3\CMS\Core\DataHandling\DataHandler->newlog2' => [ + 'numberOfMandatoryArguments' => 3, + 'maximumNumberOfArguments' => 5, + 'restFiles' => [ + 'Deprecation-83121-LoggingMethodDataHandler-newlog2.rst', + ], + ], ]; diff --git a/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php b/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php index 4e751a8eccc48bf6b7939cef4c862308429662cd..bf1dc453e02a5de1ec418bcafe1002e637f62c40 100644 --- a/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php +++ b/typo3/sysext/workspaces/Classes/Hook/DataHandlerHook.php @@ -666,7 +666,11 @@ class DataHandlerHook $mail->send(); } $emailRecipients = implode(',', $emailRecipients); - $dataHandler->newlog2('Notification email for stage change was sent to "' . $emailRecipients . '"', $table, $id); + if ($dataHandler->enableLogging) { + $propertyArray = $dataHandler->getRecordProperties($table, $id); + $pid = $propertyArray['pid']; + $dataHandler->log($table, $id, 0, 0, 0, 'Notification email for stage change was sent to "' . $emailRecipients . '"', -1, [], $dataHandler->eventPid($table, $id, $pid)); + } } } @@ -732,7 +736,12 @@ class DataHandlerHook ], ['uid' => (int)$id] ); - $dataHandler->newlog2('Stage for record was changed to ' . $stageId . '. Comment was: "' . substr($comment, 0, 100) . '"', $table, $id); + + if ($dataHandler->enableLogging) { + $propertyArray = $dataHandler->getRecordProperties($table, $id); + $pid = $propertyArray['pid']; + $dataHandler->log($table, $id, 0, 0, 0, 'Stage for record was changed to ' . $stageId . '. Comment was: "' . substr($comment, 0, 100) . '"', -1, [], $dataHandler->eventPid($table, $id, $pid)); + } // TEMPORARY, except 6-30 as action/detail number which is observed elsewhere! $dataHandler->log($table, $id, 6, 0, 0, 'Stage raised...', 30, ['comment' => $comment, 'stage' => $stageId]); if ((int)$stat['stagechg_notification'] > 0) { @@ -999,7 +1008,10 @@ class DataHandlerHook // Force delete $dataHandler->deleteEl($table, $id, true); } - $dataHandler->newlog2(($swapIntoWS ? 'Swapping' : 'Publishing') . ' successful for table "' . $table . '" uid ' . $id . '=>' . $swapWith, $table, $id, $swapVersion['pid']); + if ($dataHandler->enableLogging) { + $dataHandler->log($table, $id, 0, 0, 0, ($swapIntoWS ? 'Swapping' : 'Publishing') . ' successful for table "' . $table . '" uid ' . $id . '=>' . $swapWith, -1, [], $dataHandler->eventPid($table, $id, $swapVersion['pid'])); + } + // Update reference index of the live record: $dataHandler->addRemapStackRefIndex($table, $id); // Set log entry for live record: @@ -1033,7 +1045,11 @@ class DataHandlerHook $this->notifyStageChange($wsAccess, $stageId, $table, $id, $comment, $dataHandler, $notificationAlternativeRecipients); } // Write to log with stageId -20 - $dataHandler->newlog2('Stage for record was changed to ' . $stageId . '. Comment was: "' . substr($comment, 0, 100) . '"', $table, $id); + if ($dataHandler->enableLogging) { + $propArr = $dataHandler->getRecordProperties($table, $id); + $pid = $propArr['pid']; + $dataHandler->log($table, $id, 0, 0, 0, 'Stage for record was changed to ' . $stageId . '. Comment was: "' . substr($comment, 0, 100) . '"', -1, [], $dataHandler->eventPid($table, $id, $pid)); + } $dataHandler->log($table, $id, 6, 0, 0, 'Published', 30, ['comment' => $comment, 'stage' => $stageId]); // Clear cache: