From 6427ef4951b60519d7d9b60ea33639e6f7914bb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=B6ffler?= Date: Thu, 19 Jul 2018 22:13:08 +0200 Subject: [PATCH] Throw an extension when upload without upload comment * Casts uploadComment to string before writing in DB --- .../Exception/NoUploadCommentException.php | 20 +++++++++++++++++++ html/typo3conf/ext/ter/class.tx_ter_api.php | 9 ++++++++- .../typo3conf/ext/ter/class.tx_ter_helper.php | 1 + 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 html/typo3conf/ext/ter/Classes/Exception/NoUploadCommentException.php diff --git a/html/typo3conf/ext/ter/Classes/Exception/NoUploadCommentException.php b/html/typo3conf/ext/ter/Classes/Exception/NoUploadCommentException.php new file mode 100644 index 00000000..36c6f203 --- /dev/null +++ b/html/typo3conf/ext/ter/Classes/Exception/NoUploadCommentException.php @@ -0,0 +1,20 @@ +infoData->uploadComment === '') { + throw new \T3o\Ter\Exception\NoUploadCommentException( + 'You need to set an upload comment!', + TX_TER_ERROR_UPLOADEXTENSION_NOUPLOADCOMMENT + ); + } + if (($typo3DependencyCheck = static::checkExtensionDependencyOnSupportedTypo3Version($extensionInfoData)) !== true && $uploadUserRecordArr['admin'] !== true) { switch ($typo3DependencyCheck) { case TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYINCORRECT: @@ -982,7 +989,7 @@ class tx_ter_api $extensionDetailsRow = [ 'pid' => (int)$this->parentObj->extensionsPID, 'extensionuid' => (int)$extensionUid, - 'uploadcomment' => $extensionInfoData->infoData->uploadComment, + 'uploadcomment' => (string)$extensionInfoData->infoData->uploadComment, 'lastuploadbyusername' => $accountData->username, 'lastuploaddate' => $GLOBALS['SIM_EXEC_TIME'], 'datasize' => $extensionInfoData->infoData->dataSize, diff --git a/html/typo3conf/ext/ter/class.tx_ter_helper.php b/html/typo3conf/ext/ter/class.tx_ter_helper.php index 3d299c13..e96c2078 100755 --- a/html/typo3conf/ext/ter/class.tx_ter_helper.php +++ b/html/typo3conf/ext/ter/class.tx_ter_helper.php @@ -62,6 +62,7 @@ define('TX_TER_ERROR_UPLOADEXTENSION_ACCESSDENIED', '208'); define('TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYINCORRECT', '209'); define('TX_TER_ERROR_UPLOADEXTENSION_TYPO3DEPENDENCYCHECKFAILED', '210'); define('TX_TER_ERROR_UPLOADEXTENSION_EXTENSIONVERSIONEXISTS', '211'); +define('TX_TER_ERROR_UPLOADEXTENSION_NOUPLOADCOMMENT', '212'); define('TX_TER_ERROR_REGISTEREXTENSIONKEY_DBERRORWHILEINSERTINGKEY', '300'); -- GitLab