Пример #1
0
    include_once PATH_LIB . "exception_handler.inc.php";
    set_error_handler("myErrorHandler");
    register_shutdown_function("shutdown");
    set_exception_handler("send_http_error");
}
//clean disconnect handling
register_shutdown_function(function () {
    if (isset($GLOBALS["STEAM"])) {
        $GLOBALS["STEAM"]->disconnect();
    }
});
/*
 * setup autoloader
 */
require_once PATH_DEPENDING . "classes/autoloader/Autoloader.php";
Autoloader::getRegisteredAutoloader()->remove();
$autoloaderIndexFile = PATH_TEMP . "koala_autoloader.gz";
if (DEVELOPMENT_MODE && browserNoCache() && !isAjaxRequest() && !isPhpCli()) {
    if (file_exists($autoloaderIndexFile)) {
        unlink($autoloaderIndexFile);
    }
}
if (dropCache() && !isAjaxRequest()) {
    emptyCacheFolder();
}
$autoloader = new Autoloader(PATH_BASE);
$autoloader->register();
$autoloader->getIndex()->setIndexPath($autoloaderIndexFile);
$autoloader->getFileIterator()->setOnlyDirPattern("~/((core)|(depending)|(extensions))~");
$autoloader->getFileIterator()->setOnlyFilePattern("~\\.php\$~i");
$autoloader->getFileIterator()->addSkipDirPattern("~/((javascript)|(\\.settings)|(\\.todo)|(cache)|(log)|(temp))~");
Пример #2
0
 /**
  * Creates new indexes which are tested in this benchmark
  *
  * @see _fillIndex()
  * @return Array
  */
 private function _createIndexes()
 {
     try {
         self::$_pdoPool['mysql'] = new PDO("mysql:dbname=test");
     } catch (PDOException $e) {
         /*
          * This happens when too many connections are open.
          * We will reuse the last connection.
          */
     }
     $indexes = array("sqlite" => AutoloaderIndex_PDO::getSQLiteInstance($this->_sqliteFile), "mysql" => new AutoloaderIndex_PDO(self::$_pdoPool['mysql']), "hashtable" => new AutoloaderIndex_SerializedHashtable(), "hashtableGZ" => new AutoloaderIndex_SerializedHashtable_GZ(), "hashtableCSV" => new AutoloaderIndex_CSV(), "hashtableIni" => new AutoloaderIndex_IniFile(), "hashtablePHP" => new AutoloaderIndex_PHPArrayCode());
     $indexes["hashtable"]->setIndexPath($this->_hashtable);
     $indexes["hashtableGZ"]->setIndexPath($this->_hashtableGZ);
     $indexes["hashtableCSV"]->setIndexPath($this->_hashtableCSV);
     $indexes["hashtableIni"]->setIndexPath($this->_hashtableIni);
     $indexes["hashtablePHP"]->setIndexPath($this->_hashtablePHP);
     foreach ($indexes as $index) {
         Autoloader::getRegisteredAutoloader()->setIndex($index);
     }
     return $indexes;
 }
Пример #3
0
 /**
  * Asserts that Autoloader::getRegisteredAutoloaders() returns all registered
  * instances of Autoloaders
  *
  * @see Autoloader::getRegisteredAutoloaders()
  * @return void
  */
 public function testGetRegisteredAutoloaders()
 {
     $autoloaders = array();
     $autoloaders[] = Autoloader::getRegisteredAutoloader();
     $newAutoloader = new Autoloader(sys_get_temp_dir());
     $newAutoloader->register();
     $autoloaders[] = $newAutoloader;
     foreach ($autoloaders as $expectedAutoloader) {
         foreach (Autoloader::getRegisteredAutoloaders() as $autoloader) {
             if ($autoloader === $expectedAutoloader) {
                 continue 2;
             }
         }
         $this->fail("Autoloader wasn't registered.");
     }
     $newAutoloader->remove();
 }