Details
-
Bug
-
Resolution: Fixed
-
Medium
-
None
-
4.3.0
-
None
-
Operating System: Linux (kernel 2.6.27 x86_64)
PHP Version: 5.3.3
Database and version: MySQL 5 'doesn't matter anyway)
Browser (and version): Occurs in CLI script mode (require long execution time to spot the bug).
Description
The function getInstance become slower and slower when executed many times in a same script. This is due to the usage of array_key_exists which is somehow bugguy. The problem isi similar to that one : http://issues.ez.no/IssueView.php?Id=17155
Here is the patch :
static function getInstance( eZContentObjectAttribute $objectAttribute ) { //Patch for performance issues by Amaury SECHET //Original test from eZ publish //if ( array_key_exists( $objectAttribute->attribute( 'id' ), self::$singletons ) ) if ( isset( self::$singletons[$objectAttribute->attribute( 'id' )] ) ) { return self::$singletons[$objectAttribute->attribute( 'id' )]; } else { $datatypeString = $objectAttribute->attribute( 'data_type_string' ); // Check if using custom handler. $customMapList = self::$FindINI->variable( 'SolrFieldMapSettings', 'CustomMap' ); //Original test from eZ publish //if ( array_key_exists( $datatypeString, $customMapList ) ) if ( isset( $customMapList[$datatypeString] ) ) { $fieldBaseClass = $customMapList[$datatypeString]; if ( class_exists( $fieldBaseClass ) ) { self::$singletons[$objectAttribute->attribute( 'id' )] = new $customMapList[$datatypeString]( $objectAttribute ); return self::$singletons[$objectAttribute->attribute( 'id' )]; } else { eZDebug::writeError( "Unknown document field base class '$fieldBaseClass' for datatype '$datatypeString', check your ezfind.ini configuration", __METHOD__ ); } } // Return standard handler. self::$singletons[$objectAttribute->attribute( 'id' )] = new ezfSolrDocumentFieldBase( $objectAttribute ); return self::$singletons[$objectAttribute->attribute( 'id' )]; } }
Steps to reproduce
Just import many objects into solr using ezfind in a script.