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 @@
-
-
-
| - | |||||
|---|---|---|---|---|---|
{logEntry.requestId} |
-
- {logEntry.location}:{logEntry.line}
- |
- {logEntry.message} | -|||
| - |
- |
-
-
-
-
- {logEntry.dataVar}
- |
- |||
{logEntry.requestId} |
@@ -29,7 +28,7 @@
{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 @@
Development Log
-
- - - | ||||