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

Caractères spéciaux champs conditionnels #1270

Closed
titidelaff opened this issue Jan 21, 2019 · 34 comments · Fixed by #1279
Closed

Caractères spéciaux champs conditionnels #1270

titidelaff opened this issue Jan 21, 2019 · 34 comments · Fixed by #1279
Labels
Milestone

Comments

@titidelaff
Copy link

Lorsque que je créer un champ conditionnel avec une apostrophe ou une parenthése, la vérification du = sur la condition ne fonctionne pas.

@btry
Copy link
Collaborator

btry commented Jan 22, 2019

Bonjour

Il n'y aura plus de version corrective pour la série 2.6.x. Il est fort possible que le problème soit résolu avec la version 2.7.0 à venir. Je vous invite à essayer la beta 3 pour voir si le problème persiste.

@titidelaff
Copy link
Author

Je suis en version beta 3 actuellement

@btry btry added the bug label Jan 22, 2019
@btry btry added this to the 2.7.0 milestone Jan 22, 2019
@btry
Copy link
Collaborator

btry commented Jan 22, 2019

Bonjour

J'ai créé un formulaire avec 2 questions de type texte, la seconde étant affichée si la première contient "test =". Avec la version de développemetn actuelle (eta 3 + quelques correctifs) je n'ai eu aucun souci.

@btry
Copy link
Collaborator

btry commented Jan 22, 2019

image

image

image

sane signe =

image

avec signe =

image

@titidelaff
Copy link
Author

Ma faute,

