/** * Calls the RECache algorithm to facilitate the magic-caching of a * controller function's output. * * @param key string The key name to be cached. * @param ttl int The number of seconds until this key should expire. * @param groups array|string|boolean The group name, or array of group * names, to associate the key with; or false to not associate the * key with any group. * @param callback callback A properly formatted callback to a function * within this (extended) class. The result of calling this function * will be cached. * @param args array|boolean An array of arguments to send to the callback * function, or false for no arguments. * @return mixed The return value of the callback function. */ protected function __recache(&$key, &$ttl, &$groups, $callback, &$args) { $cm = RECacheManager::getInstance(); $data = $cm->recache_get($key, $ttl, $groups, array($this, "__getOutput"), array($callback, $args)); if (count($data) === 2) { echo $data[1]; return $data[0]; } // In very rare cases, cached data might be wrong. Log::warn("Cached data for controller " . get_class($this) . " was not properly formatted. Calling " . (isset($callback[1]) ? $callback[1] : "function") . " directly to recover."); return call_user_func_array($callback, $args); }
public static function handleError($errno, $errstr, $errfile, $errline) { if (Config::getVal("errorhandler", "log_errors") == "1") { Log::error($errstr, $errfile, $errline); } ob_end_clean(); $ad = static::$handlerStack[count(static::$handlerStack) - 1]; static::sendHttpCodeHeader($ad->responseCode); switch ($ad->errorType) { case ActionDescriptor::ERRORTYPE_DEFAULT: die(static::constructErrorPage($ad->responseCode)); case ActionDescriptor::ERRORTYPE_FILE: ob_start(); $success = @(include $ad->errorData); $content = ob_get_contents(); ob_end_clean(); die($content); case ActionDescriptor::ERRORTYPE_STRING: die($ad->errorData); case ActionDescriptor::ERRORTYPE_REDIRECT: die(header("Location: " . $ad->errorData)); } }