Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra files do not attach V13.0.1 #16420

Closed
conformist66 opened this issue Feb 24, 2021 · 61 comments · Fixed by #16449
Closed

Extra files do not attach V13.0.1 #16420

conformist66 opened this issue Feb 24, 2021 · 61 comments · Fixed by #16449
Labels
Bug This is a bug (something does not work as expected)

Comments

@conformist66
Copy link

Bug

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

Environment

  • Version: [13.0.1]
  • OS: [Linux hp285.hostpapa.com 3.10.0-962.3.2.lve1.5.26.4.el7.x86_64 Develop #1 SMP Wed Sep 11 10:29:54 EDT 2019 x86_64]
  • Web server: [Apache]
  • PHP: [7.2.34]
  • Database: [MySQL or MariaDB 5.7.33]
  • URL(s): [/compta/facture/card.php?facid=282&action=presend&mode=init#formmailbeforetitle]

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]

@conformist66 conformist66 added the Bug This is a bug (something does not work as expected) label Feb 24, 2021
@cfoellmann
Copy link
Contributor

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

@ToniTen
Copy link

ToniTen commented Feb 24, 2021

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

@daraelmin
Copy link
Contributor

daraelmin commented Feb 24, 2021

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)

@ksar-ksar ksar-ksar added the Bug or PR need more information This bug or PR needs more information (answer to a question or more accurate description) label Feb 25, 2021
@anton10ruiz
Copy link

Also experience this issue. Same exact behaviour.

@xbloq
Copy link
Contributor

xbloq commented Feb 25, 2021

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
Copy link
Contributor

@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
Copy link
Contributor

xbloq commented Feb 25, 2021

@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
Copy link

manu-p commented Feb 25, 2021

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

@ksar-ksar ksar-ksar removed the Bug or PR need more information This bug or PR needs more information (answer to a question or more accurate description) label Feb 25, 2021
@matDOTviguier
Copy link

Sorry for my #16436

@matDOTviguier
Copy link

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
Copy link

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
Copy link
Contributor

xbloq commented Feb 25, 2021

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
Copy link
Contributor

xbloq commented Feb 25, 2021

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 added a commit to daraelmin/dolibarr that referenced this issue Feb 26, 2021
Set $model_mail_selected_id to 0 when it is undefined
@daraelmin
Copy link
Contributor

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.

daraelmin added a commit to daraelmin/dolibarr that referenced this issue Feb 26, 2021
Set $model_mail_selected_id to 0 when it is undefined
@matDOTviguier
Copy link

matDOTviguier commented Feb 26, 2021

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
Copy link

manu-p commented Feb 26, 2021

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!

@anton10ruiz
Copy link

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
Copy link
Contributor

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

eldy added a commit that referenced this issue Feb 26, 2021
Fix #16420 - V13.0.1 - undefined $model_mail_selected_id
@matDOTviguier
Copy link

matDOTviguier commented Feb 27, 2021

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
Copy link
Contributor

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
Copy link

13.0.1

@matDOTviguier
Copy link

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
Copy link
Contributor

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
Copy link
Contributor

xbloq commented Feb 27, 2021

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
Copy link
Contributor

xbloq commented Feb 27, 2021

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
Copy link
Contributor

xbloq commented Feb 27, 2021

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

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

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
Copy link
Contributor

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.

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

  1. Dolibarr deleted all log and temporary files
  2. Restart apache
  3. Clean browser
    4- Setup my user display to english
  4. Sent mail from my user
  5. Attach my file.check.pdf. File it's attached
  6. Send mail
  7. Received mail (All it's ok with my file enclosed)
  8. I go to sent new mail again (Two files send in first mail remain in mail form attached. They aren¡t deleted at the time that I sent mail. I can't delete file without name, If I delete my file_check.pdf two files are deleted at same time)
  9. Attach my file again. Send mail and received mail with my file OK again)
  10. Return to sent a new mail (Two files remain in mail form) ...

In my usual language settings when I upload the first time my file_check.pdf, two files are upload and then another problem. I don't know why it's different with my usual language

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

image with two files
Screenshot_20210227_102707

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

  1. I go to sent new mail again (Now two files remain in mail form attached, my file_check.pdf send with mail and another file withoutname ...

@daraelmin
Copy link
Contributor

In my usual language settings when I upload the first time my file_check.pdf, two files are upload and then another problem. I don't know why it's different with my usual language.

Hum... I don't use translation so...

Maybe the issue is linked to this. I'll check.

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

thanks and sorry for my explain

@daraelmin
Copy link
Contributor

daraelmin commented Feb 27, 2021

I just add an other commit to my PR. It seems to be related.

if (GETPOST('mode', 'alpha') == 'init' && (GETPOSTISSET('modelmailselected') && GETPOST('modelmailselected', 'alpha') != '-1')) {

if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) { foreach ($this->param['fileinit'] as $file) { $this->add_attached_files($file, basename($file), dol_mimetype($file)); } } }

instead of

if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) {

if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) { foreach ($this->param['fileinit'] as $file) { $this->add_attached_files($file, basename($file), dol_mimetype($file)); } } }

On line 420 (develop branch).

Could you try?

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

Work, only file_check.pdf upload, no more file without name, its OK-.
But mail received hasn't file ¿?.
When I return to formmail for a new mail only remain file_check.pdf no more file without name
Note: In my html.formmail.class.php V13.0.1 it's line 385

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

Ii I apply email template I received file also

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

One time I applied

Ii I apply email template I received file also

One time I applied email template work also with default template

@xbloq
Copy link
Contributor

xbloq commented Feb 27, 2021

Only one thing. The file that I sent remain if I return to sent another email. Should it be deleted automatically?

@daraelmin
Copy link
Contributor

I can not test anymore, cause I'm in the bus.

But for attached mail withoit using template, I think we should use

if (GETPOST('mode', 'alpha') == 'init' && (GETPOSTISSET('modelmailselected') && !in_array(GETPOST('modelmailselected', 'alpha'), array('','0','-1')) )){

on both line (develop: 370 & 420 or for 13.0.1: 354 & 385)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This is a bug (something does not work as expected)
Projects
None yet
9 participants