Project

General

Profile

Actions

Bug #16998

closed

Warning displayed when using $GLOBALS["TSFE"]->fe_user->setKey(type, key, data)

Added by Christian almost 18 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Category:
-
Target version:
-
Start date:
2007-02-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.0
PHP Version:
4
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If have following PHP-Code inserted in a PHP-Script Content-Element in Typo3 Backend (using Extension "page_php_content"):
$GLOBALS['TSFE']->fe_user->setKey('user','sessionfachgebiete',$fachgebiet);
$GLOBALS['TSFE']->fe_user->storeSessionData();

In Typo3 4.0 and with PHP 4.4.2-1: no problem.
In Typo3 4.0.4 and with PHP 4.3.10: the date is still saved correctly, but some warnings are displayed:

Warning: mysql_real_escape_string(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 555

Warning: mysql_query(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 193

$fachgebiet is an array.
When commenting out the first line, the warnings disappear.
Using getKey no warnings are displayed.

(issue imported from #M5005)

Actions #1

Updated by Michael Stucki almost 18 years ago

Anyone who can reproduce this?

Actions #2

Updated by Oliver Hader almost 18 years ago

"$GLOBALS['TSFE']->fe_user->setKey('user','sessionfachgebiete',$fachgebiet);" and "$fachgebiet is an array."
I guess setKey only accepts a string. Please try to serialize $fachgebiet:
$GLOBALS['TSFE']->fe_user->setKey(
'user',
'sessionfachgebiete',
serialize($fachgebiet)
);

Actions #3

Updated by Christian almost 18 years ago

I tried your code, but still warnings. I also tried to store a pure string "hello" - without success. The code worked with my old typo3-installation on another server - without any warnings. And: the code still works in 4.0.4. - but with the mentioned warnings.

strange: After I tried the your code - and restored it to my original code after this, I now have 6 warnings:

Warning: mysql_real_escape_string(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 555

Warning: mysql_query(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 207

Warning: mysql_real_escape_string(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 555

Warning: mysql_real_escape_string(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 555

Warning: mysql_real_escape_string(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 555

Warning: mysql_query(): 28 is not a valid MySQL-Link resource in /srv/www/vhosts/mentorado-expert.de/httpdocs/typo3_src-4.0.4/t3lib/class.t3lib_db.php on line 176

Don't know why...?

Actions #4

Updated by Oliver Hader almost 18 years ago

Hm, this is strange. It looks like your database connection gets lost or a new connection is created and the old DB is thus invalid. Do you perform selects, connects to a different MySQL database than the TYPO3 DB?

Could you additionally turn on the MySQL debug in the Install Tool (All config, sqlDebug) and tell us the complete SQL queries? Thanks!

Actions #5

Updated by Christian almost 18 years ago

No, I only perform selects to the Typo3-DB. I do this with "normal" PHP-commands - not with the Typo3-DB-functions; and not in an extension but in a "normal" (external) PHP-script included as a content element (using Extension "page_php_content"). I turned sqlDebug "on" in install-tool, but no further warnings/errors are displayed. Probably because I use "page_php_content" with normal PHP-MySQL-commands?

I'm using serveral scripts like this.
At the beginning the DB is opened with $db=mysql_connect($config["datenbank"],$config["benutzer"],$config["passwort"]);
at the end it's closed with mysql_close($db);
> No warnings as long as I do not use "$GLOBALS['TSFE']->fe_user->setKey('ses','sessionfachgebiete',$fachgebiet);" in the script.

Now I discovered the following:
a) The same PHP-script in my new and in my old T3-installation
b) Using "$GLOBALS['TSFE']->fe_user->setKey('ses','sessionfachgebiete',$fachgebiet);" togehter with "mysql_close($db)" at the end of the script in the OLD installation: no warnings.
c) Using "$GLOBALS['TSFE']->fe_user->setKey('ses','sessionfachgebiete',$fachgebiet);" togehter with "mysql_close($db)" at the end of the script in the NEW installation: the mentioned warnings.
d) Commenting out "mysql_close($db)" in the NEW installation: no warnings any more.

> "$GLOBALS['TSFE']->fe_user->setKey('ses','sessionfachgebiete',$fachgebiet);" together with "mysql_close($db);" doesn't work in the new installation. A bug or a difference between my two installations (configuration or something else)?
Actions #6

Updated by Oliver Hader almost 18 years ago

The SQL debug information isn't shown since you do not use $GLOBALS['TYPO3_DB']. So, your script closes the TYPO3 database connection and after that mysql_close($db) the regular TYPO3 scripts are without a connection.

If it is necessary to use mysql_query directly you can use mysql_query($sqlQuery, $GLOBALS['TYPO3_DB']->link). Furthermore you can then remove the additional mysql_connect() and mysql_close() calls.
But it would be better to use $GLOBALS['TYPO3_DB']->exec_SELECTquery(...) to perform e.g. SELECT queries instead of using mysql_query(...) directly.

Result: Your external script produces the error thus it is not concerning the TYPO3 Core.

Actions #7

Updated by Christian almost 18 years ago

Ok, thank you very much! I will change the code using "$GLOBALS['TYPO3_DB']" to solve the problem.

What I still don't unterstand: why do the warnings only appear in my new T3-installation? And why do all my other scripts without "setKey" do not produce this warnings (I close the DB at the end of every script)?
Whatever... ;-)

Actions #8

Updated by Christian Kuhn over 15 years ago

Resolved, no change required as requested by reporter due to incorrect direct mysql calls.

Actions #9

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF