Bug #24757
closedBE ajax request fails on some systems with php 5.3
0%
Description
Beacause of a php bug on some systems the request to ajax.php fails because it includes '../t3lib/class.t3lib_div.php' with relative path while init.php uses PATH_t3lib.'class.t3lib_div.php'. On some systems PHP seems not to be able to detect the already included file when different patch are used.
Was detected on mac/MAMP PHP 5.3.2 with introductionpackage 4.5RC1
Solution: remove loading of t3lib_div and use $_REQUEST['ajaxID'];
http://lists.typo3.org/pipermail/typo3-dev/2011-January/042340.html
(issue imported from #M17250)
Files
Updated by Oliver Hader almost 14 years ago
Does PHP throw any errors in this case? What does the logfile tell?
Updated by Joh. Feustel almost 14 years ago
there is some more information in the mailing list.
Actually the problem seems to be with the internal require_once handling of PHP which doesnt recognize the already included file. So the logfile says
[24-Jan-2011 15:49:53] PHP Fatal error: Cannot redeclare class t3lib_div in /Users/jo/Sites/introduction/t3lib/class.t3lib_div.php on line 230
This is probably caused by the internal realpath function which returns not the same path as detected for PATH_t3lib constant. In my case the paths are the following:
realpath('../t3lib/class.t3lib_div.php'): /users/jo/Sites/introduction/t3lib/class.t3lib_div.php
PATH_t3lib.'class.t3lib_div.php'): /Users/jo/Sites/introduction/t3lib/class.t3lib_div.php
Notice the lowercase u which is wrong here but works because of case insensitive file system.
This is the default website directory of my mac user account and many users trying out the introduction package might put the files there.
Inserting
if (class_exists('t3lib_div')) { return; }
in class.t3lib_div.php as proposed by Tolleiv did not help since at least on my system there where many strange "LF" outputs (as strings) all over the backend.
Updated by Joh. Feustel almost 14 years ago
Since there where some objections against calling $_REQUEST directly v3 changes the require_once to call the file with absolute path using dirname(FILE).
Strange anough that getcwd() also returned wrong path with only one letter in lowercase as mentioned in my last comment.
Updated by Christa Pottfay over 13 years ago
Hi, some more information: I encountered similar problems on mac os x 10.5, php v. 5.3.0 (entropy-php), but not only with ajax.php.
First occurrence was with typo3 4.4.4, one day I could no longer login to backend. Curiously I could log in after reboot, but the next time I tried it was not possible again. After a next reboot - no login.
Php-error:
PHP Fatal error: Cannot redeclare class backend_toolbarItem in /Users/christa/Sites/typo3_src-4.4.4/typo3/interfaces/interface.backend_toolbaritem.php on line 36
PHP Stack trace:
PHP 1. {main}() /Users/christa/Sites/typo3_src-4.4.4/typo3/backend.php:0
PHP 2. include_once() /Users/christa/Sites/typo3_src-4.4.4/typo3/backend.php:744
PHP 3. require_once() /Users/christa/Sites/sca/typo3conf/ext/t3dev/class.tx_t3dev_additionalToolbarIcons.php:25
I deactivated extension t3dev and problem was solved. Then I updated to version 4.4.6 - same error with opendocs:
PHP Fatal error: Cannot redeclare class backend_toolbarItem in /Users/christa/Sites/typo3_src-4.4.6/typo3/interfaces/interface.backend_toolbaritem.php on line 36, referer: http://localhost/~christa/sca/typo3/index.php
PHP Stack trace:, referer: http://localhost/~christa/sca/typo3/index.php
PHP 1. {main}() /Users/christa/Sites/typo3_src-4.4.6/typo3/backend.php:0, referer: http://localhost/~christa/sca/typo3/index.php
PHP 2. include_once() /Users/christa/Sites/typo3_src-4.4.6/typo3/backend.php:744, referer: http://localhost/~christa/sca/typo3/index.php
PHP 3. include_once() /Users/christa/Sites/typo3_src-4.4.6/typo3/sysext/opendocs/registerToolbarItem.php:8, referer: http://localhost/~christa/sca/typo3/index.php
PHP 4. require_once() /Users/christa/Sites/typo3_src-4.4.6/typo3/sysext/opendocs/class.tx_opendocs.php:28, referer: http://localhost/~christa/sca/typo3/index.php
I solved the problem in deactivating opendocs, then I could login to the backend again. The php-error-log still lists errors referring to ajax.php, but I ecountered no problems in login and working in the backend.
Error-log:
PHP Fatal error: Cannot redeclare class t3lib_div in /Users/christa/Sites/typo3_src-4.4.6/t3lib/class.t3lib_div.php on line 230, referer: http://localhost/~christa/sca/typo3/backend.php
PHP Stack trace:, referer: http://localhost/~christa/sca/typo3/backend.php
PHP 1. {main}() /Users/christa/Sites/typo3_src-4.4.6/typo3/ajax.php:0, referer: http://localhost/~christa/sca/typo3/backend.php
PHP 2. require() /Users/christa/Sites/typo3_src-4.4.6/typo3/ajax.php:55, referer: http://localhost/~christa/sca/typo3/backend.php
PHP 3. require_once() /users/christa/Sites/typo3_src-4.4.6/typo3/init.php:200, referer: http://localhost/~christa/sca/typo3/backend.php
Today I made a new typo3-installation with version 4.5.2 - same problem as mentioned above (with ajax.php). Login was possible, but Error-Message "Module loader. No module found. If this is a temporary error, please reload the Backend!" is the only thing that appears.
Error-log:
PHP Fatal error: Cannot redeclare class t3lib_div in /Users/christa/Sites/typo3_src-4.5.2/t3lib/class.t3lib_div.php on line 230, referer: http://localhost/~christa/newsite/typo3/backend.php
PHP Stack trace:, referer: http://localhost/~christa/newsite/typo3/backend.php
PHP 1. {main}() /Users/christa/Sites/typo3_src-4.5.2/typo3/ajax.php:0, referer: http://localhost/~christa/newsite/typo3/backend.php
PHP 2. require() /Users/christa/Sites/typo3_src-4.5.2/typo3/ajax.php:55, referer: http://localhost/~christa/newsite/typo3/backend.php
PHP 3. require_once() /users/christa/Sites/typo3_src-4.5.2/typo3/init.php:200, referer: http://localhost/~christa/newsite/typo3/backend.php
Solved the problem as suggested. But I have no explanation why this started one day, because I can't remember having changed something on my system (no php-update, no typo3-update).
Updated by Xavier Perseguers over 13 years ago
I confirm this bug running:
PHP 5.3.6 from WebStart with those configuration options:
'./configure' '--prefix=/usr/local/webstart/sw/php-5.3' '--with-config-file-path=/usr/local/webstart/sw/php-5.3' '--with-apxs2=/usr/local/webstart/sw/apache2/bin/apxs' '--with-db4=/usr/local/webstart/sw/bdb/' '--with-kerberos=/usr' '--with-mcrypt=/usr/local/webstart/sw/lib-mcrypt' '--with-mhash=/usr/local/webstart/sw/mhash' '--with-ldap=/usr/local/webstart/sw/openldap' '--with-mysql=/usr/local/webstart/sw/mysql' '--with-mysql-sock=/tmp/mysql.sock' '--with-mysqli=/usr/local/webstart/sw/mysql/bin/mysql_config' '--with-pdo-mysql=/usr/local/webstart/sw/mysql' '--with-iodbc=/usr' '--with-zlib-dir=/usr' '--with-bz2' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-shmop' '--enable-sockets' '--enable-mbstring' '--with-gettext=/usr/local/webstart/sw/gettext' '--enable-exif' '--with-jpeg-dir=/usr/local/webstart/sw/lib-jpeg' '--with-png-dir=/usr/local/webstart/sw/lib-png' '--with-freetype-dir=/usr/local/webstart/sw/freetype' '--with-gd' '--enable-gd-native-ttf' '--with-curl=/usr' '--enable-ftp' '--disable-rpath' '--with-xsl' '--enable-soap' '--enable-bcmath' '--enable-calendar' '--enable-cli' '--disable-debug' '--with-openssl' '--with-xmlrpc' '--with-iconv=/usr/local/webstart/sw/lib-iconv' '--with-mssql=/usr/local/webstart/sw/freetds'
Updated by Xavier Perseguers over 13 years ago
master: https://review.typo3.org/#change,1286
TYPO3_4-5: https://review.typo3.org/#change,1293
TYPO3_4-4: https://review.typo3.org/#change,1294
Updated by Xavier Perseguers over 12 years ago
- Status changed from Resolved to Closed