Skip to content

Commit

Permalink
Merge branch 'release-2.2' into develop
Browse files Browse the repository at this point in the history
* release-2.2:
  Remove debugging code (Loud Sigh)
  Bump version for 2.2.8-pl
  Fix pass var by ref error in modX::getInstance()
  [modxcms#9450] Prevent non-existent Context initialization
  Fixed offline problem described in http://tracker.modx.com/issues/6138
  [modxcms#9859] Fix a near infinite recursion loop on TV ouptut filtering
  [modxcms#9896] Reduces time to process TVs

Conflicts:
	_build/build.sample.properties
	_build/build.xml
	core/docs/changelog.txt
	core/docs/version.inc.php
  • Loading branch information
opengeek committed Jun 4, 2013
2 parents fa82f33 + 3161ed1 commit 84f3012
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 23 deletions.
2 changes: 1 addition & 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 Down
6 changes: 6 additions & 0 deletions core/docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ development release, and is only shown to give an idea of what's currently in th
- Allow Namespace-based loading of custom TV files
- Deprecate usage of modAction objects in favor of modNamespace base controller path

MODX Revolution 2.2.8-pl (June 4, 2013)
====================================
- [#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
- Refresh file tree after removing file
- [#9946] Do not cache modResource::$_isForward
- Force browser to root on Media Source change
Expand Down
4 changes: 3 additions & 1 deletion core/model/modx/filters/modoutputfilter.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function __construct(modX &$modx) {
/**
* Filters the output
*
* @param mixed $element The element to filter
* @param modElement $element The element to filter
*/
public function filter(&$element) {
$usemb = function_exists('mb_strlen') && (boolean)$this->modx->getOption('use_multibyte',null,false);
Expand Down Expand Up @@ -633,6 +633,8 @@ public function filter(&$element) {
$this->modx->log(modX::LOG_LEVEL_ERROR,$e->getMessage());
}
}
// convert $output to string if there were any processing
$output = (string)$output;
}
}

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
25 changes: 19 additions & 6 deletions core/model/modx/modtemplatevar.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @property string $properties An array of default properties for this TV
* @property string $input_properties An array of input properties related to the rendering of the input of this TV
* @property string $output_properties An array of output properties related to the rendering of the output of this TV
*
*
* @todo Refactor this to allow user-defined and configured input and output
* widgets.
* @see modTemplateVarResource
Expand All @@ -46,6 +46,13 @@ class modTemplateVar extends modElement {
/** @var modX $xpdo */
public $xpdo;

/**
* A cache for modTemplateVar::getRenderDirectories()
* @see getRenderDirectories()
* @var array $_renderPaths
*/
private static $_renderPaths = array();

/**
* Creates a modTemplateVar instance, and sets the token of the class to *
*
Expand Down Expand Up @@ -488,14 +495,21 @@ public function registerRenderMethod($type,$method,$className) {
* @return array The found render directories
*/
public function getRenderDirectories($event,$subdir) {
$renderPath = $this->xpdo->getOption('processors_path').'element/tv/renders/'.$this->xpdo->context->get('key').'/'.$subdir.'/';
$context = $this->xpdo->context->get('key');
$renderPath = $this->xpdo->getOption('processors_path').'element/tv/renders/'.$context.'/'.$subdir.'/';
$renderDirectories = array(
$renderPath,
$this->xpdo->getOption('processors_path').'element/tv/renders/'.($subdir == 'input' ? 'mgr' : 'web').'/'.$subdir.'/',
);
$pluginResult = $this->xpdo->invokeEvent($event,array(
'context' => $this->xpdo->context->get('key'),
'context' => $context,
));
$pathsKey = serialize($pluginResult).$context.$event.$subdir;
/* return cached value if exists */
if (isset(self::$_renderPaths[$pathsKey])) {
return self::$_renderPaths[$pathsKey];
}
/* process if there is no cached value */
if (!is_array($pluginResult) && !empty($pluginResult)) { $pluginResult = array($pluginResult); }
if (!empty($pluginResult)) {
foreach ($pluginResult as $result) {
Expand All @@ -505,7 +519,6 @@ public function getRenderDirectories($event,$subdir) {
}

/* search directories */
$types = array();
$renderPaths = array();
foreach ($renderDirectories as $renderDirectory) {
if (empty($renderDirectory) || !is_dir($renderDirectory)) continue;
Expand All @@ -517,8 +530,8 @@ public function getRenderDirectories($event,$subdir) {
}
} catch (UnexpectedValueException $e) {}
}
$renderPaths = array_unique($renderPaths);
return $renderPaths;
self::$_renderPaths[$pathsKey] = array_unique($renderPaths);
return self::$_renderPaths[$pathsKey];
}

/**
Expand Down
10 changes: 6 additions & 4 deletions core/model/modx/modx.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ public static function getInstance($id = null, $config = null, $forceNew = false
if (!is_null($config) || $forceNew || empty(self::$instances)) {
$id = uniqid($class);
} else {
$id = key(self::$instances);
$instances =& self::$instances;
$id = key($instances);
}
}
if ($forceNew || !array_key_exists($id, self::$instances) || !(self::$instances[$id] instanceof $class)) {
Expand Down Expand Up @@ -1834,7 +1835,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 @@ -2099,7 +2100,7 @@ public function checkSiteStatus() {

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

/**
* Remove an extension package from MODX
*
*
* @param string $name
* @return boolean
*/
Expand Down Expand Up @@ -2239,6 +2240,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
6 changes: 5 additions & 1 deletion core/model/modx/xmlrss/rssfetch.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function fetch_rss ($url) {

$resp = _fetch_remote_file( $url, $request_headers );

if (isset($resp) and $resp) {
if ($resp) {
if ($resp->status == '304' ) {
// we have the most current copy
if ( MAGPIE_DEBUG > 1) {
Expand All @@ -187,6 +187,10 @@ function fetch_rss ($url) {
if ( $resp->status == '-100' ) {
$errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)";
}
elseif ( $resp->status == '0' ) {
// you sir, are offline
return false;
}
elseif ( $resp->error ) {
# compensate for Snoopy's annoying habbit to tacking
# on '\n'
Expand Down
12 changes: 7 additions & 5 deletions manager/controllers/default/dashboard/widget.modx-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ public function render() {
$newsEnabled = $this->modx->getOption('feed_modx_news_enabled',null,true);
if (!empty($url) && !empty($newsEnabled)) {
$rss = $this->rss->parse($url);
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
if (is_object($rss)) {
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
}
}
}
return implode("\n",$o);
}
}
return 'modDashboardWidgetNewsFeed';
return 'modDashboardWidgetNewsFeed';
12 changes: 7 additions & 5 deletions manager/controllers/default/dashboard/widget.modx-security.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public function render() {
$newsEnabled = $this->modx->getOption('feed_modx_security_enabled',null,true);
if (!empty($url) && !empty($newsEnabled)) {
$rss = $this->rss->parse($url);
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
if (is_object($rss)) {
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
}
}
}
return implode("\n",$o);
}
}
return 'modDashboardWidgetSecurityFeed';
return 'modDashboardWidgetSecurityFeed';

0 comments on commit 84f3012

Please sign in to comment.