Skip to content

Commit

Permalink
[modxcms#7279] Handle edge case where processor classes might already…
Browse files Browse the repository at this point in the history
… be loaded with CRCs causing issues with runProcessor
  • Loading branch information
Shaun McCormick committed Mar 5, 2012
1 parent 3f18515 commit 6da5ec7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file shows the changes in recent releases of MODX. The most current release is usually the
development release, and is only shown to give an idea of what's currently in the pipeline.

- [#7279] Handle edge case where processor classes might already be loaded with CRCs causing issues with runProcessor
- Add dashboard name to dashboard title
- [#3818] Add UI/processing to set response code for weblinks
- [#7061] Prevent Static Element access to the core/config/ directory
Expand Down
50 changes: 26 additions & 24 deletions core/model/modx/modmanagerresponse.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,37 +73,39 @@ public function outputContent(array $options = array()) {
$paths = $this->getNamespacePath($theme);
$f = $this->action['controller'];
$className = $this->getControllerClassName();
$classFile = strtolower($f).'.class.php';

foreach ($paths as $controllersPath) {
if (!file_exists($controllersPath.$classFile)) {
if (file_exists($controllersPath.strtolower($f).'/index.class.php')) {
$classPath = $controllersPath.strtolower($f).'/index.class.php';
if (!class_exists($className)) {
$classFile = strtolower($f).'.class.php';

foreach ($paths as $controllersPath) {
if (!file_exists($controllersPath.$classFile)) {
if (file_exists($controllersPath.strtolower($f).'/index.class.php')) {
$classPath = $controllersPath.strtolower($f).'/index.class.php';
}
} else {
$classPath = $controllersPath.$classFile;
break;
}
} else {
$classPath = $controllersPath.$classFile;
break;
}
}

/* handle Revo <2.2 controllers */
if (empty($classPath)) {
$className = 'modManagerControllerDeprecated';
$classPath = MODX_CORE_PATH.'model/modx/modmanagercontrollerdeprecated.class.php';
}

if (!file_exists($classPath)) {
if (file_exists(strtolower($f).'/index.class.php')) {
$classPath = strtolower($f).'/index.class.php';
} else { /* handle Revo <2.2 controllers */
/* handle Revo <2.2 controllers */
if (empty($classPath)) {
$className = 'modManagerControllerDeprecated';
$classPath = MODX_CORE_PATH.'model/modx/modmanagercontrollerdeprecated.class.php';
}
}

ob_start();
require_once $classPath;
ob_end_clean();
if (!file_exists($classPath)) {
if (file_exists(strtolower($f).'/index.class.php')) {
$classPath = strtolower($f).'/index.class.php';
} else { /* handle Revo <2.2 controllers */
$className = 'modManagerControllerDeprecated';
$classPath = MODX_CORE_PATH.'model/modx/modmanagercontrollerdeprecated.class.php';
}
}

ob_start();
require_once $classPath;
ob_end_clean();
}
try {
$c = new $className($this->modx,$this->action);
/* this line allows controller derivatives to decide what instance they want to return (say, for derivative class_key types) */
Expand Down
11 changes: 10 additions & 1 deletion core/model/modx/modx.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,16 @@ public function runProcessor($action = '',$scriptProperties = array(),$options =
if ($isClass) {
/* ensure processor file is only included once if run multiple times in a request */
if (!array_key_exists($processorFile,$this->processors)) {
$className = include $processorFile;
$className = include_once $processorFile;
/* handle already included core classes */
if ($className == 1) {
$s = explode('/',$action);
$o = array();
foreach ($s as $k) {
$o[] = ucfirst(str_replace(array('.','_','-'),'',$k));
}
$className = 'mod'.implode('',$o).'Processor';
}
$this->processors[$processorFile] = $className;
} else {
$className = $this->processors[$processorFile];
Expand Down

0 comments on commit 6da5ec7

Please sign in to comment.