Comments

cravecode’s picture

I'm not sure if I've gone about this in the right way, however, I have put together a patch for what I think fixes the issue.

I added the following to the top of the elfinder_connect() function:

  if(!isset($mode) && variable_get('elfinder_settings_filesystem_fileurl', 'true') == 'false') { //Saved as a string from the Admin.
      $mode = 'relative';
  }
Anonymous’s picture

The patch also works for 6.x-2.x-dev. Thanks.

Poieo’s picture

Status: Active » Needs review

Not sure if this is the proper fix, but it works for me.

jaroslaw.kaminski’s picture

Why this patch is not in dev tree? I always have to use it to enable relative path in wysiwyg. It's almost year this patch waiting for acceptance.

ph0enix’s picture

Title: Absolute/Relative setting not honored » [patch] Absolute/Relative setting not honored
Assigned: Unassigned » ph0enix
Issue summary: View changes
Priority: Normal » Major
joelpittet’s picture

Status: Needs review » Needs work

This patch totally does the trick. Nice work! Here's some nit picky things about the drupal coding standards that should be cleaned up. https://drupal.org/coding-standards

  1. +++ b/elfinder.module
    @@ -419,6 +419,10 @@ function elfinder_get_user_profile() {
    +  if(!isset($mode) && variable_get('elfinder_settings_filesystem_fileurl', 'true') == 'false') { //Saved as a string from the Admin.
    

    whitespace need on if statement. And Comment should be above if statement.

  2. +++ b/elfinder.module
    @@ -419,6 +419,10 @@ function elfinder_get_user_profile() {
    +  ¶
    

    Extra whitespace in patch.

joelpittet’s picture

It looks as if there was some kind of half conversion from $mode = 'relative'/'absolute' to 'true'/'false' somewhere or the opposite maybe? The coding standards whitespace are really easy to fix and I'd likely RTBC this if it wasn't for this mode confusion. But by the looks of it should likely be storing 'relative'/'absolute' and passing through 'default' and checking for 'default' before looking up the elfinder_settings_filesystem_fileur.

cravecode’s picture

@joelpittet, I don't understand your last two followups. Are you saying this patch no longer works?

joelpittet’s picture

@cravecode First comment is about coding standards for the patch. Though that whole file needs coding standards cleanup...
Second is regarding the $mode variable not totally decided on what it is suppose to store. Some places it expects 'relative' or 'absolute' strings and other places it expects 'true' or 'false' strings. Not sure the direction it is intended to to be but it should be a bit more clear on what it should be containing.

Does that help clear up my review?

The patch works great, just want to make sure the fix is what it should be and the coding standards are followed.

cravecode’s picture

Thanks, that clears it up for me. I've provided my contribution, I look forward to benefiting from yours.

joelpittet’s picture

@cravecode not sure which direction the maintainers intended to go there. It looks like an incomplete thought in code... which is how the bug likely surfaced in the first place, so we'll likely have to wait until they have a peek.

cravecode’s picture

@joelpittet, I completely agree, you were spot on when you stated that there seemed to be a mid-way switch from true/false to relative/absolute. I'm also really curious why this hasn't been merged.

cravecode’s picture

StatusFileSize
new586 bytes

I updated the patch to work with the latest state of 7.x-2.x

cravecode’s picture

Status: Needs work » Needs review
misthero’s picture

i think this doesn't work if drupal is installed in a subfolder and not in main domain like test.com/drupal/

joelpittet’s picture

@misthero What makes you say that did you try it? The patch doesn't change any path just makes the variable of value 'relative' actually pickup. For me this patch works but I'm not doing that subfolder stuff so maybe you can try it and let us know?

I'd recommend opening up a separate follow-up issue for that bug unless you can provide a patch that fixes that as well because I'd hate to prevent this patch from going in because we are waiting on a patch for a related but separate issue.

misthero’s picture

@joelpittet, sorry, you are totally right, the problem is not your patch, it works and correctly detect 'relative' or absolute settings. And that is what is meant for.

The problem with relative urls being wrong when drupal is installed in a subfolder is NOT your patch fault!!

I fixed it in my installation calling the global $base_path; and than getting the url this way:
'URL' => $mode == 'relative' ? $base_path.$pubFiles->getDirectoryPath() ......
both for public o private files.

and sorry for the late answer but I didn't got notified, my bad.

Again: patch #13 works!

joelpittet’s picture

@misthero thanks for giving it a try:) More eyes the better!

@ph0enix any chance you could weigh in on this?

delacosta456’s picture

hi.
hi after searching for almost on month, this patch is the one that finally saved me.
thanks

rimen’s picture

Patch #13 works for public, private and unmanaged files only but not for volumes

We must replace

if (is_object($streamWrapper)) {
    $volpath = $streamWrapper->realpath();
    $volurl = $streamWrapper->getExternalUrl();
    $url = isset($volume['url']) && $volume['url'] != '' ? elfinder_parse_path_tokens($volume['url']) : $streamWrapper->getExternalUrl();
}

with

        if (is_object($streamWrapper)) {
            $volpath = $streamWrapper->realpath();
            $volurl = $mode == 'relative' ? '/' . $streamWrapper->getDirectoryPath() : $streamWrapper->getExternalUrl();
            $url = isset($volume['url']) && $volume['url'] != '' ? elfinder_parse_path_tokens($volume['url']) : $volurl;
        }
rimen’s picture

Moreover each volume has own filesystem_fileurl
I think it's more correct to define relative/external mode per volume config

bwaindwain’s picture

Here's a patch that incorporates #13, #17 and #21. Thanks everyone!

bwaindwain’s picture

fixed whitespace issue (this module needs some cleanup)

nwom’s picture

Status: Needs review » Reviewed & tested by the community

#23 worked perfectly and applied cleanly. Thank you!

bwaindwain’s picture

  • bwaindwain committed 2bcf8f1 on 7.x-2.x
    Issue #1710590 by cravecode, bwaindwain, joelpittet, misthero, rimen: [...
bwaindwain’s picture

Status: Reviewed & tested by the community » Fixed
bwaindwain’s picture

Status: Fixed » Closed (fixed)