* @return PPNode_Hash_Tree
*/
public function preprocessToObj( $text, $flags = 0 ) {
- wfProfileIn( __METHOD__ );
// Check cache.
global $wgMemc, $wgPreprocessorCacheThreshold;
&& strlen( $text ) > $wgPreprocessorCacheThreshold;
if ( $cacheable ) {
- wfProfileIn( __METHOD__ . '-cacheable' );
$cacheKey = wfMemcKey( 'preprocess-hash', md5( $text ), $flags );
$cacheValue = $wgMemc->get( $cacheKey );
// From the cache
wfDebugLog( "Preprocessor",
"Loaded preprocessor hash from memcached (key $cacheKey)" );
- wfProfileOut( __METHOD__ . '-cacheable' );
- wfProfileOut( __METHOD__ );
return $hash;
}
}
- wfProfileIn( __METHOD__ . '-cache-miss' );
}
$rules = array(
}
if ( !$node ) {
if ( $cacheable ) {
- wfProfileOut( __METHOD__ . '-cache-miss' );
- wfProfileOut( __METHOD__ . '-cacheable' );
}
- wfProfileOut( __METHOD__ );
throw new MWException( __METHOD__ . ': eqpos not found' );
}
if ( $node->name !== 'equals' ) {
if ( $cacheable ) {
- wfProfileOut( __METHOD__ . '-cache-miss' );
- wfProfileOut( __METHOD__ . '-cacheable' );
}
- wfProfileOut( __METHOD__ );
throw new MWException( __METHOD__ . ': eqpos is not equals' );
}
$equalsNode = $node;
if ( $cacheable ) {
$cacheValue = sprintf( "%08d", self::CACHE_VERSION ) . serialize( $rootNode );
$wgMemc->set( $cacheKey, $cacheValue, 86400 );
- wfProfileOut( __METHOD__ . '-cache-miss' );
- wfProfileOut( __METHOD__ . '-cacheable' );
wfDebugLog( "Preprocessor", "Saved preprocessor Hash to memcached (key $cacheKey)" );
}
- wfProfileOut( __METHOD__ );
return $rootNode;
}
}