Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.46k stars 2.79k forks source link

Extra files do not attach V13.0.1 #16420

Closed conformist66 closed 3 years ago

conformist66 commented 3 years ago

Bug

[When attaching extra files when sending invoices, the files do not actually attach despite the dialogue saying success]

Environment

Expected and actual behavior

[Expect additional files to attach to email but they do not attach/send despite saying they do]

Steps to reproduce the behavior

[from the send invoice (email) dialogue, ask to open and attach a file. The file requested does not attach despite saying success., This issue was not present in V13.0.0]

cfoellmann commented 3 years ago

I just tested this and can not confirm that the current code has a bug (for me) at this point

ToniTen commented 3 years ago

I updated to 13.0.1 yesterday, from 12.0.4, and also experience this issue. Same exact behaviour.

daraelmin commented 3 years ago

Dont know if it is related but we can not attach anymore file (the field is missing) in tool "emailing".

EDIT: It is still possible, but not in the création tab, only in the edition tab (create a new emailing, then modify, the attach)

anton10ruiz commented 3 years ago

Also experience this issue. Same exact behaviour.

xbloq commented 3 years ago

Same problem. V13.0.1

2021-02-25 10:16:38 DEBUG 192.168.5.100 dol_add_file_process upload_dir=/var/lib/dolibarr/documents/users/3/temp allowoverwrite=1 donotupdatesession=0 savingdocmask= 2021-02-25 10:16:38 INFO 192.168.5.100 functions.lib::dol_mkdir: dir=/var/lib/dolibarr/documents/users/3/temp 2021-02-25 10:16:38 DEBUG 192.168.5.100 functions.lib::dol_mkdir: Directory '/var/lib/dolibarr/documents/users/3/temp' does not exists or is outside open_basedir PHP setting. 2021-02-25 10:16:38 DEBUG 192.168.5.100 functions.lib::dol_mkdir: Directory '/var/lib/dolibarr/documents/users/3/temp' created 2021-02-25 10:16:38 DEBUG 192.168.5.100 Files.lib::dol_move_uploaded_file Success to move /tmp/phpyS5qlx to /var/lib/dolibarr/documents/users/3/temp/file_check.pdf - Umask=0664 ........ 2021-02-25 10:16:38 DEBUG 192.168.5.100 functions.lib:dol_delete_dir_recursive /var/lib/dolibarr/documents/users/3/temp/ 2021-02-25 10:16:38 INFO 192.168.5.100 dol_delete_file file=/var/lib/dolibarr/documents/users/3/temp//file_check.pdf disableglob=1 nophperrors=0 nohook=0 2021-02-25 10:16:38 DEBUG 192.168.5.100 Removed file /var/lib/dolibarr/documents/users/3/temp//file_check.pdf

cfoellmann commented 3 years ago

@xbloq as you can see in your debug log (good idea to look there) the webserver can not create the directory. is outside open_basedir PHP setting You need to add the folder /var/lib/dolibarr/documents/ to your open_basedir config. This is php config for the "website" on your webserver.

xbloq commented 3 years ago

@xbloq as you can see in your debug log (good idea to look there) the webserver can not create the directory. is outside open_basedir PHP setting You need to add the folder /var/lib/dolibarr/documents/ to your open_basedir config. This is php config for the "website" on your webserver.

Yes I know https://wiki.dolibarr.org/index.php/Troubleshooting

Dolibarr worked always whit same configuration in another versions .

Always same configuration in php open_basedir no value no value

I checked with another configurations and same problem, I probably didn't do ok. Really dolibarr upload the file and said it's OK but the file it's deleted

Are you sure it's my config problem?

manu-p commented 3 years ago

Same problem, v13.0.1. A regression from previous version.

Just followed the instructions found in the troubleshooting section of the wiki as mentioned above. No change with upload_tmp_dir and sys_temp_dir set to "/tmp". Blank page when I set open_basedir = {WEBSPACEROOT}{/}{:}{TMP}{/}:/var/tmp

matDOTviguier commented 3 years ago

Sorry for my #16436

matDOTviguier commented 3 years ago

File is deleted just in seconds !

2021-02-25 16:19:34 DEBUG 92.131.160.199 functions.lib:dol_delete_dir_recursive /var/www/html/erp.fr/documents/users/1/temp/

2021-02-25 16:19:34 INFO 92.131.160.199 dol_delete_file file=/var/www/html/erp.fr/documents/users/1/temp//PR2102-0212.pdf disableglob=1 nophperrors=0 nohook=0

2021-02-25 16:19:34 DEBUG 92.131.160.199 Removed file /var/www/html/erp.fr/documents/users/1/temp//PR2102-0212.pdf

matDOTviguier commented 3 years ago

