diff --git a/.php_cs b/.php_cs index 5cc9925..b8a78bc 100644 --- a/.php_cs +++ b/.php_cs @@ -1,4 +1,5 @@ setRiskyAllowed(true) ->setRules([ @@ -7,9 +8,11 @@ return PhpCsFixer\Config::create() 'syntax' => 'short', ], 'binary_operator_spaces' => true, + 'blank_line_before_return' => true, 'concat_space' => [ 'spacing' => 'one', ], + 'declare_strict_types' => true, 'function_typehint_space' => true, 'hash_to_slash_comment' => true, 'linebreak_after_opening_tag' => true, @@ -55,13 +58,19 @@ return PhpCsFixer\Config::create() 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, 'normalize_index_brace' => true, + 'object_operator_without_whitespace' => true, 'ordered_imports' => true, 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_annotation_without_dot' => true, + 'phpdoc_indent' => true, + 'phpdoc_no_access' => true, 'phpdoc_no_package' => true, 'phpdoc_order' => true, 'phpdoc_scalar' => true, + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_trim' => true, 'phpdoc_types' => true, - 'self_accessor' => true, + 'phpdoc_var_without_name' => true, 'short_scalar_cast' => true, 'single_quote' => true, 'standardize_not_equals' => true, @@ -74,6 +83,6 @@ return PhpCsFixer\Config::create() ->in(__DIR__) ->exclude('.Build') ->exclude('Documentation') - ->exclude('Libraries') + ->exclude('Resources/Private') ->notName('ext_emconf.php') - ); \ No newline at end of file + ); diff --git a/.travis.yml b/.travis.yml index b5308ae..1d51a4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,25 +3,7 @@ language: php branches: only: - master - -php: - - 5.5 - - 5.6 - - 7 - -env: - - TYPO3_VERSION="^6.2.0" - - TYPO3_VERSION="^7.6.0" - - TYPO3_VERSION="^8.7.0" - -matrix: - exclude: - - php: 7 - env: TYPO3_VERSION="^6.2.0" - - php: 5.5 - env: TYPO3_VERSION="^8.7.0" - - php: 5.6 - env: TYPO3_VERSION="^8.7.0" + - pre-merge sudo: false cache: @@ -39,22 +21,159 @@ notifications: before_install: - if php -i | grep -q xdebug; then phpenv config-rm xdebug.ini; fi - - composer self-update - - composer --version - - if [ "$GITHUB_COMPOSER_AUTH" ]; then composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH; fi -before_script: - - git clean -dffx - - composer require typo3/cms="$TYPO3_VERSION" - - git checkout composer.json - - export TYPO3_PATH_WEB="$PWD/.Build/Web" +install: + - > + if [[ "$TYPO3" = *"dev"* ]]; then + composer config minimum-stability dev; + composer config prefer-stable true; + composer require typo3/cms-core="@dev" --no-update; + fi + - > + composer require nimut/typo3-complete:$TYPO3 + - mkdir -p .Build/public/typo3conf/ext/ + - if [ ! -L .Build/public/typo3conf/ext/dm_developerlog ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/dm_developerlog; fi + - export TYPO3_PATH_ROOT=$PWD/.Build/public + - export typo3DatabaseName=typo3 + - export typo3DatabaseHost=localhost + - export typo3DatabaseUsername=root + - export typo3DatabasePassword= script: - > - echo; - echo "Running unit tests"; - .Build/bin/phpunit -c .Build/vendor/nimut/testing-framework/res/Configuration/UnitTests.xml Tests/Unit + if [ -d "Tests/Unit" ]; then + echo; + echo "Running unit tests"; + echo; + echo; + .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php Tests/Unit/; + fi + + - > + if [ -d "Tests/Functional" ]; then + echo; + echo "Running functional tests"; + echo; + echo; + find 'Tests/Functional' -wholename '*Test.php' | parallel --gnu 'echo; echo "Running functional test suite {}"; .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php {}'; + fi + - > echo; echo "Running php lint"; - find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \; + echo; + echo; + find . -name \*.php ! -path "./.Build/*" | parallel --gnu php -d display_errors=stderr -l {} > /dev/null \;; + +jobs: + fast_finish: true + include: + - stage: test + php: 7.4 + env: TYPO3=dev-master + - stage: test + php: 7.3 + env: TYPO3=^10.4 + - stage: test + php: 7.2 + env: TYPO3=^9.5 + - stage: test + php: 7.2 + env: TYPO3=^8.7 + - stage: test + php: 7.1 + env: TYPO3=^8.7 + - stage: test + php: 7.0 + env: TYPO3=^8.7 + + - stage: 🚢 to ter + if: tag IS present AND env(TYPO3_ORG_USERNAME) IS present AND env(TYPO3_ORG_PASSWORD) IS present + php: 7.0 + env: TYPO3=^8.7 + before_install: skip + install: skip + before_script: skip + script: + - > + echo; + echo "Preparing upload of release ${TRAVIS_TAG} to TER"; + echo; + echo; + composer require --dev nimut/typo3-complete:$TYPO3; + composer require --update-no-dev helhum/ter-client:dev-master; + + # Cleanup before we upload + git reset --hard HEAD && git clean -fx; + + # Upload + TAG_MESSAGE=`git tag -n10 -l $TRAVIS_TAG | sed 's/^[0-9.]*[ ]*//g'`; + echo; + echo "Uploading release ${TRAVIS_TAG} to TER"; + echo; + echo; + .Build/bin/ter-client upload dm_developerlog . -u "$TYPO3_ORG_USERNAME" -p "$TYPO3_ORG_PASSWORD" -m "$TAG_MESSAGE"; + + - stage: ✔ with sonarqube scanner + if: type = push AND branch IN (master, pre-merge) AND env(SONAR_TOKEN) IS present AND fork = false + php: 7.2 + before_install: skip + install: + - mkdir -p .Log/coverage/ .Log/junit/ + - export TYPO3_PATH_WEB=$PWD/.Build/public + - export typo3DatabaseName=typo3 + - export typo3DatabaseHost=localhost + - export typo3DatabaseUsername=root + - export typo3DatabasePassword= + script: + - > + if [ -d "Tests" ]; then + for TYPO3 in "^8.7" "^9.5" "^10.4" "dev-master"; do + + echo; + echo "Running TYPO3 version $TYPO3"; + echo; + echo; + git clean -Xdf; + composer require --dev nimut/typo3-complete:$TYPO3; + git checkout composer.json; + VERSION=${TYPO3//[!0-9]/}; + + mkdir -p .Build/public/typo3conf/ext/ + if [ ! -L .Build/public/typo3conf/ext/dm_developerlog ]; then ln -snvf ../../../../. .Build/public/typo3conf/ext/dm_developerlog; fi + + if [ -d "Tests/Unit" ]; then + echo; + echo "Running unit tests"; + echo; + echo; + .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/UnitTestsBootstrap.php --log-junit .Log/junit/unit_$VERSION.xml --coverage-php .Log/coverage/unit_$VERSION.cov Tests/Unit/; + fi + + if [ -d "Tests/Functional" ]; then + echo; + echo "Running functional tests"; + echo; + echo; + .Build/bin/phpunit --bootstrap .Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTestsBootstrap.php --log-junit .Log/junit/functional_$VERSION.xml --coverage-php .Log/coverage/functional_$VERSION.cov Tests/Functional/; + fi + done + + echo; + echo "Merging log and coverage files"; + echo; + echo; + composer require --update-with-all-dependencies nimut/phpunit-merger; + .Build/bin/phpunit-merger coverage .Log/coverage/ .Log/coverage.xml; + .Build/bin/phpunit-merger log .Log/junit/ .Log/junit.xml; + fi + + - git fetch --unshallow || true + + - > + echo; + echo "Running SonarQube Scanner"; + echo; + echo; + sonar-scanner; + diff --git a/Classes/Controller/Devlog62Controller.php b/Classes/Controller/Devlog62Controller.php deleted file mode 100644 index f3cd330..0000000 --- a/Classes/Controller/Devlog62Controller.php +++ /dev/null @@ -1,31 +0,0 @@ -logEntryRepository->removeAll(); - - /** @var FlashMessage $message */ - $message = $this->getFlushFlashMessage(); - - $this->controllerContext->getFlashMessageQueue()->enqueue($message); - - $this->redirect('index'); - } -} diff --git a/Classes/Controller/DevlogController.php b/Classes/Controller/DevlogController.php index ea8b40d..545e273 100644 --- a/Classes/Controller/DevlogController.php +++ b/Classes/Controller/DevlogController.php @@ -1,8 +1,9 @@ logEntryRepository = $logEntryRepository; } + /** + * Backend Template Container + * + * @var string + */ + protected $defaultViewObjectName = \TYPO3\CMS\Backend\View\BackendTemplateView::class; + + /** + * Set up the doc header properly here + * + * @param ViewInterface $view + */ + protected function initializeView(ViewInterface $view) + { + /** @var BackendTemplateView $view */ + parent::initializeView($view); + if ($this->actionMethodName == 'indexAction') { + //$this->generateMenu(); + //$this->registerDocheaderButtons(); + $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue()); + } + if ($view instanceof \TYPO3\CMS\Backend\View\BackendTemplateView) { + $pageRenderer = $view->getModuleTemplate()->getPageRenderer(); + $pageRenderer->loadJquery(); + $pageRenderer->loadRequireJsModule('bootstrap'); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/ContextHelp'); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/DocumentHeader'); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/SplitButtons'); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Modal'); + $pageRenderer->loadRequireJsModule('TYPO3/CMS/Lang/Lang'); + $pageRenderer->addCssFile('EXT:dm_developerlog/Resources/Public/Css/Developerlog.css'); + } + } + public function initializeIndexAction() { $this->extkeyOptions = $this->logEntryRepository->getExtensionKeys(); @@ -53,8 +90,6 @@ public function initializeIndexAction() * @param \DieMedialen\DmDeveloperlog\Domain\Model\Constraint $constraint * * @ignorevalidation $constraint - * - * @return void */ public function indexAction(\DieMedialen\DmDeveloperlog\Domain\Model\Constraint $constraint = null) { @@ -68,7 +103,6 @@ public function indexAction(\DieMedialen\DmDeveloperlog\Domain\Model\Constraint /** * Delete all log entries - * @return void */ public function flushAction() { @@ -94,10 +128,10 @@ protected function getFlushFlashMessage() { return $this->objectManager->get( FlashMessage::class, - $this->translate('controller.log.flushed'), - $this->translate('controller.log.flushed.title'), - FlashMessage::OK, - true + $this->translate('controller.log.flushed'), + $this->translate('controller.log.flushed.title'), + FlashMessage::OK, + true ); } @@ -117,6 +151,7 @@ protected function translate($key, $vprintfParmeters = '') if ($vprintfParmeters != '' && !is_array($vprintfParmeters)) { $vprintfParmeters = [$vprintfParmeters]; } + return \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($key, 'dm_developerlog', $vprintfParmeters); } } diff --git a/Classes/Domain/Model/Constraint.php b/Classes/Domain/Model/Constraint.php index 1758529..3913e7d 100644 --- a/Classes/Domain/Model/Constraint.php +++ b/Classes/Domain/Model/Constraint.php @@ -1,8 +1,9 @@ 1) { return $query->matching($query->logicalAnd($and))->execute(); - } elseif (count($and)) { + } + if (count($and)) { return $query->matching(current($and))->execute(); } + return $this->findAll(); } @@ -85,14 +86,10 @@ public function findByConstraint(\DieMedialen\DmDeveloperlog\Domain\Model\Constr */ public function removeAll() { - if (class_exists(\TYPO3\CMS\Core\Database\ConnectionPool::class)) { - GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable($this->tableName) - ->truncate( - $this->tableName - ); - } else { - $this->getDatabaseConnection()->exec_TRUNCATEquery($this->tableName); - } + GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable($this->tableName) + ->truncate( + $this->tableName + ); } /** @@ -120,28 +117,17 @@ public function getExtensionKeys() protected function getDistinctOptions($field) { $values = []; - if (class_exists(\TYPO3\CMS\Core\Database\ConnectionPool::class)) { - $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable($this->tableName); - $rows = $queryBuilder->select($field) - ->from($this->tableName) - ->orderBy($field, 'ASC') - ->groupBy($field) - ->execute() - ->fetchAll(); - foreach ($rows as $row) { - $values[$row[$field]] = $row[$field]; - } - } else { - $values = $this->getDatabaseConnection()->exec_SELECTgetRows( - $field, - $this->tableName, - '1=1', - $field, - $field, - '', - $field - ); + $queryBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getQueryBuilderForTable($this->tableName); + $rows = $queryBuilder->select($field) + ->from($this->tableName) + ->orderBy($field, 'ASC') + ->groupBy($field) + ->execute() + ->fetchAll(); + foreach ($rows as $row) { + $values[$row[$field]] = $row[$field]; } + return array_combine(array_keys($values), array_keys($values)); } diff --git a/Classes/Log/Writer/DeveloperlogWriter.php b/Classes/Log/Writer/DeveloperlogWriter.php new file mode 100644 index 0000000..69ed3eb --- /dev/null +++ b/Classes/Log/Writer/DeveloperlogWriter.php @@ -0,0 +1,133 @@ + $this->getCurrentPageId(), + 'crdate' => $record->getCreated(), + 'tstamp' => time(), + 'request_id' => $record->getRequestId(), + 'request_type' => TYPO3_REQUESTTYPE, + 'message' => $record->getMessage(), + 'extkey' => $record->getComponent(), + ]; + + $callerData = $this->getCallerData($record->getData()); + + $insertFields['location'] = $callerData['location']; + $insertFields['line'] = $callerData['line']; + $insertFields['system'] = $callerData['system']; + + $insertFields['data_var'] = json_encode($record->getData(), JSON_PARTIAL_OUTPUT_ON_ERROR | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE); + + if (isset($GLOBALS['BE_USER']) && isset($GLOBALS['BE_USER']->user['uid'])) { + $insertFields['be_user'] = (int)$GLOBALS['BE_USER']->user['uid']; + $insertFields['workspace_uid'] = (int)$GLOBALS['BE_USER']->workspace; + } + + if (isset($GLOBALS['TSFE']) && isset($GLOBALS['TSFE']->fe_user->user['uid'])) { + $insertFields['fe_user'] = (int)$GLOBALS['TSFE']->fe_user->user['uid']; + } + $this->createLogEntry($insertFields); + } + + /** + * Add extra call data from the IntrospectionProcessor + * @param mixed $data + */ + protected function getCallerData($data): array + { + $system = false; + if (is_array($data['backtrace'])) { + $firstRecord = reset($data['backtrace']); + } else { + $firstRecord = $data; + } + $file = isset($firstRecord['file']) ? $firstRecord['file'] : ''; + if (strpos($file, $this->extSeach) > 0) { + $file = substr($file, strpos($file, $this->extSeach) + $this->extSearchLength); + } elseif (strpos($file, $this->systemSearch) > 0) { + $file = substr($file, strpos($file, $this->systemSearch) + $this->systemSearchLength); + $system = true; + } else { + $file = basename($file); + } + + return [ + 'location' => $file, + 'line' => (int)(isset($firstRecord['line']) ? $firstRecord['line'] : 0), + 'system' => $system, + ]; + } + + /** + * Get the current page ID (if cheaply available) + * + * @return int + */ + protected function getCurrentPageId(): int + { + $currentPageId = 0; + if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_FE) { + $currentPageId = $GLOBALS['TSFE']->id ?: 0; + } else { + $singletonInstances = GeneralUtility::getSingletonInstances(); + if (isset($singletonInstances[BackendConfigurationManager::class])) { // lucky us, that guy is clever + $backendConfigurationManager = GeneralUtility::makeInstance( + BackendConfigurationManager::class, + GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\QueryGenerator::class) + ); + // getDefaultBackendStoragePid() because someone made getCurrentPageId() protected + $currentPageId = $backendConfigurationManager->getDefaultBackendStoragePid(); + } else { // simplified backend check + $currentPageId = GeneralUtility::_GP('id') !== null ? (int)GeneralUtility::_GP('id') : 0; + } + } + + return (int)$currentPageId; + } + + protected function createLogEntry(array $insertFields) + { + GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->logTable) + ->insert( + $this->logTable, + $insertFields + ); + } +} diff --git a/Classes/Utility/Developerlog.php b/Classes/Utility/Developerlog.php index 42912b1..07a0b2e 100644 --- a/Classes/Utility/Developerlog.php +++ b/Classes/Utility/Developerlog.php @@ -1,8 +1,9 @@ 1, 'excludeKeys' => 'TYPO3\CMS\Core\Authentication\AbstractUserAuthentication, TYPO3\CMS\Backend\Template\DocumentTemplate, extbase', @@ -30,18 +35,19 @@ class Developerlog implements \TYPO3\CMS\Core\SingletonInterface 'includeCallerInformation' => 1, ]; - /** @var string $request_id */ + /** @var string */ protected $request_id = ''; - /** @var int $request_type */ + /** @var int */ protected $request_type = 0; - /** @var array $excludeKeys */ + /** @var array */ protected $excludeKeys = []; /** @var int $currentPageId */ protected $currentPageId = null; + /** @var string */ protected $systemSearch = '/sysext/'; protected $systemSearchLength = 8; @@ -50,29 +56,22 @@ class Developerlog implements \TYPO3\CMS\Core\SingletonInterface protected $extSearchLength = 15; - /** - * @var array $requestTypeMap Sad duplicate from \TYPO3\CMS\Core\Core\Bootstrap - */ - protected $requestTypeMap = [ - 1 => 'TYPO3_REQUESTTYPE_FE', - 2 => 'TYPO3_REQUESTTYPE_BE', - 4 => 'TYPO3_REQUESTTYPE_CLI', - 8 => 'TYPO3_REQUESTTYPE_AJAX', - 16 => 'TYPO3_REQUESTTYPE_INSTALL', - ]; - /** * Constructor * The constructor just reads the extension configuration and stores it in a member variable + * + * @param array $options */ - public function __construct() + public function __construct(array $options = []) { - $extConf = []; - if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey])) { - $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]); + if (class_exists('TYPO3\CMS\\Core\\Configuration\\ExtensionConfiguration')) { // v9+ + $this->extConf = GeneralUtility::makeInstance('TYPO3\CMS\\Core\\Configuration\\ExtensionConfiguration')->get('dm_developerlog'); + } else { + if (isset($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dm_developerlog'])) { + $this->extConf = (array)\unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dm_developerlog']); + } } - $this->extConf = array_merge($this->extConf, $extConf); - $this->request_id = \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getRequestId(); + $this->request_id = $this->getRequestIdFromBootstrapOrLogManager(); $this->request_type = TYPO3_REQUESTTYPE; $this->excludeKeys = GeneralUtility::trimExplode(',', $this->extConf['excludeKeys'], true); } @@ -87,7 +86,6 @@ public function __construct() * but anything but a resource should work * * @param array $logArray : log data array - * @return void */ public function devLog($logArray) { @@ -104,14 +102,17 @@ public function devLog($logArray) $insertFields = $this->getBasicDeveloperLogInformation($logArray); if (!empty($this->extConf['includeCallerInformation'])) { - $callerData = $this->getCallerInformation(debug_backtrace(false)); + $callerData = $this->getCallerInformation(debug_backtrace(0)); $insertFields['location'] = $callerData['location']; $insertFields['line'] = $callerData['line']; $insertFields['system'] = $callerData['system']; } if ($this->extConf['dataCap'] !== 0 && isset($logArray['dataVar']) && !is_resource($logArray['dataVar'])) { - $insertFields['data_var'] = substr($this->getExtraData($logArray['dataVar']), 0, - (int)$this->extConf['dataCap']); + $insertFields['data_var'] = substr( + $this->getExtraData($logArray['dataVar']), + 0, + (int)$this->extConf['dataCap'] + ); } $this->createLogEntry($insertFields); } @@ -123,11 +124,12 @@ public function devLog($logArray) * * @return array */ - protected function getBasicDeveloperLogInformation($logArray) + protected function getBasicDeveloperLogInformation($logArray): array { $insertFields = [ 'pid' => $this->getCurrentPageId(), 'crdate' => microtime(true), + 'tstamp' => time(), 'request_id' => $this->request_id, 'request_type' => $this->request_type, 'line' => 0, @@ -142,13 +144,14 @@ protected function getBasicDeveloperLogInformation($logArray) $insertFields['fe_user'] = (int)$GLOBALS['TSFE']->fe_user->user['uid']; } - $insertFields['message'] = strip_tags($logArray['msg']); + $insertFields['message'] = strip_tags($logArray['msg'] ?? ''); // There's no reason to have any markup in the extension key - $insertFields['extkey'] = strip_tags($logArray['extKey']); + $insertFields['extkey'] = strip_tags($logArray['extKey'] ?? ''); // Severity can only be a number - $insertFields['severity'] = intval($logArray['severity']); + $insertFields['severity'] = intval($logArray['severity'] ?? -1); + return $insertFields; } @@ -166,15 +169,18 @@ protected function getCurrentPageId() $this->currentPageId = $GLOBALS['TSFE']->id ?: 0; } else { $singletonInstances = GeneralUtility::getSingletonInstances(); - if (isset($singletonInstances[\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager::class])) { // lucky us, that guy is clever - $backendConfigurationManager = GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager::class, - GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\QueryGenerator::class)); + if (isset($singletonInstances[BackendConfigurationManager::class])) { // lucky us, that guy is clever + $backendConfigurationManager = GeneralUtility::makeInstance( + BackendConfigurationManager::class, + GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\QueryGenerator::class) + ); // getDefaultBackendStoragePid() because someone made getCurrentPageId() protected $this->currentPageId = $backendConfigurationManager->getDefaultBackendStoragePid(); } else { // simplified backend check $this->currentPageId = GeneralUtility::_GP('id') !== null ? (int)GeneralUtility::_GP('id') : 0; } } + return $this->currentPageId; } @@ -200,6 +206,7 @@ protected function getCallerInformation(array $backtrace) } else { $file = basename($file); } + return [ 'location' => $file, 'line' => $entry['line'], @@ -207,6 +214,7 @@ protected function getCallerInformation(array $backtrace) ]; } } + return [ 'location' => '--- unknown ---', 'line' => 0, @@ -227,32 +235,49 @@ protected function getExtraData($extraData) if (isset($this->extConf['dataCap'])) { return substr($serializedData, 0, min(strlen($serializedData), (int)$this->extConf['dataCap'])); } + return $serializedData; } + return ''; } /** - * @return \TYPO3\CMS\Core\Database\DatabaseConnection + * Add a log entry + * @param mixed $insertFields */ - protected function getDatabaseConnection() + protected function createLogEntry($insertFields) { - return $GLOBALS['TYPO3_DB']; + GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable($this->logTable) + ->insert( + $this->logTable, + $insertFields + ); } - protected function createLogEntry($insertFields) + /** + * Get the request id + * + * @return string + */ + protected function getRequestIdFromBootstrapOrLogManager(): string { - if (class_exists(\TYPO3\CMS\Core\Database\ConnectionPool::class)) { - GeneralUtility::makeInstance(\TYPO3\CMS\Core\Database\ConnectionPool::class)->getConnectionForTable($this->logTable) - ->insert( - $this->logTable, - $insertFields - ); - } else { - $db = $this->getDatabaseConnection(); - if ($db !== null) { // this can happen when devLog is called to early in the bootstrap process - @$db->exec_INSERTquery($this->logTable, $insertFields); + if (\is_callable('\TYPO3\CMS\Core\Bootstrap::getInstance')) { + $bootstrap = Bootstrap::getInstance(); + if (method_exists($bootstrap, 'getRequestId')) { + return Bootstrap::getInstance()->getRequestId(); } } + // Thank you TYPO3 9+ and the impossibe task to get the global request.id + $logManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Log\LogManager::class); + $reflectedLogManager = new \ReflectionClass($logManager); + if ($reflectedLogManager->hasProperty('requestId')) { + $property = $reflectedLogManager->getProperty('requestId'); + $property->setAccessible(true); + + return $property->getValue($logManager); + } + + return 'fake-' . substr(md5(uniqid('', true)), 0, 13); } } diff --git a/Classes/ViewHelpers/BitMaskViewHelper.php b/Classes/ViewHelpers/TYPO3Fluid/BitMaskViewHelper.php similarity index 68% rename from Classes/ViewHelpers/BitMaskViewHelper.php rename to Classes/ViewHelpers/TYPO3Fluid/BitMaskViewHelper.php index 24dbf69..e04448b 100644 --- a/Classes/ViewHelpers/BitMaskViewHelper.php +++ b/Classes/ViewHelpers/TYPO3Fluid/BitMaskViewHelper.php @@ -1,8 +1,9 @@ $value, - 'mask' => $mask, - ], - $this->buildRenderChildrenClosure(), - $this->renderingContext - ); + $this->registerArgument('value', 'int', 'The value to be bitmasked', false); + $this->registerArgument('mask', 'array|string', 'The bit mask', false); } /** @@ -71,6 +64,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl $masked[] = $v; } } + return $masked; } } diff --git a/Classes/ViewHelpers/MapToHelperClassViewHelper.php b/Classes/ViewHelpers/TYPO3Fluid/MapToHelperClassViewHelper.php similarity index 69% rename from Classes/ViewHelpers/MapToHelperClassViewHelper.php rename to Classes/ViewHelpers/TYPO3Fluid/MapToHelperClassViewHelper.php index 4c4c7f3..11fea4a 100644 --- a/Classes/ViewHelpers/MapToHelperClassViewHelper.php +++ b/Classes/ViewHelpers/TYPO3Fluid/MapToHelperClassViewHelper.php @@ -1,8 +1,9 @@ 'danger', ]; - /** - * @param int $severity - * @return string bootstrap color mapped value - */ - public function render($severity = -2) + public function initializeArguments() { - return static::renderStatic( - [ - 'severity' => $severity, - ], - $this->buildRenderChildrenClosure(), - $this->renderingContext - ); + $this->registerArgument('severity', 'int', 'Log level severity (-1 to 3).', false); } /** @@ -62,6 +57,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl if (!isset(self::$map[$severity])) { $severity = self::$defaultSeverity; } + return self::$map[$severity]; } } diff --git a/Classes/ViewHelpers/UsernameViewHelper.php b/Classes/ViewHelpers/TYPO3Fluid/UsernameViewHelper.php similarity index 73% rename from Classes/ViewHelpers/UsernameViewHelper.php rename to Classes/ViewHelpers/TYPO3Fluid/UsernameViewHelper.php index 7ae2a88..4b379d2 100644 --- a/Classes/ViewHelpers/UsernameViewHelper.php +++ b/Classes/ViewHelpers/TYPO3Fluid/UsernameViewHelper.php @@ -1,8 +1,9 @@ $uid, - 'backend' => $backend, - ], - $this->buildRenderChildrenClosure(), - $this->renderingContext - ); + $this->registerArgument('uid', 'int', 'BE user uid.', true); + $this->registerArgument('backend', 'bool', 'be or fe', false, true); } /** @@ -65,6 +56,7 @@ public static function renderStatic(array $arguments, \Closure $renderChildrenCl $identifier = $backendOrFrontend . '-' . $uid; $userName = static::getUserName(!empty($arguments['backend']), $uid, $identifier); + return htmlspecialchars($userName); } @@ -89,6 +81,7 @@ protected static function getUserName($backend, $uid, $identifier) // $user may be NULL if user was deleted from DB, set it to empty string to always return a string static::$usernameRuntimeCache[$identifier] = ($user === null) ? '' : $user->getUserName(); } + return static::$usernameRuntimeCache[$identifier]; } } diff --git a/Documentation/About/Index.rst b/Documentation/About/Index.rst index e8be8c8..d64036e 100644 --- a/Documentation/About/Index.rst +++ b/Documentation/About/Index.rst @@ -9,17 +9,18 @@ What does it do? ================ + This extension implements hooks into TYPO3 CMS devlog hook to capture devlog entries. It provides a backend module for easy access to those log entries. - Based on extbase & fluid - Tries to adhere to TYPO3 CMS UI standards -- Supports 7.6 LTS and 8.0 Dev (and 6.2) +- Supports 8.7 LTS and 9.5 LTS and 10.4 LTS .. figure:: ../Images/Module/ModuleBootstrap.png :alt: TYPO3 7.6+ Backend. -- There is a simplified but functionally equivalent backend module for TYPO3 6.2 +Table Garbage Collector Task +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. figure:: ../Images/Module/Module62.png - :alt: TYPO3 6.2 Backend. +When a table garbage collector task is configured this extension will hook into it's configuration to automatically delete old data. \ No newline at end of file diff --git a/Documentation/Images/Module/Module62.png b/Documentation/Images/Module/Module62.png deleted file mode 100644 index b20ab7a..0000000 Binary files a/Documentation/Images/Module/Module62.png and /dev/null differ diff --git a/Documentation/Index.rst b/Documentation/Index.rst index 31550c6..20fd17c 100644 --- a/Documentation/Index.rst +++ b/Documentation/Index.rst @@ -58,5 +58,6 @@ Development log About/Index Installation/Index Configuration/Index + LogWriter/Index Support/Index Links diff --git a/Documentation/Installation/Index.rst b/Documentation/Installation/Index.rst index 19fab05..50109b0 100644 --- a/Documentation/Installation/Index.rst +++ b/Documentation/Installation/Index.rst @@ -34,10 +34,6 @@ Get it via Composer Require the package ``diemedialen/dm-developerlog``. -.. important:: - - This extension has never been tested with TYPO3 6.2 and composer. Good luck! - Get it from github ------------------ diff --git a/Documentation/Links.rst b/Documentation/Links.rst index f1ec1dc..abfa584 100644 --- a/Documentation/Links.rst +++ b/Documentation/Links.rst @@ -15,7 +15,7 @@ Links https://typo3.org/extensions/repository/view/dm_developerlog :Bug Tracker: - https://forge.typo3.org/projects/extension-dm_developerlog/issues + https://github.com/pschriner/dm_developerlog/issues :Git Repository: https://github.com/pschriner/dm_develogerlog diff --git a/Documentation/LogWriter/Index.rst b/Documentation/LogWriter/Index.rst new file mode 100644 index 0000000..9077746 --- /dev/null +++ b/Documentation/LogWriter/Index.rst @@ -0,0 +1,45 @@ +.. ================================================== +.. FOR YOUR INFORMATION +.. -------------------------------------------------- +.. -*- coding: utf-8 -*- with BOM. + +.. include:: ../Includes.txt + +.. _LoggingAPI: https://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Logging/Index.html + +.. _logwriter: + +LogWriter +============ + +As of TYPO3 9 the devLog mechanism is deprecated. The recommended way is to use the standard LoggingAPI_. + +The LogWriter class is :code:`\DieMedialen\DmDeveloperlog\Log\Writer\DeveloperlogWriter`. + +Note +---- + +When used as a LogWriter, dm_developerlog will ignore all configuration settings (as the Logging API provides them differently). + +Usage +----- + +.. code-block:: php + + $GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['Backend']['writerConfiguration'] = [ + \TYPO3\CMS\Core\Log\LogLevel::ERROR => [ + 'DieMedialen\\DmDeveloperlog\\Log\\Writer\\DeveloperlogWriter' => [] + ] + ]; + +to add file / location data, you have to configure a suitable processor + +.. code-block:: php + + $GLOBALS['TYPO3_CONF_VARS']['LOG']['TYPO3']['CMS']['Backend']['processorConfiguration'] = [ + \TYPO3\CMS\Core\Log\LogLevel::ERROR => [ + 'TYPO3\\CMS\\Core\\Log\\Processor\\IntrospectionProcessor' => [ + 'appendFullBackTrace' => TRUE + ] + ] + ]; diff --git a/Documentation/Settings.cfg b/Documentation/Settings.cfg new file mode 100644 index 0000000..b8ebd08 --- /dev/null +++ b/Documentation/Settings.cfg @@ -0,0 +1,2 @@ +[general] +project = Developer log \ No newline at end of file diff --git a/Documentation/Support/Index.rst b/Documentation/Support/Index.rst index 63a086a..1e5b75f 100644 --- a/Documentation/Support/Index.rst +++ b/Documentation/Support/Index.rst @@ -10,9 +10,9 @@ Need Support? ============= -Forge +Github ----- -Go to https://forge.typo3.org/projects/extension-dm_developerlog and you might get some support. +Go to https://github.com/pschriner/dm_developerlog/issues and you might get some support. Note on "Missing" features -------------------------- diff --git a/README.md b/README.md index 140bd80..2b9d70b 100644 --- a/README.md +++ b/README.md @@ -13,12 +13,24 @@ Extension to capture development log entries. Open the TYPO3 module "**Extensions**". Select "**Get Extensions**". Search for and install extension key "**dm_developerlog**". Activate the "**dm_developerlog**" extension within in the installed extensions list. -## Activate logging +## Activate logging (devLog) For the ``dm_developerlog`` extension to work you have to enable TYPO3s developer logging mechanism. Visit the install tool and search for **dlog**. Enable suitable options. +## LogWriter (Logging API) + +This extension provides a suitable LogWriter class: + +``\DieMedialen\DmDeveloperlog\Log\Writer\DeveloperlogWriter`` + +It is most useful when combined with the IntrospectionProcessor. + +**Note**: None of the extension configuration is used when using the LogWriter as the TYPO3 logging API provides suitable options. + # Special thanks -To the original authors of ``devlog``. \ No newline at end of file +To the original authors of ``devlog``. + +To @IchHabRecht for showing me a sane way to maintain this extension (travis config) \ No newline at end of file diff --git a/Resources/Private/Layouts/Backend/62/Default.html b/Resources/Private/Layouts/Backend/62/Default.html deleted file mode 100644 index d51f12f..0000000 --- a/Resources/Private/Layouts/Backend/62/Default.html +++ /dev/null @@ -1,31 +0,0 @@ - -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-

- -
-
-
-
diff --git a/Resources/Private/Layouts/Backend/Default.html b/Resources/Private/Layouts/Backend/Default.html index c8ce29e..e4f1b94 100644 --- a/Resources/Private/Layouts/Backend/Default.html +++ b/Resources/Private/Layouts/Backend/Default.html @@ -1,25 +1,3 @@ - -
- -
-

- -
-
-
+ + + diff --git a/Resources/Private/Partials/62/SeverityIcon.html b/Resources/Private/Partials/62/SeverityIcon.html deleted file mode 100644 index dc2d97f..0000000 --- a/Resources/Private/Partials/62/SeverityIcon.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Resources/Private/Partials/62/Table.html b/Resources/Private/Partials/62/Table.html deleted file mode 100644 index bc54bc4..0000000 --- a/Resources/Private/Partials/62/Table.html +++ /dev/null @@ -1,46 +0,0 @@ -{namespace be=TYPO3\CMS\Backend\ViewHelpers} -{namespace devlog=DieMedialen\DmDeveloperlog\ViewHelpers} - - - - - - - - - - - - - - - - - - - - - - - - - - -
 :
{logEntry.crdate}{logEntry.requestId} - - - SYS - EXT - - {logEntry.location}:{logEntry.line} - - {logEntry.message}
  - - - -
- -
{logEntry.dataVar}
-
-
-
\ No newline at end of file diff --git a/Resources/Private/Partials/FluidTYPO3/MapToHelperClass.html b/Resources/Private/Partials/FluidTYPO3/MapToHelperClass.html new file mode 100644 index 0000000..5226f1f --- /dev/null +++ b/Resources/Private/Partials/FluidTYPO3/MapToHelperClass.html @@ -0,0 +1,2 @@ +{namespace devlog=DieMedialen\DmDeveloperlog\ViewHelpers} +{logEntry.severity -> devlog:TYPO3Fluid.mapToHelperClass()} \ No newline at end of file diff --git a/Resources/Private/Partials/62/Properties.html b/Resources/Private/Partials/FluidTYPO3/Properties.html similarity index 55% rename from Resources/Private/Partials/62/Properties.html rename to Resources/Private/Partials/FluidTYPO3/Properties.html index 101fd48..ef70865 100644 --- a/Resources/Private/Partials/62/Properties.html +++ b/Resources/Private/Partials/FluidTYPO3/Properties.html @@ -1,10 +1,11 @@ +{namespace be=TYPO3\CMS\Backend\ViewHelpers} {namespace devlog=DieMedialen\DmDeveloperlog\ViewHelpers}
{logEntry.extkey}
-
+
@@ -16,15 +17,16 @@
{logEntry.workspaceUid}
- +
- -
+ + +
- +
-
+
\ No newline at end of file diff --git a/Resources/Private/Partials/MapToHelperClass.html b/Resources/Private/Partials/MapToHelperClass.html new file mode 100644 index 0000000..4bc6f28 --- /dev/null +++ b/Resources/Private/Partials/MapToHelperClass.html @@ -0,0 +1,2 @@ +{namespace devlog=DieMedialen\DmDeveloperlog\ViewHelpers} +{logEntry.severity -> devlog:mapToHelperClass()} \ No newline at end of file diff --git a/Resources/Private/Partials/Table.html b/Resources/Private/Partials/Table.html index 736b7e2..ba99d2b 100644 --- a/Resources/Private/Partials/Table.html +++ b/Resources/Private/Partials/Table.html @@ -1,5 +1,4 @@ {namespace be=TYPO3\CMS\Backend\ViewHelpers} -{namespace devlog=DieMedialen\DmDeveloperlog\ViewHelpers} @@ -13,7 +12,7 @@ - + @@ -29,7 +28,7 @@ - +
{logEntry.crdate} {logEntry.requestId}{logEntry.message}
diff --git a/Resources/Private/Templates/Devlog/Index.html b/Resources/Private/Templates/Devlog/Index.html index 62f231b..f5edd6e 100644 --- a/Resources/Private/Templates/Devlog/Index.html +++ b/Resources/Private/Templates/Devlog/Index.html @@ -4,7 +4,7 @@ This is the template for TYPO3 7.6+; Bootstrap-based - Development Log +

Development Log

diff --git a/Resources/Private/Templates/Devlog62/Flush.html b/Resources/Private/Templates/Devlog62/Flush.html deleted file mode 100644 index 0519ecb..0000000 --- a/Resources/Private/Templates/Devlog62/Flush.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Resources/Private/Templates/Devlog62/Index.html b/Resources/Private/Templates/Devlog62/Index.html deleted file mode 100644 index 6c2928b..0000000 --- a/Resources/Private/Templates/Devlog62/Index.html +++ /dev/null @@ -1,61 +0,0 @@ -{namespace devlog=DieMedialen\DmDeveloperlog\ViewHelpers} - - -This is the template for TYPO3 6.2; Non-Bootstrap - - - Development Log - - - - - - -
- - - - - - - - - -
-

 

- - - - - - - - - - - - - - - - - - - - - - -
\ No newline at end of file diff --git a/Resources/Public/Css/Developerlog.css b/Resources/Public/Css/Developerlog.css index 0360c77..d0fef17 100644 --- a/Resources/Public/Css/Developerlog.css +++ b/Resources/Public/Css/Developerlog.css @@ -1,4 +1,4 @@ -.table > tbody > tr > td.zeroPadding { +#dm-developerlog-list tr td.zeroPadding { padding: 0 !important; border-top:0; } diff --git a/Tests/Unit/Controller/Devlog62ControllerTest.php b/Tests/Unit/Controller/Devlog62ControllerTest.php deleted file mode 100644 index a712bdb..0000000 --- a/Tests/Unit/Controller/Devlog62ControllerTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertNotNull($instance); } } diff --git a/Tests/Unit/Utility/DeveloperlogTest.php b/Tests/Unit/Utility/DeveloperlogTest.php index b4b1078..9aaa785 100644 --- a/Tests/Unit/Utility/DeveloperlogTest.php +++ b/Tests/Unit/Utility/DeveloperlogTest.php @@ -2,7 +2,7 @@ namespace DieMedialen\DmDeveloperlog\Tests\Unit\Utility; /** - * This file is part of the TYPO3 CMS project. + * This file is part of the dm_developerlog 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 @@ -14,19 +14,40 @@ * The TYPO3 project - inspiring people to share! */ use DieMedialen\DmDeveloperlog\Utility\Developerlog; +use TYPO3\CMS\Core\Configuration\ConfigurationManager; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Tests for Developerlog - * */ class DeveloperlogTest extends \Nimut\TestingFramework\TestCase\UnitTestCase { + /** + * Create LocalConfiguration.php or export Configuration to $GLOBALS['TYPO3_CONF_VARS'] + */ + public static function setUpBeforeClass() + { + try { + GeneralUtility::makeInstance(ConfigurationManager::class)->createLocalConfigurationFromFactoryConfiguration(); + } catch (\RuntimeException $rte) { + if ($rte->getCode() !== 1364836026) { // pretty hacky: 1364836026 means LocalConfiguration.php was already there + throw $rte; + } + } + if (class_exists('TYPO3\CMS\\Core\\Configuration\\ExtensionConfiguration')) { // v9+ + GeneralUtility::makeInstance('TYPO3\CMS\\Core\\Configuration\\ExtensionConfiguration')->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions(); + } else { + GeneralUtility::makeInstance(ConfigurationManager::class)->exportConfiguration(); + } + } + /** * @test */ public function canInstanceDevlog() { $instance = new Developerlog(); + $this->assertNotNull($instance); } /** @@ -34,13 +55,9 @@ public function canInstanceDevlog() */ public function basicFunctionality() { - $old = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dm_developerlog']; - $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dm_developerlog'] = serialize(['excludeKeys' => 'TEST']); $mock = $this->getAccessibleMock(Developerlog::class, ['createLogEntry']); $this->assertNull($mock->devLog(['severity' => -4])); $this->assertNull($mock->devLog(['extKey' => 'TEST'])); - - $mock->expects($this->once())->method('createLogEntry')->will($this->returnValue(42)); $this->assertNull($mock->devLog(['severity' => 3])); } } diff --git a/Tests/Unit/ViewHelpers/BitMaskViewHelperTest.php b/Tests/Unit/ViewHelpers/BitMaskViewHelperTest.php index a74c048..d9051c8 100644 --- a/Tests/Unit/ViewHelpers/BitMaskViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/BitMaskViewHelperTest.php @@ -2,7 +2,7 @@ namespace DieMedialen\DmDeveloperlog\Tests\Unit\ViewHelpers; /** - * This file is part of the TYPO3 CMS project. + * This file is part of the dm_developerlog 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 @@ -13,12 +13,11 @@ * * The TYPO3 project - inspiring people to share! */ -use DieMedialen\DmDeveloperlog\ViewHelpers\BitMaskViewHelper; +use DieMedialen\DmDeveloperlog\ViewHelpers\TYPO3Fluid\BitMaskViewHelper; use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext; /** * Tests for BitMaskViewHelper - * */ class BitMaskViewHelperTest extends \Nimut\TestingFramework\TestCase\ViewHelperBaseTestcase { diff --git a/Tests/Unit/ViewHelpers/MapToHelperClassViewHelperTest.php b/Tests/Unit/ViewHelpers/MapToHelperClassViewHelperTest.php index 61ba20b..d48ddca 100644 --- a/Tests/Unit/ViewHelpers/MapToHelperClassViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/MapToHelperClassViewHelperTest.php @@ -2,7 +2,7 @@ namespace DieMedialen\DmDeveloperlog\Tests\Unit\ViewHelpers; /** - * This file is part of the TYPO3 CMS project. + * This file is part of the dm_developerlog 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 @@ -13,12 +13,11 @@ * * The TYPO3 project - inspiring people to share! */ -use DieMedialen\DmDeveloperlog\ViewHelpers\MapToHelperClassViewHelper; +use DieMedialen\DmDeveloperlog\ViewHelpers\TYPO3Fluid\MapToHelperClassViewHelper; use TYPO3\CMS\Fluid\Core\Rendering\RenderingContext; /** * Tests for MapToHelperClassViewHelper - * */ class MapToHelperClassViewHelperTest extends \Nimut\TestingFramework\TestCase\ViewHelperBaseTestcase { diff --git a/Tests/Unit/ViewHelpers/UsernameViewHelperTest.php b/Tests/Unit/ViewHelpers/UsernameViewHelperTest.php index 8c97257..6c7b3fa 100644 --- a/Tests/Unit/ViewHelpers/UsernameViewHelperTest.php +++ b/Tests/Unit/ViewHelpers/UsernameViewHelperTest.php @@ -2,7 +2,7 @@ namespace DieMedialen\DmDeveloperlog\Tests\Unit\ViewHelpers; /** - * This file is part of the TYPO3 CMS project. + * This file is part of the dm_developerlog 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 @@ -13,11 +13,10 @@ * * The TYPO3 project - inspiring people to share! */ -use DieMedialen\DmDeveloperlog\ViewHelpers\UsernameViewHelper; +use DieMedialen\DmDeveloperlog\ViewHelpers\TYPO3Fluid\UsernameViewHelper; /** * Tests for UsernameViewHelper - * */ class UsernameViewHelperTest extends \Nimut\TestingFramework\TestCase\ViewHelperBaseTestcase { diff --git a/composer.json b/composer.json index 30b3c47..c8137f5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "diemedialen/dm-developerlog", "description": "An extension to capture TYPO3 devlog messages for debugging. Provides a backend module.", "type": "typo3-cms-extension", - "license": "GPL-2.0+", + "license": "GPL-2.0-or-later", "authors": [ { "name": "Patrick Schriner", @@ -14,12 +14,11 @@ "issues": "https://github.com/pschriner/dm_developerlog/issues" }, "require": { - "php": ">=5.5.0", - "typo3/cms-core": "^6.2 || ^7.6 || ^8.7" + "php": ">=7.0, < 8.0", + "typo3/cms-core": "^8.7 || ^9.5.25 || ^10.4.14 || dev-master" }, "require-dev": { - "nimut/testing-framework": "^1.1", - "phpunit/phpunit": "~4.8.0" + "nimut/testing-framework": "^5.0" }, "autoload": { "psr-4": { @@ -31,18 +30,16 @@ "DieMedialen\\DmDeveloperlog\\Tests\\": "Tests" } }, - "replace": { - "dm_developerlog": "self.version", - "typo3-ter/dm-developerlog": "self.version" - }, "config": { "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin" }, "extra": { "typo3/cms": { - "cms-package-dir": "{$vendor-dir}/typo3/cms", - "web-dir": ".Build/Web" + "extension-key": "dm_developerlog", + "cms-package-dir": "{$vendor-dir}/typo3/cms", + "app-dir": ".Build", + "web-dir": ".Build/public" } - } +} } \ No newline at end of file diff --git a/ext_conf_template.txt b/ext_conf_template.txt index f80e867..1f49b85 100644 --- a/ext_conf_template.txt +++ b/ext_conf_template.txt @@ -1,9 +1,7 @@ -# customsubcategory=filtering=Filtering - -# cat=basic/filtering/a; type=options[Ok(-1)=-1,Info(0)=0,Notice(1)=1,Warning(2)=2,Error(3)=3]; label=Minimum level for logging: Minimum message level required for actually writing to the log table +# cat=basic/enable/a; type=options[Ok(-1)=-1,Info(0)=0,Notice(1)=1,Warning(2)=2,Error(3)=3]; label=Minimum level for logging: Minimum message level required for actually writing to the log table minLogLevel = -1 -# cat=basic/filtering/b; type=string; label=Exclude keys: Comma-separated list of (extension) keys that should not be logged into the Development Log +# cat=basic/enable/b; type=string; label=Exclude keys: Comma-separated list of (extension) keys that should not be logged into the Development Log excludeKeys = TYPO3\CMS\Core\Authentication\AbstractUserAuthentication, TYPO3\CMS\Backend\Template\DocumentTemplate, extbase # cat=advanced/limits/a; type=integer; label=Maximum size of extra data: The extra data field accepts an array containing any number of data. However when that array becomes too large, writing it to the database may actually crash you server. It is recommended to set a limit (in number of characters). If not set, the DBMS might truncate the data if there is insufficient space. diff --git a/ext_emconf.php b/ext_emconf.php index 9232240..7ef9054 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -6,9 +6,9 @@ $EM_CONF[$_EXTKEY] = array ( 'title' => 'Development log', - 'description' => 'An extension to capture TYPO3 devlog messages for debugging. Provides a backend module.', + 'description' => 'An extension to capture TYPO3 devlog messages for debugging. Provides a backend module and a LogWriter', 'category' => 'misc', - 'version' => '0.7.2', + 'version' => '1.0.0', 'state' => 'beta', 'uploadfolder' => false, 'author' => 'Patrick Schriner', @@ -16,8 +16,8 @@ 'author_company' => 'DieMedialen GmbH', 'constraints' => array ( 'depends' => array( - 'php' => '5.5.0-0.0.0', - 'typo3' => '6.2.7-8.7.2', + 'php' => '7.0.0-7.4.99', + 'typo3' => '8.7.99-10.4.99', ), 'conflicts' => array(), 'suggests' => array(), diff --git a/ext_localconf.php b/ext_localconf.php index 72bf34a..47d69b9 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -2,6 +2,10 @@ if (!defined('TYPO3_MODE')) { die('Access denied.'); } -if (version_compare(PHP_VERSION, '5.5.0') >= 0) { // this is a hard requirement - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'][$_EXTKEY] = 'DieMedialen\DmDeveloperlog\Utility\Developerlog->devLog'; + +if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables']['tx_dmdeveloperlog_domain_model_logentry'])) { + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\TYPO3\CMS\Scheduler\Task\TableGarbageCollectionTask::class]['options']['tables']['tx_dmdeveloperlog_domain_model_logentry'] = [ + 'dateField' => 'tstamp', + 'expirePeriod' => '30' + ]; } diff --git a/ext_tables.php b/ext_tables.php index c4a88b9..ce18876 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,41 +1,23 @@ = 7006000) { - $boot = function ($extension) { - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\IconRegistry'); - $iconRegistry->registerIcon('module-dmdeveloperlog', \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider::class, ['name' => 'ambulance']); - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( - 'DieMedialen.dm_developerlog', - 'system', - 'dm_developerlog', - 'after:BelogLog', - ['Devlog' => 'index,flush'], - [ - 'access' => 'admin', - 'icon' => \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch) > 8000000 ? '' : 'EXT:' . $extension . '/ext_icon.png', - 'iconIdentifier' => 'module-dmdeveloperlog', - 'labels' => 'LLL:EXT:' . $extension . '/Resources/Private/Language/locallang_mod.xlf', - 'cssFiles' => ['EXT:' . $extension . '/Resources/Public/Css/Backend.css'], - ] - ); - }; - $boot($_EXTKEY); - unset($boot); - } else { // 6.2 - \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( - 'DieMedialen.' . $_EXTKEY, - 'system', // Make module a submodule of 'web' - 'dm_developerlog', // Submodule key - 'after:BelogLog', // Position - ['Devlog62' => 'index,flush'], - [ - 'access' => 'admin', - 'icon' => 'EXT:' . $_EXTKEY . '/ext_icon.png', - 'labels' => 'LLL:EXT:dm_developerlog/Resources/Private/Language/locallang_mod.xlf', - 'cssFiles' => ['EXT:dm_developerlog/Resources/Public/Css/Backend.css'], - ] - ); - } -} +$boot = function ($extension) { + $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); + $iconRegistry->registerIcon('module-dmdeveloperlog', \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider::class, ['name' => 'ambulance']); + \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule( + 'DieMedialen.dm_developerlog', + 'system', + 'dm_developerlog', + 'after:BelogLog', + ['Devlog' => 'index,flush'], + [ + 'access' => 'admin', + 'icon' => '', + 'iconIdentifier' => 'module-dmdeveloperlog', + 'labels' => 'LLL:EXT:' . $extension . '/Resources/Private/Language/locallang_mod.xlf', + 'cssFiles' => ['EXT:' . $extension . '/Resources/Public/Css/Backend.css'], + ] + ); +}; +$boot('dm_developerlog'); +unset($boot); diff --git a/ext_tables.sql b/ext_tables.sql index 522357a..82b4e49 100644 --- a/ext_tables.sql +++ b/ext_tables.sql @@ -5,6 +5,7 @@ CREATE TABLE tx_dmdeveloperlog_domain_model_logentry ( uid int(11) unsigned DEFAULT '0' NOT NULL auto_increment, pid int(11) unsigned DEFAULT '0' NOT NULL, crdate varchar(20) DEFAULT '0' NOT NULL, + tstamp int(11) unsigned DEFAULT '0' NOT NULL, request_id varchar(40) DEFAULT '' NOT NULL, request_type int(11) unsigned DEFAULT '0' NOT NULL, be_user int(11) unsigned DEFAULT '0' NOT NULL, diff --git a/ext_typoscript_setup.txt b/ext_typoscript_setup.txt index e6b9573..e6a8d15 100644 --- a/ext_typoscript_setup.txt +++ b/ext_typoscript_setup.txt @@ -3,4 +3,30 @@ module.tx_dmdeveloperlog.settings { itemsPerPage = 20 maximumNumberOfLinks = 20 } -} \ No newline at end of file +} + +module.tx_dmdeveloperlog { + view { + templateRootPaths { + 0 = EXT:dm_developerlog/Resources/Private/Templates/ + } + + partialRootPaths { + 0 = EXT:dm_developerlog/Resources/Private/Partials/ + } + + layoutRootPaths { + 0 = EXT:dm_developerlog/Resources/Private/Layouts/ + } + } +} + +[compatVersion = 8.7.0] +module.tx_dmdeveloperlog { + view { + partialRootPaths { + 1 = EXT:dm_developerlog/Resources/Private/Partials/FluidTYPO3/ + } + } +} +[global] \ No newline at end of file