View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
07013Bug reportsOtherpublic2012-12-11 14:48
Reporterrkabalin Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version2.00+ 
Fixed in Version2.00+ 
Summary07013: kcfinder: image upload problem if survey has not been created yet.
Description

Basically, if you choose to create a new survey and attempt to upload the image before "saving" it, you will get:

mkdir(): Permission denied in /var/www/limesurvey/third_party/kcfinder/core/uploader.php on line 267

the more detailed look reveled that it actually attempt to save the file in:

/var/www/limesurvey/third_party/kcfinder/upload/images

If I save survey first and then start adding images to text blocks, it works fine, all files are saved where they should be (in upload/surveys/.../)

Steps To Reproduce
  1. Click on create new survey
  2. Try to insert the image to any text areas using editor image button, upload tab.
  3. Observe the error
TagsNo tags attached.
Bug heat4
Complete LimeSurvey version number (& build)121117
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMySQL
Server OS (if known)Debian Linux
Webserver software & version (if known)Apache, 2.2.16-6+squeeze6
PHP Version5.3.3-7+squeeze8

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2012-12-05 15:12

administrator   ~22912

Last edited: 2012-12-05 15:21

If I try to upload images here on survey creation I get the message that I don't have permission to do this (which is the intended behaviour)

Please update to the latest version and check again.

rkabalin

rkabalin

2012-12-05 15:31

reporter   ~22915

Last edited: 2012-12-05 15:32

Intended behaviour? So user should guess that he should save the survey first before he will be able to insert image in the text block? Or more advanced user will start checking permissions of /upload, find that they are correct and will stay puzzled why he can't upload while directory permissions are correct... Will test on latest stable tonight anyway, but doubt it is fixed. The issue is around for a while, I am sure these guys encountered the same case - uploading before saving new survey:
http://www.limesurvey.org/en/forum/installation-a-update-issues/75677-image-upload-apache-cannot-write-to-upload-folder-even-when-permissions-are-ok

http://www.limesurvey.org/en/forum/installation-a-update-issues/65062-problem-with-image-upload-ckfinder

c_schmitz

c_schmitz

2012-12-05 19:27

administrator   ~22919

rkabalin: Please try to understand what I wrote before you start ranting. I wrote, that normally you should get a message 'you don't have permission to do this' when trying to upload a file. (and which is currently the expected behaviour) I am completely aware that the message is not optimal.

Still, according to your bug report you get a PHP error, which is quite a difference.
I am asking you kindly to update to the latest version, clear your browser cache and see if you still have this error. Can you do this, please? Thank you.

rkabalin

rkabalin

2012-12-05 20:47

reporter   ~22922

c_schmitz: sorry, my mistake, was not that clear in the original description. The message obviously pops-up, it says "Cannot create images folder". The PHP error I mentioned is from apache error log.

Updated to latest master (a40d6b1f), the problem with upload persists.

c_schmitz

c_schmitz

2012-12-05 21:04

administrator   ~22924

That's really strange because I cannot reproduce it. What browser are you using?

rkabalin

rkabalin

2012-12-05 21:28

reporter   ~22925

latest Chrome on windows. Also I have debug setting set to 2, that might be why the mkdir is reporting error to log. Quick modification makes it show where it actually tries to write:

--- a/third_party/kcfinder/core/uploader.php
+++ b/third_party/kcfinder/core/uploader.php
@@ -265,7 +265,7 @@ class uploader {
// CHECK & CREATE UPLOAD FOLDER
if (!is_dir($this->typeDir)) {
if (!mkdir($this->typeDir, $this->config['dirPerms']))

  • $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->type));
  • $this->backMsg("Cannot create {dir} folder.", array('dir' => $this->typeDir));
    } elseif (!is_readable($this->typeDir))
    $this->backMsg("Cannot read upload folder.");
    }

and the JS error pop-up becomes " Cannot create /var/www/limesurvey/third_party/kcfinder/upload/images folder"

c_schmitz

c_schmitz

2012-12-05 22:01

administrator   ~22928

Can you dump the contents of $_SESSION['KCFINDER'] please?

rkabalin

rkabalin

2012-12-05 22:10

reporter   ~22929

yep, sure.

At the point when there is an error:

array(2) {
["types"]=>
array(3) {
["files"]=>
string(223) "7z aiff asf avi bmp csv doc fla flv gif gz gzip ico jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip pstpl css js"
["flash"]=>
string(223) "7z aiff asf avi bmp csv doc fla flv gif gz gzip ico jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip pstpl css js"
["images"]=>
string(223) "7z aiff asf avi bmp csv doc fla flv gif gz gzip ico jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip pstpl css js"
}
["self"]=>
&array(0) {
}
}

after the survey has been saved (when there is no error):

array(5) {
["types"]=>
array(3) {
["files"]=>
string(223) "7z aiff asf avi bmp csv doc fla flv gif gz gzip ico jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip pstpl css js"
["flash"]=>
string(223) "7z aiff asf avi bmp csv doc fla flv gif gz gzip ico jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip pstpl css js"
["images"]=>
string(223) "7z aiff asf avi bmp csv doc fla flv gif gz gzip ico jpeg jpg mid mov mp3 mp4 mpc mpeg mpg ods odt pdf png ppt pxd qt ram rar rm rmi rmvb rtf sdc sitd swf sxc sxw tar tgz tif tiff txt vsd wav wma wmv xls xml zip pstpl css js"
}
["disabled"]=>
bool(false)
["uploadURL"]=>
string(34) "/limesurvey/upload/surveys/178169/"
["uploadDir"]=>
string(42) "/var/www/limesurvey/upload/surveys/178169/"
["self"]=>
&array(0) {
}
}

c_schmitz

c_schmitz

2012-12-05 23:17

administrator   ~22932

Last edited: 2012-12-05 23:19

Open application/helper/htmleditor_helper.php

and after line

 Yii::app()->session['KCFINDER'] = array();

insert this line
$_SESSION['KCFINDER']['disabled'] = true;

save, then try again and see if anything changed.

rkabalin

rkabalin

2012-12-05 23:40

reporter   ~22936

With a fix above it works fine now. Thanks a lot!

The potential problem that may araise from here - what will happen if user uploaded the image, but changed his mind and decided not to save survey. What will happen with the file, will it be deleted from /upload directory at some point?

c_schmitz

c_schmitz

2012-12-06 00:26

administrator   ~22941

Last edited: 2012-12-06 00:26

Wait, with that fix applied you should get now the message 'You don't have permission to do this'.
You should not be able to upload files during survey creation. Can you check again please?

rkabalin

rkabalin

2012-12-06 00:50

reporter   ~22943

please ignore the previous post, it was a red herring )) I must have created survey when posted the session dump, then deleted it, and then created a new one, which allowed me to save since the directory with the same id for some reason remained there (potentially a different bug).

No, the $_SESSION['KCFINDER']['disabled'] = true; fix does not do anything for the new survey. I still get the same "Cannot create images folder" message.

c_schmitz

c_schmitz

2012-12-06 11:18

administrator   ~22975

Is there a way I can get access to that system?
I would need FTP/SSH access and a login to the limesurvey administration.

If yes, please send it (email address removed)

rkabalin

rkabalin

2012-12-06 11:30

reporter   ~22976

Last edited: 2012-12-06 11:33

no, sorry, it is my local dev environment. The bug is on the latest master and there is nothing specific about the system, just a minimal apache/php/mysql with no weird settings, or unusual modules. I can's see why you are not able to replicate it.

c_schmitz

c_schmitz

2012-12-06 11:41

administrator   ~22977

I am sorry but I can fix only something that I can reproduce.
For example you can see the correct behaviour in our online demo.

I am sorry but since I cannot reproduce I will need to close the issue. If you find a fix or have new hints regarding the issue feel free to re-open it.

rkabalin

rkabalin

2012-12-06 12:06

reporter   ~22978

The thing is that we focused on the error message issue here, rather than responding to the original problem defined in the subject. That might be a part of the problem since I reported that php error, but more like a separate bug rather than the original issue. Even with correct message the bug is still there. The message "You don\'t have permissions to upload files" is clearly misleading. If there is no way to upload image before storing survey, it should explicitly say so. Since the discussion of this one was focused on the message content, I suggest to rename it to "incorrect message on file upload attempt at the newly created survey" and fill in another report claiming that "You don't have permissions to upload files" message is misleading as there is nothing wrong with permissions really.

c_schmitz

c_schmitz

2012-12-09 19:48

administrator   ~23053

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=10807

c_schmitz

c_schmitz

2012-12-09 20:20

administrator   ~23064

Fix committed to 2.1 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=10822

rkabalin

rkabalin

2012-12-09 20:54

reporter   ~23065

Thanks, c_schmitz. There is a typo I commented on in github.

c_schmitz

c_schmitz

2012-12-09 22:10

administrator   ~23066

Fix committed to 2.1 branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=10823

c_schmitz

c_schmitz

2012-12-09 22:11

administrator   ~23067

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=10824

c_schmitz

c_schmitz

2012-12-11 14:48

administrator   ~23129

2.00 Build 121211 released

Related Changesets

LimeSurvey: master f990a8f1

2012-12-09 19:48

c_schmitz


Details Diff
Fixed issue 07013: Misleading error message on file upload if survey has not been saved yet Affected Issues
07013
mod - application/controllers/admin/surveyadmin.php Diff File
mod - application/helpers/admin/htmleditor_helper.php Diff File
add - application/views/admin/survey/newSurveyBrowserMessage.php Diff File

LimeSurvey: 2.1 bc7aeae1

2012-12-09 19:48

c_schmitz


Details Diff
Fixed issue 07013: Misleading error message on file upload if survey has not been saved yet Affected Issues
07013
mod - application/controllers/admin/surveyadmin.php Diff File
mod - application/helpers/admin/htmleditor_helper.php Diff File
add - application/views/admin/survey/newSurveyBrowserMessage.php Diff File

LimeSurvey: 2.1 a2fe9eeb

2012-12-09 22:09

c_schmitz


Details Diff
Fixed issue 07013: Misleading error message on file upload if survey has not been saved yet
Dev Typo
Affected Issues
07013
mod - application/views/admin/survey/newSurveyBrowserMessage.php Diff File

LimeSurvey: master fd85b464

2012-12-09 22:09

c_schmitz


Details Diff
Fixed issue 07013: Misleading error message on file upload if survey has not been saved yet
Dev Typo
Affected Issues
07013
mod - application/views/admin/survey/newSurveyBrowserMessage.php Diff File

Issue History

Date Modified Username Field Change
2012-12-04 23:21 rkabalin New Issue
2012-12-05 10:41 c_schmitz Assigned To => c_schmitz
2012-12-05 10:41 c_schmitz Status new => assigned
2012-12-05 15:12 c_schmitz Note Added: 22912
2012-12-05 15:12 c_schmitz Status assigned => feedback
2012-12-05 15:21 c_schmitz Note Edited: 22912
2012-12-05 15:31 rkabalin Note Added: 22915
2012-12-05 15:31 rkabalin Status feedback => assigned
2012-12-05 15:32 rkabalin Note Edited: 22915
2012-12-05 19:27 c_schmitz Note Added: 22919
2012-12-05 19:27 c_schmitz Status assigned => feedback
2012-12-05 20:47 rkabalin Note Added: 22922
2012-12-05 20:47 rkabalin Status feedback => assigned
2012-12-05 21:04 c_schmitz Note Added: 22924
2012-12-05 21:28 rkabalin Note Added: 22925
2012-12-05 22:01 c_schmitz Note Added: 22928
2012-12-05 22:10 rkabalin Note Added: 22929
2012-12-05 23:17 c_schmitz Note Added: 22932
2012-12-05 23:19 c_schmitz Note Edited: 22932
2012-12-05 23:32 c_schmitz Status assigned => feedback
2012-12-05 23:40 rkabalin Note Added: 22936
2012-12-05 23:40 rkabalin Status feedback => assigned
2012-12-06 00:26 c_schmitz Note Added: 22941
2012-12-06 00:26 c_schmitz Note Edited: 22941
2012-12-06 00:26 c_schmitz Status assigned => feedback
2012-12-06 00:50 rkabalin Note Added: 22943
2012-12-06 00:50 rkabalin Status feedback => assigned
2012-12-06 11:18 c_schmitz Note Added: 22975
2012-12-06 11:19 c_schmitz Status assigned => feedback
2012-12-06 11:30 rkabalin Note Added: 22976
2012-12-06 11:30 rkabalin Status feedback => assigned
2012-12-06 11:33 rkabalin Note Edited: 22976
2012-12-06 11:41 c_schmitz Note Added: 22977
2012-12-06 11:41 c_schmitz Status assigned => closed
2012-12-06 11:41 c_schmitz Resolution open => unable to reproduce
2012-12-06 12:06 rkabalin Note Added: 22978
2012-12-06 12:06 rkabalin Status closed => feedback
2012-12-06 12:06 rkabalin Resolution unable to reproduce => reopened
2012-12-09 19:48 c_schmitz Changeset attached => LimeSurvey master f990a8f1
2012-12-09 19:48 c_schmitz Note Added: 23053
2012-12-09 19:49 c_schmitz Status feedback => resolved
2012-12-09 19:49 c_schmitz Fixed in Version => 2.00+
2012-12-09 19:49 c_schmitz Resolution reopened => fixed
2012-12-09 20:20 c_schmitz Changeset attached => LimeSurvey 2.1 bc7aeae1
2012-12-09 20:20 c_schmitz Note Added: 23064
2012-12-09 20:54 rkabalin Note Added: 23065
2012-12-09 22:10 c_schmitz Changeset attached => LimeSurvey 2.1 a2fe9eeb
2012-12-09 22:10 c_schmitz Note Added: 23066
2012-12-09 22:11 c_schmitz Changeset attached => LimeSurvey master fd85b464
2012-12-09 22:11 c_schmitz Note Added: 23067
2012-12-11 14:48 c_schmitz Note Added: 23129
2012-12-11 14:48 c_schmitz Status resolved => closed