Skip to content

Commit

Permalink
Merge pull request #449 from cron-eu/fix-php81
Browse files Browse the repository at this point in the history
[BUGFIX] PHP 8.1 deprecation exceptions
  • Loading branch information
kartolo authored Feb 21, 2024
2 parents 07a5100 + bd1ea26 commit 6223ba5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Classes/Dmailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ protected function replaceMailMarkers(string $content, array $recipRow, array $m
public function sendAdvanced(array $recipientRow, string $tableNameChar): int
{
$returnCode = 0;
$recipientRow = array_map('htmlspecialchars', $recipientRow);
$recipientRow = array_map(function($a) { return @htmlspecialchars($a); }, $recipientRow);

// Workaround for strict checking of email addresses in TYPO3
// (trailing newline = invalid address)
Expand Down
5 changes: 3 additions & 2 deletions Classes/Module/DmailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1418,15 +1418,16 @@ protected function cmd_finalmail($direct_mail_row)
$this->messageQueue->addMessage($message);
}

// @todo Replace deprecated strftime for php 9. Suppress warning for php 8.1 and later
return [
'id' => $this->id,
'sys_dmail_uid' => $this->sys_dmail_uid,
'hookContents' => $hookContents, // put content from hook
'hookSelectDisabled' => $hookSelectDisabled, // put content from hook
'lastGroup' => $lastGroup,
'opt' => $opt,
'send_mail_datetime_hr' => strftime('%H:%M %d-%m-%Y', time()),
'send_mail_datetime' => strftime('%H:%M %d-%m-%Y', time()),
'send_mail_datetime_hr' => @strftime('%H:%M %d-%m-%Y', time()),
'send_mail_datetime' => @strftime('%H:%M %d-%m-%Y', time()),
];
}

Expand Down
68 changes: 33 additions & 35 deletions Classes/Repository/TempRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,45 +315,43 @@ public function getRecordOverlay(string $table, array $row, int $sys_language_co
{
if ($row['uid'] > 0 && $row['pid'] > 0) {
if ($GLOBALS['TCA'][$table] && $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) {
if (!$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable']) {
// Will try to overlay a record only
// if the sys_language_content value is larger that zero.
if ($sys_language_content > 0) {
// Must be default language or [All], otherwise no overlaying:
if ($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) {
// Select overlay record:
$queryBuilder = $this->getQueryBuilder($table);
$olrow = $queryBuilder->select('*')
->from($table)
->add('where', 'pid=' . (int)$row['pid'] .
' AND ' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$sys_language_content .
' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$row['uid'])
->setMaxResults(1)/* LIMIT 1*/
->executeQuery()
->fetchAssociative();

// Merge record content by traversing all fields:
if (is_array($olrow)) {
foreach ($row as $fN => $fV) {
if ($fN != 'uid' && $fN != 'pid' && isset($olrow[$fN])) {
if ($GLOBALS['TCA'][$table]['l10n_mode'][$fN] != 'exclude' && ($GLOBALS['TCA'][$table]['l10n_mode'][$fN] != 'mergeIfNotBlank' || strcmp(trim($olrow[$fN]), ''))) {
$row[$fN] = $olrow[$fN];
}
// Will try to overlay a record only
// if the sys_language_content value is larger that zero.
if ($sys_language_content > 0) {
// Must be default language or [All], otherwise no overlaying:
if ($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] <= 0) {
// Select overlay record:
$queryBuilder = $this->getQueryBuilder($table);
$olrow = $queryBuilder->select('*')
->from($table)
->add('where', 'pid=' . (int)$row['pid'] .
' AND ' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '=' . (int)$sys_language_content .
' AND ' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . '=' . (int)$row['uid'])
->setMaxResults(1)/* LIMIT 1*/
->executeQuery()
->fetchAssociative();

// Merge record content by traversing all fields:
if (is_array($olrow)) {
foreach ($row as $fN => $fV) {
if ($fN != 'uid' && $fN != 'pid' && isset($olrow[$fN])) {
if ($GLOBALS['TCA'][$table]['l10n_mode'][$fN] != 'exclude' && ($GLOBALS['TCA'][$table]['l10n_mode'][$fN] != 'mergeIfNotBlank' || strcmp(trim($olrow[$fN]), ''))) {
$row[$fN] = $olrow[$fN];
}
}
}

// Otherwise, check if sys_language_content is different from the value of the record
// that means a japanese site might try to display french content.
} elseif ($sys_language_content != $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]) {
unset($row);
}
} else {
// When default language is displayed,
// we never want to return a record carrying another language!:
if ($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
unset($row);
}

// Otherwise, check if sys_language_content is different from the value of the record
// that means a japanese site might try to display french content.
} elseif ($sys_language_content != $row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]) {
unset($row);
}
} else {
// When default language is displayed,
// we never want to return a record carrying another language!:
if ($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']] > 0) {
unset($row);
}
}
}
Expand Down

0 comments on commit 6223ba5

Please sign in to comment.