Skip to content

Commit

Permalink
[modxcms#9450] Prevent non-existent Context initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
opengeek committed Jun 4, 2013
1 parent a27f044 commit c371a90
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion connectors/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
$modx->initialize($ctx);

if (defined('MODX_REQP') && MODX_REQP === false) {
} else if (!$modx->context->checkPolicy('load')) {
} else if (!is_object($modx->context) || !$modx->context->checkPolicy('load')) {
header("Content-Type: application/json; charset=UTF-8");
header('HTTP/1.1 401 Not Authorized');
echo $modx->toJSON(array(
Expand All @@ -43,6 +43,10 @@
));
@session_write_close();
die();
} else {
@session_write_close();
var_dump($modx->context->toArray());
die();
}

if ($ctx == 'mgr') {
Expand Down
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.

- [#9450] Prevent non-existent Context initialization
- [#9896] Improve performance of modTemplateVar::getRenderDirectories()
- [#9859] Prevent conditional output filter recursion
- [#6138] Handle offline errors in RSS feeds
Expand Down
2 changes: 2 additions & 0 deletions core/model/modx/modcachemanager.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ public function generateContext($key, array $options = array()) {

/* cache the Context ACL policies */
$results['policies'] = $obj->findPolicy($contextKey);
} else {
$results = false;
}
} else {
$results = $this->getOption("{$key}_results", $options, array());
Expand Down
7 changes: 4 additions & 3 deletions core/model/modx/modx.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ public function hasPermission($pm) {

/**
* Logs a manager action.
*
*
* @param string $action The action to pull from the lexicon module.
* @param string $class_key The class key that the action is being performed on.
* @param mixed $item The primary key id or array of keys to grab the object with.
Expand Down Expand Up @@ -2076,7 +2076,7 @@ public function checkSiteStatus() {

/**
* Add an extension package to MODX
*
*
* @param string $name
* @param string $path
* @param array $options
Expand Down Expand Up @@ -2130,7 +2130,7 @@ public function addExtensionPackage($name,$path,array $options = array()) {

/**
* Remove an extension package from MODX
*
*
* @param string $name
* @return boolean
*/
Expand Down Expand Up @@ -2216,6 +2216,7 @@ protected function _initContext($contextKey, $regenerate = false, $options = nul
}
if ($this->context) {
if (!$this->context->prepare((boolean) $regenerate, is_array($options) ? $options : array())) {
$this->context= null;
$this->log(modX::LOG_LEVEL_ERROR, 'Could not prepare context: ' . $contextKey);
} else {
//This fixes error with multiple contexts
Expand Down

0 comments on commit c371a90

Please sign in to comment.