*/
public static function _POST($var = null)
{
- $value = $var === null ? $_POST : (empty($var) ? null : $_POST[$var]);
+ $value = $var === null ? $_POST : (empty($var) || !isset($_POST[$var]) ? null : $_POST[$var]);
// This is there for backwards-compatibility, in order to avoid NULL
if (isset($value) && !is_array($value)) {
$value = (string)$value;
// Closing tag.
$tagName = $tagName[0] === 'n' && MathUtility::canBeInterpretedAsInteger($testNtag) ? (int)$testNtag : $tagName;
// Test for alternative index value:
- if ((string)$val['attributes']['index'] !== '') {
+ if ((string)($val['attributes']['index'] ?? '') !== '') {
$tagName = $val['attributes']['index'];
}
// Setting tag-values, manage stack:
break;
case 'complete':
// If "complete", then it's a value. If the attribute "base64" is set, then decode the value, otherwise just set it.
- if ($val['attributes']['base64']) {
+ if (!empty($val['attributes']['base64'])) {
$current[$tagName] = base64_decode($val['value']);
} else {
// Had to cast it as a string - otherwise it would be evaluate FALSE if tested with isset()!!
- $current[$tagName] = (string)$val['value'];
+ $current[$tagName] = (string)($val['value'] ?? '');
// Cast type:
- switch ((string)$val['attributes']['type']) {
+ switch ((string)($val['attributes']['type'] ?? '')) {
case 'integer':
$current[$tagName] = (int)$current[$tagName];
break;
case 'double':
- $current[$tagName] = (double) $current[$tagName];
+ $current[$tagName] = (double)$current[$tagName];
break;
case 'boolean':
$current[$tagName] = (bool)$current[$tagName];
*/
public static function minifyJavaScript($script, &$error = '')
{
- if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['minifyJavaScript'])) {
- $fakeThis = false;
- foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['minifyJavaScript'] as $hookMethod) {
- try {
- $parameters = ['script' => $script];
- $script = static::callUserFunction($hookMethod, $parameters, $fakeThis);
- } catch (\Exception $e) {
- $errorMessage = 'Error minifying java script: ' . $e->getMessage();
- $error .= $errorMessage;
- static::getLogger()->warning($errorMessage, [
- 'JavaScript' => $script,
- 'hook' => $hookMethod,
- 'exception' => $e,
- ]);
- }
+ $fakeThis = false;
+ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['minifyJavaScript'] ?? [] as $hookMethod) {
+ try {
+ $parameters = ['script' => $script];
+ $script = static::callUserFunction($hookMethod, $parameters, $fakeThis);
+ } catch (\Exception $e) {
+ $errorMessage = 'Error minifying java script: ' . $e->getMessage();
+ $error .= $errorMessage;
+ static::getLogger()->warning($errorMessage, [
+ 'JavaScript' => $script,
+ 'hook' => $hookMethod,
+ 'exception' => $e,
+ ]);
}
}
return $script;
$response = $requestFactory->request($url, 'GET', $configuration);
} catch (RequestException $exception) {
if (isset($report)) {
- $report['error'] = $exception->getHandlerContext()['errno'];
+ $report['error'] = $exception->getCode() ?: 1518707554;
$report['message'] = $exception->getMessage();
$report['exception'] = $exception;
}
if ($includeHeader) {
$parsedURL = parse_url($url);
$method = $includeHeader === 2 ? 'HEAD' : 'GET';
- $content = $method . ' ' . (isset($parsedURL['path']) ? $parsedURL['path'] : '/')
- . ($parsedURL['query'] ? '?' . $parsedURL['query'] : '') . ' HTTP/1.0' . CRLF
+ $content = $method . ' ' . ($parsedURL['path'] ?? '/')
+ . (!empty($parsedURL['query']) ? '?' . $parsedURL['query'] : '') . ' HTTP/1.0' . CRLF
. 'Host: ' . $parsedURL['host'] . CRLF
. 'Connection: close' . CRLF;
if (is_array($requestHeaders)) {
}
if (static::isAllowedAbsPath($path)) {
if (@is_file($path)) {
- $targetPermissions = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'])
- ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask']
- : '0644';
+ $targetPermissions = $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] ?? '0644';
} elseif (@is_dir($path)) {
- $targetPermissions = isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'])
- ? $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask']
- : '0755';
+ $targetPermissions = $GLOBALS['TYPO3_CONF_VARS']['SYS']['folderCreateMask'] ?? '0755';
}
if (!empty($targetPermissions)) {
// make sure it's always 4 digits
if (preg_match('#^(?:[[:alnum:]_]+/)+$#', $subdir)) {
$dirName .= $subdir;
if (!@is_dir($dirName)) {
- static::mkdir_deep(PATH_site . 'typo3temp/', $subdir);
+ static::mkdir_deep(PATH_site . 'typo3temp/' . $subdir);
}
} else {
return 'Subdir, "' . $subdir . '", was NOT on the form "[[:alnum:]_]/+"';
throw new \InvalidArgumentException('The specified directory is of type "' . gettype($deepDirectory) . '" but a string is expected.', 1303662956);
}
// Ensure there is only one slash
- $fullPath = rtrim($directory, '/') . '/' . ltrim($deepDirectory, '/');
- if ($fullPath !== '' && !is_dir($fullPath)) {
+ $fullPath = rtrim($directory, '/') . '/';
+ if ($deepDirectory !== '') {
+ trigger_error('Second argument $deepDirectory of GeneralUtility::mkdir_deep() will be removed in TYPO3 v10.0, use a combined string as first argument instead.', E_USER_DEPRECATED);
+ $fullPath .= ltrim($deepDirectory, '/');
+ }
+ if ($fullPath !== '/' && !is_dir($fullPath)) {
$firstCreatedPath = static::createDirectoryPath($fullPath);
if ($firstCreatedPath !== '') {
static::fixPermissions($firstCreatedPath, true);
}
$pathPrefix = $path . '/';
+ $allowedFileExtensionArray = self::trimExplode(',', $extensionList);
$extensionList = ',' . str_replace(' ', '', $extensionList) . ',';
$files = [];
foreach ($rawFileList as $entry) {
continue;
}
- if (
- ($extensionList === ',,' || stripos($extensionList, ',' . pathinfo($entry, PATHINFO_EXTENSION) . ',') !== false)
- && ($excludePattern === '' || !preg_match(('/^' . $excludePattern . '$/'), $entry))
- ) {
- if ($order !== 'mtime') {
- $files[] = $entry;
- } else {
- // Store the value in the key so we can do a fast asort later.
- $files[$entry] = filemtime($completePathToEntry);
+ foreach ($allowedFileExtensionArray as $allowedFileExtension) {
+ if (
+ ($extensionList === ',,' || stripos($extensionList, ',' . substr($entry, strlen($allowedFileExtension) * -1, strlen($allowedFileExtension)) . ',') !== false)
+ && ($excludePattern === '' || !preg_match(('/^' . $excludePattern . '$/'), $entry))
+ ) {
+ if ($order !== 'mtime') {
+ $files[] = $entry;
+ } else {
+ // Store the value in the key so we can do a fast asort later.
+ $files[$entry] = filemtime($completePathToEntry);
+ }
}
}
}
} else {
$mode = $GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['versionNumberInFilename'];
}
- if (!file_exists($path) || $doNothing) {
+ if ($doNothing || !file_exists($path)) {
// File not found, return filename unaltered
$fullName = $file;
} else {
if (!$mode) {
// If use of .htaccess rule is not configured,
// we use the default query-string method
- if ($lookupFile[1]) {
+ if (!empty($lookupFile[1])) {
$separator = '&';
} else {
$separator = '?';
break;
case 'REQUEST_URI':
// Typical application of REQUEST_URI is return urls, forms submitting to itself etc. Example: returnUrl='.rawurlencode(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'))
- if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']) {
+ if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar'])) {
// This is for URL rewriters that store the original URI in a server variable (eg ISAPI_Rewriter for IIS: HTTP_X_REWRITE_URL)
list($v, $n) = explode('|', $GLOBALS['TYPO3_CONF_VARS']['SYS']['requestURIvar']);
$retVal = $GLOBALS[$v][$n];
break;
case 'HTTP_HOST':
// if it is not set we're most likely on the cli
- $retVal = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : null;
+ $retVal = $_SERVER['HTTP_HOST'] ?? null;
if (isset($_SERVER['REMOTE_ADDR']) && static::cmpIP($_SERVER['REMOTE_ADDR'], $GLOBALS['TYPO3_CONF_VARS']['SYS']['reverseProxyIP'])) {
$host = self::trimExplode(',', $_SERVER['HTTP_X_FORWARDED_HOST']);
// Choose which host in list to use
$destination = PATH_site . $destination;
}
if (static::isAllowedAbsPath($source) && static::isAllowedAbsPath($destination)) {
+ static::mkdir_deep($destination);
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
* @param string $language Language key
* @param bool $sameLocation If TRUE, then locallang localization file name will be returned with same directory as $fileRef
* @return string Returns the filename reference for the language unless error occurred in which case it will be NULL
+ * @deprecated in TYPO3 v9.0, will be removed in TYPO3 v10.0, as the functionality has been moved into AbstractXmlParser.
*/
public static function llXmlAutoFileName($fileRef, $language, $sameLocation = false)
{
+ trigger_error('This method will be removed in TYPO3 v10.0, the functionality has been moved into AbstractXmlParser', E_USER_DEPRECATED);
// If $fileRef is already prefixed with "[language key]" then we should return it as is
$fileName = basename($fileRef);
if (self::isFirstPartOfStr($fileName, $language . '.')) {
* @param string $className Class name
* @return object The instance of the class asked for. Instance is created with GeneralUtility::makeInstance
* @see callUserFunction()
- * @deprecated since TYPO3 v9, will be removed in TYPO3 v10, use makeInstance instead.
+ * @deprecated
*/
public static function getUserObj($className)
{
- self::logDeprecatedFunction();
+ trigger_error('This method will be removed in TYPO3 v10.0, use GeneralUtility::makeInstance() directly instead', E_USER_DEPRECATED);
// Check if class exists:
if (class_exists($className)) {
return self::makeInstance($className);
*/
protected static function classHasImplementation($className)
{
- // If we are early in the bootstrap, the configuration might not yet be present
- if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'])) {
- return false;
- }
-
- return isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$className])
- && is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$className])
- && !empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$className]['className']);
+ return !empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects'][$className]['className']);
}
/**
public static function initSysLog()
{
// Init custom logging
- if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
- $params = ['initLog' => true];
- $fakeThis = false;
- foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
- self::callUserFunction($hookMethod, $params, $fakeThis);
- }
+ $params = ['initLog' => true];
+ $fakeThis = false;
+ foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] ?? [] as $hookMethod) {
+ self::callUserFunction($hookMethod, $params, $fakeThis);
}
$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = MathUtility::forceIntegerInRange($GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'], 0, 4);
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = true;
* @param string $msg Message (in English).
* @param string $extKey Extension key (from which extension you are calling the log) or "Core"
* @param int $severity \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_* constant
- * @deprecated since TYPO3 v9, will be removed in TYPO3 v10
+ * @deprecated
*/
public static function sysLog($msg, $extKey, $severity = 0)
{
- static::logDeprecatedFunction();
+ trigger_error('Method sysLog() is deprecated since v9 and will be removed with v10', E_USER_DEPRECATED);
$severity = MathUtility::forceIntegerInRange($severity, 0, 4);
// Is message worth logging?
if (!$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) {
self::initSysLog();
}
- // Do custom logging
- if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
+ // Do custom logging; avoid calling debug_backtrace if there are no custom loggers.
+ if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) {
$params = ['msg' => $msg, 'extKey' => $extKey, 'backTrace' => debug_backtrace(), 'severity' => $severity];
$fakeThis = false;
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) {
* @param string $extKey Extension key (from which extension you are calling the log)
* @param int $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is fatal error, -1 is "OK" message
* @param mixed $dataVar Additional data you want to pass to the logger.
- * @deprecated since TYPO3 CMS 9, will be removed in TYPO3 CMS 10.
+ * @deprecated
*/
public static function devLog($msg, $extKey, $severity = 0, $dataVar = false)
{
- static::logDeprecatedFunction();
- if ((bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['enable_DLOG'] && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'])) {
+ trigger_error('Method devLog() is deprecated since v9 and will be removed with v10', E_USER_DEPRECATED);
+ if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'])) {
$params = ['msg' => $msg, 'extKey' => $extKey, 'severity' => $severity, 'dataVar' => $dataVar];
$fakeThis = false;
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['devLog'] as $hookMethod) {
* Writes a message to the deprecation log.
*
* @param string $msg Message (in English).
+ * @deprecated
*/
public static function deprecationLog($msg)
{
- if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
- return;
- }
- // Legacy values (no strict comparison, $log can be boolean, string or int)
- $log = $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'];
- if ($log === true || $log == '1') {
- $log = ['file'];
- } else {
- $log = self::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'], true);
- }
- $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
- if (in_array('file', $log) !== false) {
- // Write a longer message to the deprecation log
- $destination = static::getDeprecationLogFileName();
- $file = @fopen($destination, 'a');
- if ($file) {
- @fwrite($file, ($date . $msg . LF));
- @fclose($file);
- self::fixPermissions($destination);
- }
- }
- // Do not use console in login screen
- if (in_array('console', $log) !== false && isset($GLOBALS['BE_USER']->user['uid'])) {
- DebugUtility::debug($msg, $date, 'Deprecation Log');
- }
+ static::writeDeprecationLogFileEntry(__METHOD__ . ' is deprecated since TYPO3 v9.0, will be removed in TYPO3 v10.0, use "trigger_error("Given reason", E_USER_DEPRECATED);" to log deprecations.');
+ trigger_error($msg, E_USER_DEPRECATED);
}
/**
* @param string $property
* @param RenderingContextInterface $renderingContext
* @param string $additionalMessage
+ * @deprecated
*/
public static function logDeprecatedViewHelperAttribute(string $property, RenderingContextInterface $renderingContext, string $additionalMessage = '')
{
+ static::writeDeprecationLogFileEntry(__METHOD__ . ' is deprecated since TYPO3 v9.0, will be removed in TYPO3 v10.0');
$template = $renderingContext->getTemplatePaths()->resolveTemplateFileForControllerAndActionAndFormat(
$renderingContext->getControllerName(),
$renderingContext->getControllerAction()
$message[] = 'The property "' . $property . '" has been marked as deprecated.';
$message[] = $additionalMessage;
$message[] = 'Please check also your partial and layout files of this template';
- self::deprecationLog(implode(' ', $message));
+ trigger_error(implode(' ', $message), E_USER_DEPRECATED);
}
/**
* Gets the absolute path to the deprecation log file.
*
* @return string Absolute path to the deprecation log file
+ * @deprecated
*/
public static function getDeprecationLogFileName()
{
+ static::writeDeprecationLogFileEntry(__METHOD__ . ' is deprecated since TYPO3 v9.0, will be removed in TYPO3 v10.0');
return PATH_typo3conf . 'deprecation_' . self::shortMD5((PATH_site . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'])) . '.log';
}
/**
* Logs a call to a deprecated function.
* The log message will be taken from the annotation.
+ * @deprecated
*/
public static function logDeprecatedFunction()
{
- if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
- return;
- }
+ static::writeDeprecationLogFileEntry(__METHOD__ . ' is deprecated since TYPO3 v9.0, will be removed in TYPO3 v10.0');
$trail = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
if ($trail[1]['type']) {
$function = new \ReflectionMethod($trail[1]['class'], $trail[1]['function']);
$logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
$logMsg .= '() - ' . $msg . ' - ' . DebugUtility::debugTrail();
$logMsg .= ' (' . PathUtility::stripPathSitePrefix($function->getFileName()) . '#' . $function->getStartLine() . ')';
- self::deprecationLog($logMsg);
+ trigger_error($logMsg, E_USER_DEPRECATED);
}
/**
public static function quoteJSvalue($value)
{
return strtr(
- json_encode((string)$value, JSON_HEX_AMP|JSON_HEX_APOS|JSON_HEX_QUOT|JSON_HEX_TAG),
+ json_encode((string)$value, JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_TAG),
[
'"' => '\'',
'\\\\' => '\\u005C',
{
return static::makeInstance(LogManager::class)->getLogger(__CLASS__);
}
+
+ /**
+ * @param string $msg
+ * @deprecated
+ */
+ private static function writeDeprecationLogFileEntry($msg)
+ {
+ $date = date($GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'] . ' ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm'] . ': ');
+ // Write a longer message to the deprecation log
+ $destination = PATH_typo3conf . 'deprecation_' . self::shortMD5(PATH_site . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']) . '.log';
+ $file = @fopen($destination, 'a');
+ if ($file) {
+ @fwrite($file, $date . $msg . LF);
+ @fclose($file);
+ self::fixPermissions($destination);
+ }
+ }
}