Hallo zusammen,
ich habe vor kurzem TYPO3 von der Version 4.7.8 auf 6.0.2 geupdatet.
Eigentlich lief alles perfekt. Das anscheinend einzige Problem ist, dass, wenn ich den Fehler richtig interpretiere, tt_products die "Bestell-Emails" gerne über die Klasse "t3lib_htmlmail" versenden möchte, dies aber offensichtlich nicht funktioniert, da diese Klasse mittlerweile gar nicht mehr in TYPO3 enthalten ist.
Der Fehler, den alleine das Plugin "Warenkorb: Bestellung abschließen" verursacht, sieht folgendermaßen aus:
Fatal error: Class '\t3lib_htmlmail' not found in /html/typo3/typo3_src-6.0.2/typo3/sysext/core/Classes/Utility/GeneralUtility.php on line 4158
Hier die Stelle in der Datei 'GeneralUtility.php':
static public function makeInstance($className) {
if (!is_string($className) || empty($className)) {
throw new \InvalidArgumentException('$className must be a non empty string.', 1288965219);
}
$finalClassName = self::getClassName($className);
// Return singleton instance if it is already registered
if (isset(self::$singletonInstances[$finalClassName])) {
return self::$singletonInstances[$finalClassName];
}
// Return instance if it has been injected by addInstance()
if (isset(self::$nonSingletonInstances[$finalClassName]) && !empty(self::$nonSingletonInstances[$finalClassName])) {
return array_shift(self::$nonSingletonInstances[$finalClassName]);
}
// Create new instance and call constructor with parameters
if (func_num_args() > 1) {
$constructorArguments = func_get_args();
array_shift($constructorArguments);
$reflectedClass = new \ReflectionClass($finalClassName);
$instance = $reflectedClass->newInstanceArgs($constructorArguments);
} else {
$fullyQualifiedClassName = '\\' . $finalClassName;
// Folgende Zeile verursacht den Fehler:
$instance = new $fullyQualifiedClassName();
}
// Create alias if not present
$alias = \TYPO3\CMS\Core\Core\ClassLoader::getAliasForClassName($finalClassName);
if ($finalClassName !== $alias && !class_exists($alias, FALSE)) {
class_alias($finalClassName, $alias);
}
// Register new singleton instance
if ($instance instanceof \TYPO3\CMS\Core\SingletonInterface) {
self::$singletonInstances[$finalClassName] = $instance;
}
return $instance;
}
Das gesamte Bestellprozedere hat schon mal funktioniert. Ob der Fehler erst aufgetreten ist, nachdem das TYPO3-Update durchgeführt wurde, kann ich nicht zu 100% bestätigen.
An dem Plugin tt_products habe ich auch keine Änderungen vorgenommen.
Hat jemand eine Idee?
Viele Grüße
Max
Hallo,
ich habe bereits selbst eine Lösung gefunden, sodass die tt_products Bestellung (bzw. Bestellung abschließen / finalize) funktioniert.
Die Klasse tx_ttproducts_email_div in meiner class.tx_ttproducts_email_div.php sieht nun folgendermaßen aus:
(Alle vorherigen Einstellungen sind mit "// -- " markiert)
class tx_ttproducts_email_div {
/**
* Extended mail function
*
* @param [type] $toEMail: ...
* @param [type] $subject: ...
* @param [type] $message: ...
* @param [type] $html: ...
* @param [type] $fromEMail: ...
* @param [type] $fromName: ...
* @param [type] $attachment: ...
* @return [type] ...
*/
function send_mail (
$toEMail,
$subject,
&$message,
&$html,
$fromEMail,
$fromName,
$attachment=''
) {
global $TYPO3_CONF_VARS;
if (
isset($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']) &&
is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']) &&
isset($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']) &&
is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']) &&
array_search('t3lib_mail_SwiftMailerAdapter', $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/utility/class.t3lib_utility_mail.php']['substituteMailDelivery']) !== FALSE
) {
if (!is_array($toEMail)) {
$emailArray = t3lib_div::trimExplode(',', $toEMail);
$toEMail = array();
foreach ($emailArray as $email) {
$toEMail[] = $email;
}
}
/** @var $mail t3lib_mail_Message */
$mailMessage = t3lib_div::makeInstance('t3lib_mail_Message');
$mailMessage->setTo($toEMail)
->setFrom(array($fromEMail => $fromName))
->setSubject($subject)
->setBody($html, 'text/html', $GLOBALS['TSFE']->renderCharset)
->addPart($message, 'text/plain', $GLOBALS['TSFE']->renderCharset);
if ($html != '') {
$mailMessage->setBody($html, 'text/html', 'iso-8859-1');
} else if ($message != '') {
$mailMessage->addPart($message, 'text/plain', 'iso-8859-1');
}
if (isset($attachment)) {
if (is_array($attachment)) {
$attachmentArray = $attachment;
} else {
$attachmentArray = array($attachment);
}
foreach ($attachmentArray as $theAttachment) {
if (file_exists($theAttachment)) {
$mailMessage->attach(Swift_Attachment::fromPath($theAttachment));
}
}
}
if ($bcc != '') {
$mailMessage->addBcc($bcc);
}
$mailMessage->send();
} else {
// -- include_once(PATH_t3lib.'class.t3lib_htmlmail.php');
include_once(PATH_t3lib.'/mail/class.t3lib_mail_mailer.php');
$fromName = tx_div2007_alpha5::slashName($fromName);
if (is_array($toEMail)) {
list($email, $name) = each($toEMail);
$toEMail = tx_div2007_alpha5::slashName($name) . ' <' . $email . '>';
}
// -- $Typo3_htmlmail = t3lib_div::makeInstance('t3lib_htmlmail');
$Typo3_htmlmail = t3lib_div::makeInstance('t3lib_mail_Message');
// -- $Typo3_htmlmail->start();
// -- $Typo3_htmlmail->mailer = 'TYPO3 HTMLMail';
// $Typo3_htmlmail->useBase64(); +++ TODO
$message = html_entity_decode($message);
if ($Typo3_htmlmail->linebreak == chr(10)) {
$message = str_replace(chr(13).chr(10),$Typo3_htmlmail->linebreak,$message);
}
$Typo3_htmlmail->setTo(array($toEMail => null));
$Typo3_htmlmail->setFrom(array($fromEMail => $fromName));
$Typo3_htmlmail->setReplyTo(array($fromEMail => $fromName));
$Typo3_htmlmail->setSubject($subject);
if ($attachment != '' && file_exists($attachment)) {
$Typo3_htmlmail->addAttachment($attachment);
}
if ($html) {
$Typo3_htmlmail->theParts['html']['content'] = $html; // Fetches the content of the page
$Typo3_htmlmail->theParts['html']['path'] = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/';
$Typo3_htmlmail->extractMediaLinks();
$Typo3_htmlmail->extractHyperLinks();
$Typo3_htmlmail->fetchHTMLMedia();
$Typo3_htmlmail->substMediaNamesInHTML(0); // 0 = relative
$Typo3_htmlmail->substHREFsInHTML();
$Typo3_htmlmail->setHTML($Typo3_htmlmail->encodeMsg($Typo3_htmlmail->theParts['html']['content']));
if ($message) {
$Typo3_htmlmail->addPlain($message);
}
} else {
// -- $Typo3_htmlmail->addPlain($message);
$Typo3_htmlmail->setBody($message);
}
// -- $Typo3_htmlmail->setHeaders();
if ($attachment != '') {
if (isset($Typo3_htmlmail->theParts) && is_array($Typo3_htmlmail->theParts) && isset($Typo3_htmlmail->theParts['attach']) && is_array($Typo3_htmlmail->theParts['attach'])) {
foreach ($Typo3_htmlmail->theParts['attach'] as $k => $media) {
$Typo3_htmlmail->theParts['attach'][$k]['filename'] = basename($media['filename']);
}
}
}
// -- $Typo3_htmlmail->setContent();
// -- $Typo3_htmlmail->setRecipient(explode(',', $toEMail));
$hookVar = 'sendMail';
if ($hookVar && is_array ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TT_PRODUCTS_EXTkey][$hookVar])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][TT_PRODUCTS_EXTkey][$hookVar] as $classRef) {
$hookObj= &t3lib_div::getUserObj($classRef);
if (method_exists($hookObj, 'init')) {
$hookObj->init($Typo3_htmlmail);
}
if (method_exists($hookObj, 'sendMail')) {
$rc = $hookObj->sendMail($Typo3_htmlmail,$toEMail,$subject,$message,$html,$fromEMail,$fromName,$attachment);
}
}
}
if ($rc !== FALSE) {
// -- $Typo3_htmlmail->sendTheMail();
$Typo3_htmlmail->send();
}
}
}
Hilfe hat mir folgende Seite gegeben: http://forge.typo3.org/attachments/5111/linkvalidator-swiftmailer.diff
Ich hoffe, ich konnte helfen!
Viele Grüße,
Max