Exemplo n.º 1
0
 /**
  * @inherit
  */
 public function handleError(\R3H6\Error404page\Domain\Model\Error $error)
 {
     if ($this->httpService->isOwnRequest()) {
         $this->getLogger()->debug("Throw exception 1475311053");
         throw new \Exception("Error processing request", 1475311053);
     }
     if ($this->extensionConfiguration->is('enableErrorLog')) {
         $this->errorRepository->log($error);
     }
     $cacheIdentifier = $this->errorHandlerCache->calculateCacheIdentifier($error);
     $errorHandler = $this->errorHandlerCache->get($cacheIdentifier);
     if ($errorHandler === null) {
         foreach ($this->getErrorHandlers() as $errorHandler) {
             try {
                 $this->getLogger()->debug('Try handle error with ' . get_class($errorHandler));
                 if ($errorHandler->handleError($error)) {
                     $this->errorHandlerCache->set($cacheIdentifier, $errorHandler);
                     break;
                 }
             } catch (\Exception $exception) {
                 $this->getLogger()->debug('Could not handle error in ' . get_class($errorHandler) . ': ' . $exception->getMessage());
             }
         }
     }
     $this->getLogger()->debug('Get error handler output of ' . get_class($errorHandler));
     return $errorHandler->getOutput($error);
 }
 /**
  * @test
  */
 public function handleErrorLogsErrorWhenConfigurationIsSet()
 {
     /** @var \R3H6\Error404page\Domain\Model\Error $errorFixture */
     $errorFixture = new Error();
     $this->mockGetErrorHandlers();
     $this->extensionConfigurationMock->expects($this->once())->method('is')->with($this->equalTo('enableErrorLog'))->will($this->returnValue(true));
     $this->errorRepositoryMock->expects($this->once())->method('log')->with($errorFixture);
     $this->subject->handleError($errorFixture);
 }
 /**
  * [find404PageForError description]
  * @param  Error  $error [description]
  * @return \R3H6\Error404page\Domain\Model\Page|null
  */
 public function find404PageForError(Error $error)
 {
     $doktype = (int) $this->extensionConfiguration->get('doktypeError404page');
     $page = $this->findFirstByHostAndDoktype($error->getHost(), $doktype);
     if ($page === null) {
         $page = $this->findFirstWithoutHostByDoktype($doktype);
     }
     return $page;
 }
Exemplo n.º 4
0
 /**
  * Creates a http request
  *
  * @param  string $url
  * @return \TYPO3\CMS\Core\Http\HttpRequest
  */
 protected function getHttpRequest($url)
 {
     $url .= strpos($url, '?') === false ? '?' : '&';
     $url .= '&tx_error404page_request=' . uniqid();
     /** @var \TYPO3\CMS\Core\Http\HttpRequest $request */
     $request = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Http\\HttpRequest', $url);
     $feCookieName = $GLOBALS['TYPO3_CONF_VARS']['FE']['cookieName'];
     // Forward cookies.
     $request->setCookieJar(true);
     if (isset($_COOKIE[$feCookieName]) && !empty($_COOKIE[$feCookieName])) {
         $request->addCookie($feCookieName, $_COOKIE[$feCookieName]);
     }
     // TYPO3 uses user-agent for authentification.
     $request->setHeader('user-agent', GeneralUtility::getIndpEnv('HTTP_USER_AGENT'));
     // Set basic authentication.
     if ($this->extensionConfiguration->use('basicAuthentication')) {
         $basicAuthentication = GeneralUtility::trimExplode(':', $this->extensionConfiguration->get('basicAuthentication'), true);
         $request->setAuth($basicAuthentication[0], $basicAuthentication[1]);
     }
     return $request;
 }
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
\R3H6\Error404page\Utility\CustomPageUtility::addDoktypeToPagesLanguageOverlay(\R3H6\Error404page\Configuration\ExtensionConfiguration::EXT_KEY, \R3H6\Error404page\Configuration\ExtensionConfiguration::get('doktypeError404page'), 'Error404page', '404');
Exemplo n.º 6
0
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
\R3H6\Error404page\Utility\CustomPageUtility::addDoktype($_EXTKEY, \R3H6\Error404page\Configuration\ExtensionConfiguration::get('doktypeError404page'), 'Error404page');
if (TYPO3_MODE === 'BE' && \R3H6\Error404page\Configuration\ExtensionConfiguration::get('enableErrorLog')) {
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:error404page/Configuration/TypoScript/setup.txt">');
    if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '7.6.0', '<')) {
        \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScriptSetup('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:error404page/Configuration/TypoScript/Compatibility6/setup.txt">');
    }
    /**
     * Registers a Backend Module
     */
    \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerModule('R3H6.' . $_EXTKEY, 'web', 'statistic', '', array('Error' => 'dashboard, list, show, deleteAll'), array('access' => 'user,group', 'icon' => 'EXT:' . $_EXTKEY . '/ext_icon.svg', 'labels' => 'LLL:EXT:' . $_EXTKEY . '/Resources/Private/Language/locallang_statistic.xlf'));
}
if (version_compare(\TYPO3\CMS\Core\Utility\VersionNumberUtility::getCurrentTypo3Version(), '7.4.0', '>=')) {
    \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerPageTSConfigFile($_EXTKEY, 'Configuration/PageTS/Redirect403.txt', 'EXT:error404page :: Redirect 403 error to login page');
}
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addLLrefForTCAdescr('tx_error404page_domain_model_error', 'EXT:error404page/Resources/Private/Language/locallang_csh_tx_error404page_domain_model_error.xlf');
Exemplo n.º 7
0
<?php

if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
// Override local page not found handling configuration
$GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = 'USER_FUNCTION:R3H6\\Error404page\\Domain\\Hook\\ErrorHandlerHook->pageNotFound';
if (!isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['errorHandlers'])) {
    $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$_EXTKEY]['errorHandlers'] = array();
}
// Cache configuration
if (!is_array($TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][\R3H6\Error404page\Domain\Cache\ErrorHandlerCache::IDENTIFIER])) {
    $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations'][\R3H6\Error404page\Domain\Cache\ErrorHandlerCache::IDENTIFIER] = array();
}
// Debug log
if (\R3H6\Error404page\Configuration\ExtensionConfiguration::is('debug')) {
    $GLOBALS['TYPO3_CONF_VARS']['LOG']['R3H6']['Error404page']['writerConfiguration'] = array(\TYPO3\CMS\Core\Log\LogLevel::DEBUG => array('TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter' => array('logFile' => 'typo3temp/logs/debug.log')));
}