elfinder breaks the Commerce Distribution ( 7.24 - drupal core 7.27)

From @trongnguyentcec

When I enable elfinder module elfinder-7.08 (with elfinder library 1.2) OR elfinder-7.2x-dev (with elfinder library 2.1), my site is broken with json data when I cleare all cache or access "admin/modules". I found that elfinder alway print " echo json_encode($this->_result); in function run() { } of elFinder.class.php " when $mode = 'default' .

/**
* File browser to filesystem php connector callback for elfinder 7.2x-dev
*/
function elfinder_connector($mode = NULL) {
if (is_null($mode) && !isset($_GET['cmd'])) {
return;
}
global $base_root, $user;

like this:

/**
 * File browser to filesystem php connector callback
 */
function elfinder_connector($mode = NULL) {
    if (is_null($mode) && !isset($_GET['cmd'])) {
        return;
    }
    global $base_root, $user;
    
    /**
     * Emulate json_encode required by filesystem connector for old php without JSON support
     */
    if (!function_exists('json_encode')) {
.............................

All changes are in attached file. elfinder 7.08 My code patch also works on elfinder 7.2x-dev

elfinder-7.2x-dev.zip elfinder_2.zip

Edited by 667bdrm