C'est les caractères ' et ( qui me posent problèmes.

Question de type boutons radio
image

Question de type boutons radio avec la condition
image

Résultat
image

En attendant j'enlève les apostrophes et les parenthèses et ça marche.

@titidelaff
Copy link
Author

Sans le '
image

@btry btry mentioned this issue Jan 28, 2019
2 tasks
@btry
Copy link
Collaborator

btry commented Jan 28, 2019

Hi

I found several issues when investigating. Please test the latest revision of the develop branch with the above patch and feedback

@titidelaff
Copy link
Author

It still does not work with the patch on the latest version of the develop branch.

@btry
Copy link
Collaborator

btry commented Jan 29, 2019

Indeed, I updated the PR, please try again and feeback

@titidelaff
Copy link
Author

With the last modification it works.
Thank you

@titidelaff
Copy link
Author

titidelaff commented Jan 30, 2019

I just did some tests, I think there is a problem to recover the answer and for showing entered form.
I created a destination for a ticket.
Inside I put an answer from a question with radio button and '
Once the ticket is created, the answers do not appear in my ticket.
When i want to show entered form, in debug mode I have an error in the fields.class.php file:
PHP Notice: Undefined offset: 254 in C:\glpi\plugins\formcreator\inc\fields.class.php at line 186

Fatal error: Uncaught Error: Call to a member function isPrerequisites() on null in C:\glpi\plugins\formcreator\inc\fields.class.php:201 
Stack trace: 
#0 C:\glpi\plugins\formcreator\inc\formanswer.class.php(574): PluginFormcreatorFields::isVisible('260', Array) 
#1 C:\glpi\inc\commonglpi.class.php(475): PluginFormcreatorFormAnswer->showForm('193', Array) 
#2 C:\glpi\ajax\common.tabs.php(92): CommonGLPI::displayStandardTab(Object(PluginFormcreatorFormAnswer), 'PluginFormcreat...', '', Array) 
#3 {main} thrown in C:\glpi\plugins\formcreator\inc\fields.class.php on line 201

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

Hi

This error looks like an inconsistency in your DB. Let's assume you have a form with two fields A and B

B is hidden unless A matches some expression, but A does not exists (it may be deleted after confuring B)

In such case, the code will instanciate an object representing the field A to do the comparison defined in the field B. This instanciation probably failed.

Please have a look in your database: check if this A field is in the DB. If the inconsistency is confirmed, then I need to find what did you do with this A field. Maybe a cascaded deletion is missing in the plugin (i'm checking right now)

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

Update

the cascaded deletion of the A field works as expected: deleting A will also delete the condition in the field B.

@titidelaff
Copy link
Author

I created a simple form.
image
A radio button issue called A, two choices 1 or 2
image
A question 1 and a question 2 that appears depending on the answer to A
image
No problem.
On the other hand if I do the same thing with a choice including a '
image
image
This time I get the error
I looked in the DB and the field exists

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

I'll try to reproduce with your exact description. Stay tuned

@titidelaff
Copy link
Author

Another problem with the patch.
When someone populates a question in a form with a ' I have a http 500 error.

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

tests with it's ok and it's not ok => success. I don't reproduce any bug

image

image

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

When someone populates a question in a form with a ' I have a http 500 error.

Please tell me which types or fields are impacted. Text, textarea ?

@titidelaff
Copy link
Author

text

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

The patch is updated, now you should be able to have a single quote in text and radio answers.

@titidelaff
Copy link
Author

Ok for single quote in text filed

@btry
Copy link
Collaborator

btry commented Jan 30, 2019

OK,

now the conditions issue remains to be fixed.

You have a condition in your question B. This contition has a the ID of the question A in a foreign key column. Checl that the ID of the question A matches the value in the condition.

If not, try to delete questions A and B then recreate them (with the condition).

@titidelaff
Copy link
Author

titidelaff commented Jan 31, 2019

Looks like it's working properly now.
I will still do some testing and make a feedback..
Thank you for the time spent on this problem.

@titidelaff
Copy link
Author

Hello,
When I create a destination for a ticket, if I put an single quote in the title field, the ticket does not generate on the other hand the form yes and I get a 500 error or a blank page

@btry
Copy link
Collaborator

btry commented Feb 1, 2019

Hi,

First, i will merge the PR of this issue as it seems solved.

Next, please open a new issue for your HTTP 500 error. FYI, when such error happens the HTTP server logs a backtrace. This backtrace is required : it helps to solve a lot of fatal errors very quickly.

@titidelaff
Copy link
Author

titidelaff commented Feb 1, 2019

I understand that it is easier to handle errors by making several requests but the error here is always related to the single quote.
Moreover if in a field description (textaerafield) there is a single quote the form does not record the field and I end up with tickets without description

@btry
Copy link
Collaborator

btry commented Feb 1, 2019

I understand that it is easier to handle errors by making several requests but the error here is always related to the single quote.

Yes, you're right, but 2 bugs needs to be more similar to ensure they are the same.

Moreover if in a field description (textaerafield) there is a single quote the form does not record the field and I end up with tickets without description

this one is a good example: there is again a single quote problem, but it does not impacts the conditions feature, and the place of the faulty quote is not the same.

I'll submit other fixes for these 2 problems. Stay tuned.

@btry btry closed this as completed in #1279 Feb 1, 2019
@btry btry reopened this Feb 1, 2019
@titidelaff
Copy link
Author

You'r right.
Thank you

@titidelaff
Copy link
Author

Ok, so last information with a - '- it works
With a - '- it does not work.
I did not see the difference at the beginning but by making a copy paste of the single quote we see the difference

@btry btry mentioned this issue Feb 1, 2019
2 tasks
@btry
Copy link
Collaborator

btry commented Feb 1, 2019

for the HTTP 500 error :
#1285

please test and feedback.

Moreover if in a field description (textaerafield) there is a single quote the form does not record the field and I end up with tickets without description

Are you talking about a question of type description ?
image

@titidelaff
Copy link
Author

titidelaff commented Feb 4, 2019

Yes question of type description.
In textaerafireId.php I try this:
line 80 add return Toolbox::addslashes_deep($this->value);
line 127 & 135 replace by return Toolbox::addslashes_deep($this->value);
With this no problem.

@btry
Copy link
Collaborator

btry commented Feb 4, 2019

Hi

I get a different result because it is better to not save a \' litterally in the DB. I took time to check other fields and noticed similar issues.

Please feedback with fixes #1285 and #1286 .

@btry
Copy link
Collaborator

btry commented Feb 5, 2019

Hi @titidelaff

FYI, both PR were merged to progress on other debugs.

@btry btry modified the milestones: 2.7.0, 2.7.1 Feb 12, 2019
@btry
Copy link
Collaborator

btry commented Feb 18, 2019

Hi

No feedback, then I assume the bug is solved. Feel free to open a new ticket if issue still occurs.

@btry btry closed this as completed Feb 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants