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

FIX : attached file on first page load #30694

Merged
merged 4 commits into from
Sep 1, 2024

Conversation

atm-jpb
Copy link
Contributor

@atm-jpb atm-jpb commented Aug 20, 2024

Bug Description

When creating a new ticket, if the user adds an attachment without creating the ticket, leaves the page, and then returns to the ticket creation page, the previously added attachment is still present. This behavior is undesirable as it can lead to confusion for the user and potentially result in the addition of irrelevant attachments to a new ticket.

Proposed Solution

To resolve this issue, we will check if the page is loaded for the first time by testing for the presence of a token in the $_POST. If this is the case, we will clean up the temporary attachments associated with the user's session.

@@ -738,7 +738,21 @@

if ($action == 'create' || $action == 'presend') {
$formticket = new FormTicket($db);
if (!GETPOSTISSET('token')) {
Copy link
Member

@eldy eldy Aug 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other part of code, we used a different solution:
The parameter mode=init was added on the link with action=presend
And we reset dir and session when mode=init. For eample in htdocs/admin/mails.php

		// Init list of files
		if (GETPOST("mode", "aZ09") == 'init') {
			$formmail->clear_attached_files();
		}

When mode is not init, we untouch dir

Can you try to use a similar method for better code consistency ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have taken your comment into account to use mode=init as suggested. This results in a modification of modTiket and an SQL update. Let me know if this works for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eldy eldy added the Discussion Some questions or discussions are opened and wait answers of author or other people to be processed label Aug 23, 2024
jpb and others added 2 commits August 27, 2024 11:26
@eldy eldy merged commit 1092454 into Dolibarr:19.0 Sep 1, 2024
3 of 4 checks passed
@eldy eldy added the github_note No meaning, for internal use. label Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion Some questions or discussions are opened and wait answers of author or other people to be processed github_note No meaning, for internal use.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants