save value in session since TYPO3 10.4 - typo3

i want to save values in a anonymous session in an extbase extension. Up to 10.4 it was possible to use
$GLOBALS['TSFE']->fe_user->setKey('ses', 'id', $data);
$GLOBALS["TSFE"]->storeSessionData();
but since 10.4 this does not work anymore.
How is the prefered way in version 10/11?
Thanks!

Reading the deprecation entry gives me the feeling that
$frontendUser->storeSessionData();
should work fine

Related

TYPO3 website doesn't work after changing db

I want to make a copy of my TYPO3 CMS 6.2.18 website - what I did so far:
Copied the entire website folder (including the TYPO3 installation)
Copied the entire database (with a new name)
Created a new db user for the copied db
Adjusted the file /typo3conf/LocalConfiguration.php accordingly to the new DB+User
Now I'm receiving following errors when calling different urls of my copied TYPO3 website:
When I try calling the "Upgrade Wizard" from inside the install tool /typo3/install (which is the only page that currently works):
#1: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/<my-domain>/typo3/sysext/install/Classes/Service/SqlSchemaMigrationService.php line 409
When I call <my-domain>/typo3
#1: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/<my-domain>/typo3/sysext/backend/Classes/Utility/BackendUtility.php line 3022
4 count(NULL)
...
/var/www/vhosts/<my-domain>/typo3/sysext/backend/Classes/Utility/BackendUtility.php:
03020: $signals = array();
03021: $modData = $GLOBALS['BE_USER']->getModuleData('TYPO3\\CMS\\Backend\\Utility\\BackendUtility::getUpdateSignal', 'ses');
03022: if (!count($modData)) {
03023: return '';
03024: }
When I call <my-domain>
#1: PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/<my-domain>/typo3/sysext/core/Classes/Database/PreparedStatement.php line 582
...after calling...
TYPO3\CMS\Core\Database\PreparedStatement::convertNamedPlaceholdersToQuestionMarks("SELECT * FROM fe_session_data WHERE hash = :hash", array, array)
What's interesting to me:
After copying the website the copy worked, only after referencing it to the copied db it showed these errors.
Anyone an idea what I could do / be looking for?
I tried deleting all cache, all tables shown in the "Cleanup" part of the install tool and all files in the typoe3temp folder already.
So, as I have said in the comment. Probably the issue with PHP version, because of all the mentioned errors (warning actually ;) ) reflect the incompatible PHP code.
The solution is pretty easy, switch your PHP version according to TYPO3's need :)

Problem with referencing files via "FILE:EXT" in TYPO3

I just upgraded a TYPO3 extension with cal and had an exception. This was resolved by changing the constant:
plugin.tx_cal_controller.view.list.listTemplate =
FILE:EXT:somextkey/somepath/list.tmpl
to
plugin.tx_cal_controller.view.list.listTemplate =
EXT:someextkey/somepath/list.tmpl
While the latter is how it is documented in the cal docs and should have been used in the first place, this is an easy mistake to make, because often FILE:EXT is actually used to reference files. I don't know why this worked in TYPO3 8 and not in TYPO3 9.
The part that broke was
$absPath = $GLOBALS['TSFE']->tmpl->getFileName($path);
with $path being the path as defined by the constant.
Also, on this page TypoScript Syntax: Includes both variants are used:
and
Is there an easy to remember rule what is to be used when, is the variant "FILE:EXT" deprecated?
FILE:EXT: is only for inclusion because there we have also DIR:EXT:. For templates you always need EXT:. The only other exception is with languages: LLL:EXT:. It is like this since TYPO3 3.x.

f:uri.image inline-Viewhelper does not work

I am trying to access an imageurl via inlinecondition in fluid.
The none inlineversion works well and returns the URI of that image:
<f:uri.image image="{data.image.0}" />
returns:
fileadmin/user_upload/jumbotron.jpg
This one doesn't:
{f:uri.image(image:data.image.0)}
I have tried different versions with {}, without, with '' without ...
My environment is: TYPO3 8.2 (as I can't update cause extensions I need are only available till this version for now)
Can someone please help me?
Seems this was a bug in 8.2 - After updating to 8.4 it works like charm.
This code works:
{f:uri.image(image:data.image.0)}
Try using {f:uri.image(image:'{data.image.0}')}, mind the escaping

Umlauted Characters are not properly shown after updating TYPO3 to 6.2

I've updated my TYPO3 website from 4.1 to 6.2.9. Now the Umlauted Characters [German Letters] are not shown properly. Is there any Idea to fix that.
I experienced similar troubles when upgrading from 4.1 to 4.2. The following paragraphs are notes from my blog. Hope it helps.
Updating from TYPO3 4.1 (and earlier versions) to 4.2 (and later)
Some DB fields in 4.1 are of type BLOB (for example the TS templates). Most of these fields get converted to TEXT in 4.2. Now think about the following scenario, which seems to be common. The template was saved using TYPO3 4.1 and a DB using latin1 (ISO-8859-X) as charset. Then the DB converted to UTF-8 and TYPO3 was configured accordingly. You think you're finished because everything works will. But in most cases, there's still some latin1 formatted data in the BLOB fields. You just don't see. Once you upgrade TYPO3 to 4.2, these BLOBs get converted to TEXT, assuming the data is UTF-8. But it's latin1, because BLOB was not converted before. The result is a broken template. Lots of people in the mailing lists complain about whole parts missing. The reason is invalid non ascii characters (like umlauts äöüé¢ etc), which break the template view.
How to avoid that?
If you change the charset of TYPO3 and/or your DB, convert those BLOB fields which would have been changed by the TYPO3 update to TEXT before converting the charset or make sure to convert the BLOB data otherwise.
More about UTF-8 and older versions of TYPO3: https://stmllr.net/blog/thinking-about-utf-8-character-set-conversion-in-typo3/ Creative Commons License CC BY-SA 3.0

Zend Framework Can't determine mime type of image upload

Hi all I'm trying to upload a image when creating a item in my app, however the action fails returning the following error: The mimetype of file 'mytestimage.jpg' could not be detected.
I've tried adding a Mime Type validator but the error persists, can anyone tell me where I'm going wrong in the code below.
// Image uploads
$images = new Zend_Form_Element_File('images');
$images->setMultiFile(2)
->addValidator('IsImage')
->addValidator('Size',false,'5242880')
->addValidator('Extension',false,'jpg,png,gif')
->addValidator('ImageSize',false,array(
'minwidth' => 250,
'minheight'=>250,
'maxwidth'=>500,
'maxheight'=>500
))
->setValueDisabled(true);
Many thanks in advance.
Graham
I had the same problem.
Zend_Frameworks tries to determine the mimetype in two ways:
First it tries to use the PECL FILEINFO-Extension (which is not installed on every server)
if the extension is not istalled it tries to use mime_content_type (a php function). This function however is deprecated as of php version 5.3
So in this case I guess your hoster is using php version 5.3 and has not installed the PECL FILEINFO-Extension. Same goes unfortunately for my hoster :(
Here are more details of the two ways in the php-manual:
http://de.php.net/manual/en/function.mime-content-type.php
http://de.php.net/manual/en/ref.fileinfo.php
By the way. You can see the code ZF uses in the file "Zend\File\Transfer\Adapter\Http.php" (lines 1281-1318: methodname is _detectMimeType