Skip to content

Commit

Permalink
[TASK] Log warning if a custom BE login image couldn't be resolved
Browse files Browse the repository at this point in the history
Log a warning message if the configured TYPO3 backend login
- logo or
- background image
can't get resolved.

Change-Id: I782a9b08650d9b2f9cfb3cefb9c4ba18577d5a7d
Resolves: #84050
Releases: master
Reviewed-on: https://review.typo3.org/55911
Reviewed-by: Wolfgang Klinger <wolfgang@wazum.com>
Tested-by: Wolfgang Klinger <wolfgang@wazum.com>
Reviewed-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: Tobi Kretschmann <tobi@tobishome.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
d3pendent authored and NeoBlack committed Feb 28, 2018
1 parent 537d74c commit 5fbab6b
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions typo3/sysext/backend/Classes/Controller/LoginController.php
Expand Up @@ -16,6 +16,8 @@

use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
use TYPO3\CMS\Backend\Exception;
use TYPO3\CMS\Backend\LoginProvider\LoginProviderInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
Expand All @@ -36,8 +38,10 @@
/**
* Script Class for rendering the login form
*/
class LoginController
class LoginController implements LoggerAwareInterface
{
use LoggerAwareTrait;

/**
* The URL to redirect to after login.
*
Expand Down Expand Up @@ -169,6 +173,12 @@ public function main()
// Background Image
if (!empty($extConf['loginBackgroundImage'])) {
$backgroundImage = $this->getUriForFileName($extConf['loginBackgroundImage']);
if ($backgroundImage === '') {
$this->logger->warning(
'The configured TYPO3 backend login background image "' . htmlspecialchars($extConf['loginBackgroundImage']) .
'" can\'t be resolved. Please check if the file exists and the extension is activated.'
);
}
$this->getDocumentTemplate()->inDocStylesArray[] = '
.typo3-login-carousel-control.right,
.typo3-login-carousel-control.left,
Expand Down Expand Up @@ -201,6 +211,12 @@ public function main()

// Logo
if (!empty($extConf['loginLogo'])) {
if ($this->getUriForFileName($extConf['loginLogo']) === '') {
$this->logger->warning(
'The configured TYPO3 backend login logo "' . htmlspecialchars($extConf['loginLogo']) .
'" can\'t be resolved. Please check if the file exists and the extension is activated.'
);
}
$logo = $extConf['loginLogo'];
} else {
// Use TYPO3 logo depending on highlight color
Expand Down Expand Up @@ -402,20 +418,16 @@ protected function getSystemNews()
*/
private function getUriForFileName($filename)
{
if (strpos($filename, '://')) {
// Check if it's already a URL
if (preg_match('/^(https?:)?\/\//', $filename)) {
return $filename;
}
$urlPrefix = '';
if (strpos($filename, 'EXT:') === 0) {
$absoluteFilename = GeneralUtility::getFileAbsFileName($filename);
$filename = '';
if ($absoluteFilename !== '') {
$filename = PathUtility::getAbsoluteWebPath($absoluteFilename);
}
} elseif (strpos($filename, '/') !== 0) {
$urlPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
$absoluteFilename = GeneralUtility::getFileAbsFileName(ltrim($filename, '/'));
$filename = '';
if ($absoluteFilename !== '' && @is_file($absoluteFilename)) {
$filename = PathUtility::getAbsoluteWebPath($absoluteFilename);
}
return $urlPrefix . $filename;
return $filename;
}

/**
Expand Down

0 comments on commit 5fbab6b

Please sign in to comment.