Project

General

Profile

Actions

Bug #21181

closed

Call to getCache() on a non-object

Added by Franz Holzinger about 15 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Must have
Category:
Caching
Target version:
-
Start date:
2009-10-03
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.3
PHP Version:
5.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

In some cases, if you call t3lib_div::xml2array out from localconf.php of an extension, then the caching has not been initialized.

Fatal error: Call to a member function getCache() on a non-object in ...../typo3_src-4.3.0beta1/t3lib/class.t3lib_page.php on line 978

$contentHashCache = $GLOBALS['typo3CacheManager']->getCache('cache_hash');

Solution:
It should be checked if the object $GLOBALS['typo3CacheManager'] exists, and if not, the else branch should be called.

(issue imported from #M12109)


Files

0012109.patch (1.64 KB) 0012109.patch Administrator Admin, 2009-10-07 19:25
12109_v2.diff (1.28 KB) 12109_v2.diff Administrator Admin, 2009-10-14 21:44

Related issues 3 (0 open3 closed)

Related to TYPO3 Core - Bug #21196: autoloaders registered by extensions slow down the core autoloaderClosedRupert Germann2009-10-06

Actions
Related to TYPO3 Core - Feature #20562: Speed up xml2array by adding a two level cacheClosedRupert Germann2009-06-03

Actions
Related to TYPO3 Core - Bug #21735: Caching error when clearing indexed search elements in info moduleClosedOliver Hader2009-11-29

Actions
Actions #1

Updated by Oliver Hader about 15 years ago

Does this occur in frontend and/or backend disposal?

Actions #2

Updated by Franz Holzinger about 15 years ago

This occurs in both backend, frontend and install tool. This happens e.g. if you install paymentlib and one of those additional extension which use the ext_localconf.php to register there.

Actions #3

Updated by Oliver Hader about 15 years ago

Hm, I see... However, using the caching framework only will be triggered, when the constant 'TYPO3_UseCachingFramework' is set. And that constant is set after processing the ext_localconf.php files.

So, I would have expected "Use of undefined constant TYPO3_UseCachingFramework". Can you please give a full debug_print_backtrace() of this fatal error?

Actions #4

Updated by Oliver Hader about 15 years ago

Besides the fact that I'm waiting for the backtrace to analyze the problem further, the attached patch prevents from writing xml2array() results to any cache when called from a ext_localconf.php file.

Actions #5

Updated by Rupert Germann about 15 years ago

hi,

I digged into this and found that there's no obvious fix.
In general I see this two possibilities:
1. fix it in the extension
2. fix in the core

The problem here is, that the paymentlib* extensions instantiate their payment providers in ext_localconf.php.
Besides the fact that this is absolutely unneeded at this point and also a serious performance break it will lead to further issues beyound the caching system initialisation.

if I install paymentlib_payone I get only
Fatal error: Class 't3lib_pageSelect' not found in /srv/SVN/forge.typo3.org/Core/trunk/t3lib/class.t3lib_div.php on line 2521

this extension calls the method getAvailablePaymentMethods() which calls t3lib_div::xml2array() already in its constructor.
The problem with the not found class t3lib_page can be fixed by #0012133 (moves the autoloader registration before loading the ext_localconf's)

but the caching problem remains.

Actions #6

Updated by Rupert Germann about 15 years ago

possible solution for the missing cache object:
- disable caching of t3lib_div::xml2array() when there's no caching object
that would slow down things a bit compared to calling t3lib_div::xml2array() with caching, but I don't see a problem here, because that was the situation before 4.3

Of course we could move the caching framework initialisation in front of the ext_localconf loading but we don't want to encourage ext developers to execute code in the ext_localconf.php.
Such extensions will slow down the whole system because the code from ext_localconf will be executed on each click but it will be actually needed on only a few sites.

Actions #7

Updated by Steffen Kamper about 15 years ago

i agree argumentation of Rupi. This is missusage of ext_localconf as this file is loaded "before" anything else.

Solution: move the relevant part to ext_tables.php

Actions #8

Updated by Rupert Germann about 15 years ago

OK, after wasting some more hours I can say that moving the caching framework initialisation before the loading of the localconfs will not work. The caching framework needs a db connection and if the initialisation of class t3lib_db is moved before the extensions, no extension can extend it -> DBAL will not work anymore.

That means: this bug can only be fixed by curing the symptome. Check is there is a cachemanager object in storeHash/getHash and if not do no caching.

Actions #9

Updated by Franz Holzinger about 15 years ago

The same problem comes with the ratings extension:

calling path in t3lib_div::xml2array: require#14154 // require#14154 // t3lib_div::makeInstance#14154 // tx_ratings_ajax->__construct#14154 // language->includeLLFile#14154 // language->readLLfile#14154 // t3lib_div::readLLfile#14154 // t3lib_div::readLLXMLfile#14154 // t3lib_div::xml2array#14154

"Fatal error: Call to a member function getCache() on a non-object in /var/www/web36/web/trunk/t3lib/class.t3lib_div.php on line 2487"

This is the line:
$GLOBALS['typo3CacheManager']->getCache('cache_hash')->set($identifier, $array, array('ident_xml2array'), 0);

This gets called if you choose a rating. Then Ajax seems to be called and causes the error message:

<script type="text/javascript" src="typo3conf/ext/ratings/res/rating.js"></script>
<a href="javascript:void(0)" rel="nofollow" class="tx-ratings-star-1" onclick="tx_ratings_submit('tt_products_2', 1, 'YTozOntzOjM6InBpZCI7aTozMzk7czo0OiJjb25mIjthOjEyOntzOjExOiJpbmNsdWRlTGlicyI7YToyOntpOjA7czo0MDoiRVhUOnJhdGluZ3MvcGkxL2NsYXNzLnR4X3JhdGluZ3NfcGkxLnBocCI7aToxO3M6NDA6IkVYVDpyYXRpbmdzL3BpMS9jbGFzcy50eF9yYXRpbmdzX3BpMS5waHAiO31zOjEwOiJzdG9yYWdlUGlkIjtpOjMzOTtzOjEyOiJ0ZW1wbGF0ZUZpbGUiO3M6Mzg6InR5cG8zY29uZi9leHQvcmF0aW5ncy9yZXMvcmF0aW5ncy5odG1sIjtzOjg6Im1pblZhbHVlIjtzOjE6IjEiO3M6ODoibWF4VmFsdWUiO3M6MToiNSI7czoxNjoicmF0aW5nSW1hZ2VXaWR0aCI7czoyOiIxMSI7czoxMzoiYWRkaXRpb25hbENTUyI7czowOiIiO3M6NDoibW9kZSI7czo0OiJhdXRvIjtzOjE0OiJkaXNhYmxlSXBDaGVjayI7czoxOiIwIjtzOjY6ImV4dGtleSI7czo3OiJyYXRpbmdzIjtzOjM6ImFwaSI7czoxNDoidHhfcmF0aW5nc19hcGkiO3M6MzoicmVmIjtzOjEzOiJ0dF9wcm9kdWN0c18yIjt9czo0OiJsYW5nIjtzOjI6ImRlIjt9', 'b4eb2c6f072aec27ece17247998ea229');return false"></a>

It reads the local language texts and runs into the error message.

Actions #10

Updated by Jacco van der Post almost 15 years ago

Fatal error: Call to a member function getCache() on a non-object in .../class.tx_indexedsearch_modfunc1.php on line 1288

When trying to "Clear ALL phash-rows below" via Info and than Indexed Search.
TYPO3 4.3 rc1

Actions #11

Updated by Rupert Germann almost 15 years ago

committed to trunk rev 6548

Actions #12

Updated by Jochen Weiland almost 15 years ago

The bug is still present in 4.3.0RC2 when using indexed_search (tested with PHP 5.2.8, 5.2.11, 5.3.0, 5.3.1).

Fatal error: Call to a member function getCache() on a non-object in .../typo3_src-4.3.0RC2/typo3/sysext/indexed_search/modfunc1/class.tx_indexedsearch_modfunc1.php on line 1288

steps to reproduce: in Web->Info->Indexed search try to clear a phash-row (the page must have been indexed)

Actions #13

Updated by Oliver Hader almost 15 years ago

Hi Jochen,
thanks for reporting. The message is the same, however it's a different bug that will be handled in this issue: #21735

Actions

Also available in: Atom PDF