2021-02-25 16:19:34 DEBUG 92.131.160.199 functions.lib::dol_mkdir: Directory '/var/www/html/erp.fr/documents/users/1/temp' does not exists or is outside open_basedir PHP setting.

2021-02-25 16:19:34 DEBUG 92.131.160.199 functions.lib::dol_mkdir: Directory '/var/www/html/erp.fr/documents/users/1/temp' created

@xbloq no problem with that, I think, while the file is created well, here too.

xbloq commented 3 years ago

Sorry, I don't know anything about php But if I change htdocs/core/class/html.formmail.class.php diff lines from V13.0.0 to V13.0.1 work again I don'k know if this change have another problems

xbloq commented 3 years ago

Sorry, I don't know anything about php But if I change htdocs/core/class/html.formmail.class.php diff lines from V13.0.0 to V13.0.1 work again I don'k know if this change have another problems

'modelmailselected', $modelmail_array, $model_mail_selected_id, 1, 0, 0, by 'modelmailselected', $modelmail_array, 0, 1, 0, 0, '

daraelmin commented 3 years ago

Thanks to you @xbloq for pointing the problem in formmail.class

I've made a PR (#16448) to solve this part, but I'm not sure that all the bug referenced here are linked to this issue.

matDOTviguier commented 3 years ago

V13.0.1 patched with #16448. Still no joint file in Ticket Message (via mail). Idem on customer Mail.

[EDIT] The fix force and replace by 0 the value of $model_mail_selected_id if $arraydefaultmessage is not defined. @daraelmin, if you add : $model_mail_selected_id = 0; just after the patch #16448, it works. So, what was the value of $arraydefaultmessage I don't know. [/EDIT]

manu-p commented 3 years ago

Congrats @xbloq you rock!

At line 464 in core/class/html.formmail.class.php replace:

And it works, new attachments are allowed. Back to normal behavior. Thanks!

anton10ruiz commented 3 years ago

Congrats @xbloq you rock!

At line 464 in core/class/html.formmail.class.php replace:

  • $model_mail_selected_id with:
  • 0

And it works, new attachments are allowed. Back to normal behavior. Thanks!

It works! I don't know if it can affect another part because I don't know PHP but at the moment it seems that everything is fine

daraelmin commented 3 years ago

It works for me so

Can someone add

var_dump($model_mail_model_id);exit;

On line 465 (without applying the workaround proposed by @matDOTviguier or @manu-p)

And paste the result here

Thanks in advance

anton10ruiz commented 3 years ago

It works for me so

Can someone add

var_dump($model_mail_model_id);exit;

On line 465 (without applying the workaround proposed by @matDOTviguier or @manu-p)

And paste the result here

Thanks in advance

The result that appears is: send email "NULL "

The ability to send email disappears

anton10ruiz commented 3 years ago

Congrats @xbloq you rock!

At line 464 in core/class/html.formmail.class.php replace:

  • $model_mail_selected_id with:
  • 0

And it works, new attachments are allowed. Back to normal behavior. Thanks!

Woof! The problem gets worse Allows you to attach a file to the email Does not allow to select email template

matDOTviguier commented 3 years ago

@anton10ruiz it is a work in progress solution. But, here on 13.0.1 the email template choosen is applied well. illogic if you follow the variable naming convention, but works.

anton10ruiz commented 3 years ago

@anton10ruiz it is a work in progress solution. But, here on 13.0.1 the email template choosen is applied well. illogic if you follow the variable naming convention, but works.

Also v13.0.1 I have multiple quote email templates and it won't allow me to open the dropdown selection to choose available templates

matDOTviguier commented 3 years ago

I trust you. It is logic, when whe force 0. But ... Sans titre I cannot explain. apache2 restarted. Still working.

matDOTviguier commented 3 years ago

@daraelmin Same behavior ... NULL. Capture

matDOTviguier commented 3 years ago

var_dump($arraydefaultmessage->id); === string(2) "28" var_dump($modelmailmodel_id); === NULL

still null with (num)$arraydefaultmessage->id === 28 then NULL

but var_dump($modelmailselected_id); === $arraydefaultmessage->id === 28 whit the model #.28

when $model_mail_selected_id !=0, no file is joint at all.

daraelmin commented 3 years ago

@conformist66 Please reopen this bug. It seems that the fix I proposed doesn't solve the issue completely

daraelmin commented 3 years ago

@conformist66 Please reopen this bug. It seems that the fix I proposed doesn't solve the issue completely

Let it closed, eldy has fixed the fix here : https://github.com/Dolibarr/dolibarr/pull/16448/commits/e0785ac5ef316cf737c6d5d7fcf200059646d52c

matDOTviguier commented 3 years ago

I upvote reopenning because is not the right fix for me 13.0.1

