Skip to content

Commit

Permalink
fix to elFinder regarding 'sessions'
Browse files Browse the repository at this point in the history
  • Loading branch information
dleffler committed Dec 12, 2016
1 parent 9df16e8 commit 04c994f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
23 changes: 15 additions & 8 deletions external/elFinder/js/elFinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -6509,7 +6509,7 @@ elFinder.prototype = {
*
* @param Array urls to load JavaScript file URLs
* @param Function callback call back function on script loaded
* @param Object opts Additional options to $.ajax
* @param Object opts Additional options to $.ajax OR {loadType: 'tag'} to load by script tag
* @param Object check { obj: (Object)ParentObject, name: (String)"Attribute name", timeout: (Integer)milliseconds }
* @return elFinder
*/
Expand Down Expand Up @@ -6538,13 +6538,20 @@ elFinder.prototype = {
}
}
}
opts = $.isPlainObject(opts)? $.extend(defOpts, opts) : defOpts;
(function appendScript() {
$.ajax($.extend(opts, {
url: urls.shift(),
success: urls.length? appendScript : success
}));
})();
if (opts && opts.loadType === 'tag') {
$.each(urls, function(i, url) {
$('head').append($('<script defer="defer">').attr('src', url));
});
success();
} else {
opts = $.isPlainObject(opts)? $.extend(defOpts, opts) : defOpts;
(function appendScript() {
$.ajax($.extend(opts, {
url: urls.shift(),
success: urls.length? appendScript : success
}));
})();
}
return this;
},

Expand Down
2 changes: 1 addition & 1 deletion external/elFinder/php/elFinder.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ public function exec($cmd, $args) {
}

foreach ($this->volumes as $volume) {
$volume->saveSessionCache();
$volume->umount();
$volume->__destruct();
}

if (!empty($result['callback'])) {
Expand Down
9 changes: 8 additions & 1 deletion external/elFinder/php/elFinderSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class elFinderSession implements elFinderSessionInterface

protected $keys = array();

protected $prevVal = null;

protected $base64encode = false;

protected $opts = array(
Expand Down Expand Up @@ -49,6 +51,10 @@ public function start()
}
$this->started = session_id()? true : false;

if ($this->started && is_null($this->prevVal)) {
$this->prevVal = $_SESSION;
}

return $this;
}

Expand All @@ -57,8 +63,9 @@ public function start()
*/
public function close()
{
if ($this->started) {
if ($this->started && $this->prevVal !== $_SESSION) {
session_write_close();
$this->prevVal = $_SESSION;
}
$this->started = false;

Expand Down
17 changes: 10 additions & 7 deletions external/elFinder/php/elFinderVolumeDriver.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,6 @@ abstract class elFinderVolumeDriver {
*/
protected $rootModified = false;

/**
* Destracter
*/
public function __destruct() {
$this->session->set($this->id, $this->sessionCache);
}

/*********************************************************************/
/* INITIALIZATION */
/*********************************************************************/
Expand Down Expand Up @@ -831,6 +824,16 @@ public function setSession($session) {
$this->session = $session;
}

/**
* Save session cache data
* Calls this function before umount this volume on elFinder::exec()
*
* @return void
*/
public function saveSessionCache() {
$this->session->set($this->id, $this->sessionCache);
}

/**
* Return debug info for client
*
Expand Down

0 comments on commit 04c994f

Please sign in to comment.