Skip to content

Commit

Permalink
Caching result of call to EE_URI when parsing @uri pointer in context…
Browse files Browse the repository at this point in the history
… parameter, to avoid redundant object instantiation. Fixes #140
  • Loading branch information
croxton committed Jan 25, 2016
1 parent 5fb63cc commit 1ec3e29
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions system/expressionengine/third_party/stash/mod.stash.php
Original file line number Diff line number Diff line change
Expand Up @@ -4086,16 +4086,25 @@ private function _parse_context($name, $disable_query_str = FALSE)
}

// fetch the *unadulterated* URI of the current page
$ee_uri = new EE_URI;
if ( isset(self::$_cache['uri']))
{
$uri = self::$_cache['uri']; // retrieve from cache if we've done this before
}
else
{
$ee_uri = new EE_URI;

// documented as a 'private' method, but not actually. Called in CI_Router so unlikely to ever be made private.
$ee_uri->_fetch_uri_string();
$ee_uri->_remove_url_suffix();
$ee_uri->_explode_segments();

// documented as a 'private' method, but not actually. Called in CI_Router so unlikely to ever be made private.
$ee_uri->_fetch_uri_string();
$ee_uri->_remove_url_suffix();
$ee_uri->_explode_segments();
// provide a fallback value for index pages
$uri = $ee_uri->uri_string();
$uri = empty($uri) ? $this->EE->stash_model->get_index_key() : $uri;

// provide a fallback value for index pages
$uri = $ee_uri->uri_string();
$uri = empty($uri) ? $this->EE->stash_model->get_index_key() : $uri;
self::$_cache['uri'] = $uri; // cache the value
}

// append query string?
if ($this->include_query_str
Expand Down

0 comments on commit 1ec3e29

Please sign in to comment.