xbloq commented 3 years ago

I upvote reopenning because is not the right fix for me 13.0.1

it don't work for me too

daraelmin commented 3 years ago

var_dump($arraydefaultmessage->id); === string(2) "28" var_dump($modelmailmodel_id); === NULL

still null with (num)$arraydefaultmessage->id === 28 then NULL

but var_dump($modelmailselected_id); === $arraydefaultmessage->id === 28 whit the model #.28

when $model_mail_selected_id !=0, no file is joint at all.

Where did you find ($model_mail_**model**_id ? I can not find it in html.formmail.class.php.

daraelmin commented 3 years ago

@matDOTviguier What does the var_dump('$model_mail_selected_id') return

If you try with this

$model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'alpha') : ($arraydefaultmessage->id > 0 ? $arraydefaultmessage->id : 0);

at line 491

matDOTviguier commented 3 years ago

You asked for : Can someone add var_dump($model_mail_model_id);exit;

matDOTviguier commented 3 years ago

It's my line 458 ! So it's probably a bigger problem !

daraelmin commented 3 years ago

You asked for : Can someone add var_dump($model_mail_model_id);exit;

My fault sorry.

daraelmin commented 3 years ago

@matDOTviguier

Could you try this one:

$model_mail_selected_id = (GETPOSTISSET('modelmailselected') && GETPOST('modelmailselected', 'int') ) ? GETPOST('modelmailselected', 'int') : ($arraydefaultmessage->id > 0 ? $arraydefaultmessage->id : 0);

I wonder if the issue is not cause by a false return getpost.

If 'modelmailselected' parameter is set BUT not numeric.

In this case the getposisset return true but $model_mail_selected_id may be set to NULL

daraelmin commented 3 years ago

@matDOTviguier I think I've found the problem on line 370.

When mailmodelselected is set by form, the script was calling clear_attached_files().

Hope I'm right this time, but let me know

xbloq commented 3 years ago

working for me now

daraelmin commented 3 years ago

working for me now

Phew ! I was starting to run out of ideas...

Thx for your response

xbloq commented 3 years ago

working for me now

Phew ! I was starting to run out of ideas...

Thx for your response

Thanks a lot

xbloq commented 3 years ago

sorry, when i upload my file a strange another more file it's attached (without name) and I can't deleted this one, only it's deleted if I delete my file. I'm not sure it's my problem, better wait another coment

matDOTviguier commented 3 years ago

That doesn't work for me. First line found clear_attached_files() is in line 355. strange offset with @daraelmin I'm staying on my illogic fix forcing 0.

daraelmin commented 3 years ago

That doesn't work for me. First line found clear_attached_files() is in line 355. strange offset with @daraelmin I'm staying on my illogic fix forcing 0.

Wich version of dolibarr do you use ? I'm on the develop branch

matDOTviguier commented 3 years ago

13.0.1

matDOTviguier commented 3 years ago

problem occred when upgrading from 13.0 to 13.0.1. The only fix that works well is to set $model_mail_selected_id = 0; just after it declaration. And, yes, it is an int >0, but it blocks. When it is set to 0, it works, displaying the good model.

daraelmin commented 3 years ago

sorry, when i upload my file a strange another more file it's attached (without name) and I can't deleted this one, only it's deleted if I delete my file. I'm not sure it's my problem, better wait another coment

I'll check what's going on here, it may be a tmp upload file.

xbloq commented 3 years ago

13.0.1 with this change

// If list of template is filled // Clear temp files. Must be done at beginning, before call of triggers if (GETPOST('mode', 'alpha') == 'init' && (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {
................. $out .= '

'."\n";

            $out .= '<span class="opacitymedium">'.$langs->trans('SelectMailModel').':</span> ';
            $out .= $this->selectarray('modelmailselected', $modelmail_array, $model_mail_selected_id, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1, '', 0, 1);
xbloq commented 3 years ago

sorry, when i upload my file a strange another more file it's attached (without name) and I can't deleted this one, only it's deleted if I delete my file. I'm not sure it's my problem, better wait another coment

I'll check what's going on here, it may be a tmp upload file.

restart apache, clean browser, same result

xbloq commented 3 years ago

I only received the correct file by mail but after sending the mail the two files remain when opening a new mail delivery

xbloq commented 3 years ago

I was with text plain in my mail. The another file it's a html embebedI t's a page from OMS that I visited months ago .I think this is my problem bit if I open with another browser same result, Checkig if it's always same page

daraelmin commented 3 years ago

I was with text plain in my mail. The another file it's a html embebedI t's a page from OMS that I visited months ago .I think this is my problem bit if I open with another browser same result, Checkig if it's always same page

I'm sorry. I can't reproduce, but I'm not sure that I have understand the situation.