} elseif (!$treeOptions['path']) { $treeOptions['path'] = $srcPath; } $treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#'; if (is_file($treeOptions['path'])) { $sha1 = sha1_file($treeOptions['path']); $existingNode = Site::resolvePath($srcPath); if (!$existingNode || $existingNode->SHA1 != $sha1) { $fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null); SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1); Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}"); } else { Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}"); } } else { $cachedFiles = Emergence_FS::cacheTree($srcPath); Benchmark::mark("precached {$srcPath}: " . $cachedFiles); $exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions); Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult)); } } // commit changes #$repo->git('add --all'); # #$repo->git(sprintf( # 'commit -n -m "%s" --author="%s <%s>"' # ,addslashes($_POST['message']) # ,$GLOBALS['Session']->Person->FullName # ,$GLOBALS['Session']->Person->Email #)); #Benchmark::mark("committed all changes");
Benchmark::mark("precached {$appPath}"); $exportResult = Emergence_FS::exportTree($appPath, $appTmpPath); Benchmark::mark("exported {$appPath} to {$appTmpPath}: " . http_build_query($exportResult)); // write any libraries from classpath $classPaths = explode(',', $App->getBuildCfg('app.classpath')); foreach ($classPaths as $classPath) { if (substr($classPath, 0, 2) == 'x/') { $classPathSource = 'ext-library' . substr($classPath, 1); $cachedFiles = Emergence_FS::cacheTree($classPathSource); Benchmark::mark("precached {$cachedFiles} files from {$classPathSource}"); $exportResult = Emergence_FS::exportTree($classPathSource, "{$appTmpPath}/{$classPath}"); Benchmark::mark("exported {$classPathSource} to {$appTmpPath}/{$classPath}: " . http_build_query($exportResult)); } } // change into app's directory chdir($appTmpPath); Benchmark::mark("chdir to: {$appTmpPath}"); // prepare and run upgrade command $upgradeCmd = Sencha::buildCmd($cmdVersion, 'app upgrade --noframework'); Benchmark::mark("running upgrade CMD: {$upgradeCmd}"); passthru($upgradeCmd, $upgradeCmdStatus); Benchmark::mark("Upgrade CMD finished: exitCode={$upgradeCmdStatus}"); // import results Benchmark::mark("importing {$appTmpPath}"); $importResults = Emergence_FS::importTree($appTmpPath, $appPath, array('exclude' => array("#^/x(/|\$)#", "#/\\.sass-cache(/|\$)#", "#/\\.sencha-backup(/|\$)#", "#/\\.emergence(/|\$)#"))); Benchmark::mark("imported files: " . http_build_query($importResults)); // clean up if (empty($_GET['leaveWorkspace'])) { exec("rm -R {$tmpPath}"); Benchmark::mark("erased {$tmpPath}"); }
if (!is_dir("{$repoPath}/.git")) { die("{$repoPath} does not contain .git"); } // get repo chdir($repoPath); // sync trees foreach ($repoCfg['trees'] as $srcPath => $treeOptions) { if (is_string($treeOptions)) { $treeOptions = array('path' => $treeOptions); } $treeOptions = array_merge($exportOptions, $treeOptions, ['dataPath' => false]); if (!is_string($srcPath)) { $srcPath = $treeOptions['path']; } elseif (!$treeOptions['path']) { $treeOptions['path'] = $srcPath; } $srcFileNode = Site::resolvePath($srcPath); if (is_a($srcFileNode, 'SiteFile')) { $destDir = dirname($treeOptions['path']); if ($destDir && !is_dir($destDir)) { mkdir($destDir, 0777, true); } copy($srcFileNode->RealPath, $treeOptions['path']); Benchmark::mark("exported file {$srcPath} to {$treeOptions['path']}"); } else { $exportResult = Emergence_FS::exportTree($srcPath, $treeOptions['path'], $treeOptions); Benchmark::mark("exported directory {$srcPath} to {$treeOptions['path']}: " . http_build_query($exportResult)); } } Benchmark::mark("wrote all changes");
$srcPath = $treeOptions['path']; } elseif (!$treeOptions['path']) { $treeOptions['path'] = $srcPath; } $srcFileNode = Site::resolvePath($srcPath); if (is_a($srcFileNode, 'SiteFile')) { $destDir = dirname($treeOptions['path']); if ($destDir && !is_dir($destDir)) { mkdir($destDir, 0777, true); } copy($srcFileNode->RealPath, $treeOptions['path']); Benchmark::mark("exported file {$srcPath} to {$treeOptions['path']}"); } else { $exportResult = Emergence_FS::exportTree($srcPath, $treeOptions['path'], $treeOptions); Benchmark::mark("exported directory {$srcPath} to {$treeOptions['path']}: " . http_build_query($exportResult)); } } if (!empty($_REQUEST['syncOnly'])) { exit; } // set author $repo->git(sprintf('git config user.name "%s"', $GLOBALS['Session']->Person->FullName)); $repo->git(sprintf('git config user.email "%s"', $GLOBALS['Session']->Person->Email)); // commit changes $repo->git('add --all'); $repo->git(sprintf('commit -n -m "%s"', addslashes($_POST['message']))); Benchmark::mark("committed all changes"); // push changes $repo->git("push origin {$repoCfg['workingBranch']}"); Benchmark::mark("pushed to {$repoCfg['workingBranch']}");
Benchmark::mark("saved git wrapper to {$gitWrapperPath}"); // create new repo $repo = PHPGit_Repository::create($repoPath, !empty($_REQUEST['debug'])); Benchmark::mark("initialized git repo in {$repoPath}"); // add remote $repo->git("remote add origin {$repoCfg['remote']}"); Benchmark::mark("added origin {$repoCfg['remote']}"); // fetch remote branch if (!empty($repoCfg['originBranch'])) { $repo->git("fetch origin {$repoCfg['originBranch']}"); Benchmark::mark("fetched origin/{$repoCfg['originBranch']}"); } // create local working branch if (!empty($repoCfg['originBranch'])) { $repo->git("checkout -b {$repoCfg['workingBranch']} FETCH_HEAD"); Benchmark::mark("created local branch {$repoCfg['workingBranch']}"); } else { die('TODO: handle initializing repo without originBranch'); // see http://git.661346.n2.nabble.com/how-to-start-with-non-master-branch-td3284326.html } // add gitignore $gitIgnorePath = "{$repoPath}/.gitignore"; $gitIgnoreContent = file_exists($gitIgnorePath) ? file_get_contents($gitIgnorePath) : ''; if (!preg_match('/^\\.emergence$/m', $gitIgnoreContent)) { if (!trim($gitIgnoreContent) || !substr($gitIgnoreContent, -1) == PHP_EOL) { $gitIgnoreContent .= PHP_EOL; } $gitIgnoreContent .= "\n# ignore emergence VFS markers:\n.emergence\n"; file_put_contents($gitIgnorePath, $gitIgnoreContent); Benchmark::mark("added .emergence to .gitignore"); }
/** * @return void */ public function run() { $page = $this->getPage(); $response = $this->renderPage($page); Hook::trigger(Hook::ACTION, 'outputGenerated', $response); $response->send(); Hook::trigger(Hook::ACTION, 'outputRendered'); if (0 < static::$DI['Config']->get('display_load_time', 0)) { $time = Benchmark::mark(); echo sprintf("\n<!-- Generated by Herbie in %s seconds | www.getherbie.org -->", $time); } }
<?php $GLOBALS['Session']->requireAccountLevel('Developer'); set_time_limit(0); Benchmark::startLive(); if (!($framework = $_GET['framework'])) { die('parameter "framework" missing'); } if (!($frameworkVersion = $_GET['version'])) { die('parameter "version" missing'); } $cachedFiles = Emergence_FS::cacheTree("sencha-workspace/{$framework}-{$frameworkVersion}"); Benchmark::mark("precached {$cachedFiles} files in sencha-workspace/{$framework}-{$frameworkVersion}");
<?php $GLOBALS['Session']->requireAccountLevel('Developer'); set_time_limit(0); Benchmark::startLive(); foreach (Sencha::$frameworks as $framework => $frameworkConfig) { $cachedFiles = Emergence_FS::cacheTree("sencha-workspace/{$framework}-{$frameworkConfig['defaultVersion']}"); Benchmark::mark("precached sencha-workspace/{$framework}-{$frameworkConfig['defaultVersion']}"); } // precache workspace config $cachedFiles = Emergence_FS::cacheTree('sencha-workspace/.sencha'); Benchmark::mark("precached sencha-workspace/.sencha");
$treeOptions = array('path' => $treeOptions); } if (!is_string($srcPath)) { $srcPath = $treeOptions['path']; } elseif (!$treeOptions['path']) { $treeOptions['path'] = $srcPath; } if (is_string($treeOptions['exclude'])) { $treeOptions['exclude'] = array($treeOptions['exclude']); } $treeOptions['exclude'][] = '#(^|/)\\.git(/|$)#'; $treeOptions['dataPath'] = false; try { if (is_file($treeOptions['path'])) { $sha1 = sha1_file($treeOptions['path']); $existingNode = Site::resolvePath($srcPath); if (!$existingNode || $existingNode->SHA1 != $sha1) { $fileRecord = SiteFile::createFromPath($srcPath, null, $existingNode ? $existingNode->ID : null); SiteFile::saveRecordData($fileRecord, fopen($treeOptions['path'], 'r'), $sha1); Benchmark::mark("importing file {$srcPath} from {$treeOptions['path']}"); } else { Benchmark::mark("skipped unchanged file {$srcPath} from {$treeOptions['path']}"); } } else { $exportResult = Emergence_FS::importTree($treeOptions['path'], $srcPath, $treeOptions); Benchmark::mark("importing directory {$srcPath} from {$treeOptions['path']}: " . http_build_query($exportResult)); } } catch (Exception $e) { Benchmark::mark("failed to import directory {$srcPath} from {$treeOptions['path']}: " . $e->getMessage()); } }
<?php $GLOBALS['Session']->requireAccountLevel('Developer'); set_time_limit(0); Benchmark::startLive(); // precache workspace config $cachedFiles = Emergence_FS::cacheTree('sencha-workspace/.sencha'); Benchmark::mark("precached sencha-workspace/.sencha"); // precache workspace packages $cachedFiles = Emergence_FS::cacheTree('sencha-workspace/packages'); Benchmark::mark("precached sencha-workspace/packages"); // precache workspace microloaders $cachedFiles = Emergence_FS::cacheTree('sencha-workspace/microloaders'); Benchmark::mark("precached sencha-workspace/microloaders");
/** * Function which starts web application. * * @static * @access public * @since 1.0.0-alpha * @version 1.0.0-alpha */ public static function startApp() { if (!file_exists(PATH_APP)) { throw new \Exception('Application directory does not exist.'); } // initialize basic functionalities Router::loadModulesList(); DB::create(); Cache::factory(); Session::init(); Router::factory(); // 2nd mark added to global 'indexView::php' view Benchmark::mark('start'); echo Router::getInstance()->executeAction(); }
File: core.system.php ----------------------------------------------------- Purpose: This file initializes ExpressionEngine. It loads the system preferences and instantiates the base classes. All data flows through this file. ===================================================== */ // -------------------------------------------------- // Turn off magic quotes // -------------------------------------------------- @set_magic_quotes_runtime(0); // ---------------------------------------------- // Instantiate the Benchmark class // ---------------------------------------------- $BM = new Benchmark(); $BM->mark('start'); // Start the timer // -------------------------------------------------- // Kill globals // -------------------------------------------------- if ((bool) @ini_get('register_globals')) { // Would kind of be "wrong" to unset any of these GLOBALS. $protected = array('_SERVER', '_GET', '_POST', '_ENV', '_FILES', '_REQUEST', '_SESSION', 'GLOBALS', 'HTTP_RAW_POST_DATA', 'uri'); foreach (array($_GET, $_POST, $_COOKIE, $_SERVER, $_FILES, $_ENV, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array()) as $global) { if (!is_array($global)) { if (!in_array($global, $protected)) { unset($GLOBALS[$global]); } } else { foreach ($global as $key => $val) { if (!in_array($key, $protected)) {