Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2203 from camspiers/config-memory

Improve memory performance when generating config static and class caches
  • Loading branch information...
commit 3bfb82d25fd08e6421074fd3b9bf3ebc5d73f601 2 parents 10b5517 + 2d30592
@chillu chillu authored
View
13 core/manifest/ClassManifest.php
@@ -274,6 +274,15 @@ public function getModules() {
}
/**
+ * Used to set up files that we want to exclude from parsing for performance reasons.
+ */
+ protected function setDefaults()
+ {
+ $this->classes['sstemplateparser'] = FRAMEWORK_PATH.'/view/SSTemplateParser.php';
+ $this->classes['sstemplateparseexception'] = FRAMEWORK_PATH.'/view/SSTemplateParser.php';
+ }
+
+ /**
* Completely regenerates the manifest file.
*
* @param bool $cache Cache the result.
@@ -289,10 +298,12 @@ public function regenerate($cache = true) {
$this->$reset = array();
}
+ $this->setDefaults();
+
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^(_config.php|[^_].*\.php)$/',
- 'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
+ 'ignore_files' => array('index.php', 'main.php', 'cli-script.php', 'SSTemplateParser.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile'),
'dir_callback' => array($this, 'handleDir')
View
2  core/manifest/ConfigStaticManifest.php
@@ -100,7 +100,7 @@ public function regenerate($cache = true) {
$finder = new ManifestFileFinder();
$finder->setOptions(array(
'name_regex' => '/^([^_].*\.php)$/',
- 'ignore_files' => array('index.php', 'main.php', 'cli-script.php'),
+ 'ignore_files' => array('index.php', 'main.php', 'cli-script.php', 'SSTemplateParser.php'),
'ignore_tests' => !$this->tests,
'file_callback' => array($this, 'handleFile')
));
View
13 tests/core/manifest/ClassManifestTest.php
@@ -36,17 +36,20 @@ public function testGetItemPath() {
public function testGetClasses() {
$expect = array(
- 'classa' => "{$this->base}/module/classes/ClassA.php",
- 'classb' => "{$this->base}/module/classes/ClassB.php",
- 'classc' => "{$this->base}/module/classes/ClassC.php",
- 'classd' => "{$this->base}/module/classes/ClassD.php"
+ 'classb' => "{$this->base}/module/classes/ClassB.php",
+ 'classa' => "{$this->base}/module/classes/ClassA.php",
+ 'classb' => "{$this->base}/module/classes/ClassB.php",
+ 'classc' => "{$this->base}/module/classes/ClassC.php",
+ 'classd' => "{$this->base}/module/classes/ClassD.php",
+ 'sstemplateparser' => FRAMEWORK_PATH."/view/SSTemplateParser.php",
+ 'sstemplateparseexception' => FRAMEWORK_PATH."/view/SSTemplateParser.php"
);
$this->assertEquals($expect, $this->manifest->getClasses());
}
public function testGetClassNames() {
$this->assertEquals(
- array('classa', 'classb', 'classc', 'classd'),
+ array('sstemplateparser', 'sstemplateparseexception', 'classa', 'classb', 'classc', 'classd'),
$this->manifest->getClassNames());
}
View
19 tests/core/manifest/NamespacedClassManifestTest.php
@@ -12,7 +12,7 @@ class NamespacedClassManifestTest extends SapphireTest {
public function setUp() {
parent::setUp();
-
+
$this->base = dirname(__FILE__) . '/fixtures/namespaced_classmanifest';
$this->manifest = new SS_ClassManifest($this->base, false, true, false);
}
@@ -41,17 +41,20 @@ public function testGetClasses() {
'silverstripe\test\classe' => "{$this->base}/module/classes/ClassE.php",
'silverstripe\test\classf' => "{$this->base}/module/classes/ClassF.php",
'silverstripe\test\classg' => "{$this->base}/module/classes/ClassG.php",
- 'silverstripe\test\classh' => "{$this->base}/module/classes/ClassH.php"
+ 'silverstripe\test\classh' => "{$this->base}/module/classes/ClassH.php",
+ 'sstemplateparser' => FRAMEWORK_PATH."/view/SSTemplateParser.php",
+ 'sstemplateparseexception' => FRAMEWORK_PATH."/view/SSTemplateParser.php"
);
-
+
$this->assertEquals($expect, $this->manifest->getClasses());
}
public function testGetClassNames() {
$this->assertEquals(
- array('silverstripe\test\classa', 'silverstripe\test\classb', 'silverstripe\test\classc',
- 'silverstripe\test\classd', 'silverstripe\test\classe', 'silverstripe\test\classf',
- 'silverstripe\test\classg', 'silverstripe\test\classh'),
+ array('sstemplateparser', 'sstemplateparseexception', 'silverstripe\test\classa',
+ 'silverstripe\test\classb', 'silverstripe\test\classc', 'silverstripe\test\classd',
+ 'silverstripe\test\classe', 'silverstripe\test\classf', 'silverstripe\test\classg',
+ 'silverstripe\test\classh'),
$this->manifest->getClassNames());
}
@@ -59,7 +62,7 @@ public function testGetDescendants() {
$expect = array(
'silverstripe\test\classa' => array('silverstripe\test\ClassB', 'silverstripe\test\ClassH'),
);
-
+
$this->assertEquals($expect, $this->manifest->getDescendants());
}
@@ -109,7 +112,7 @@ public function testGetConfigs() {
$expect = array("{$this->base}/module/_config.php");
$this->assertEquals($expect, $this->manifest->getConfigs());
}
-
+
public function testGetModules() {
$expect = array(
"module" => "{$this->base}/module",
Please sign in to comment.
Something went wrong with that request. Please try again.