Skip to content

Editing checkout agreements throws exception #7171

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

Closed
cizgidekiadam opened this issue Oct 25, 2016 · 15 comments
Closed

Editing checkout agreements throws exception #7171

cizgidekiadam opened this issue Oct 25, 2016 · 15 comments
Labels
bug report Component: Checkout Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release

Comments

@cizgidekiadam
Copy link

Preconditions

  1. Magento 2.1.2
  2. Updated from 2.1 via composer
  3. Single Store Mode enabled

Steps to reproduce

  1. Create new checkout agreement.
  2. Try to edit

Expected result

  1. Open agreement for edit

Actual result

  1. Warning: htmlspecialchars() expects parameter 1 to be string, array given in
    /vendor/magento/framework/Data/Form/Element/AbstractElement.php on line 286
@palamar
Copy link
Contributor

palamar commented Oct 26, 2016

Internal ticket MAGETWO-60143 has been created to track this issue.

@palamar palamar added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Oct 26, 2016
@palamar palamar removed their assignment Oct 26, 2016
@mosesmalone
Copy link

Same problem here on Magento 2.1.2.
Any workaround to delete a term that's been created?
I'd like to remove it, but can't, because editing is not possible :)

@mosesmalone
Copy link

sorry, found the entry in the database.
Table "checkout_agreement".

@mosesmalone
Copy link

mosesmalone commented Dec 7, 2016

I was able to fix it by changing Line 302 in /vendor/magento/framework/Data/Form/Element/AbstractElement.php from
return $this->_escape($value);
to
if(is_string($value)) { return $this->_escape($value); }

don't know if this causes any other issues though :)

@therool
Copy link
Contributor

therool commented Dec 9, 2016

I encountered the same issue on magento 2.1.0 and found that the issue lies withing https://github.com/magento/magento2/blob/develop/app/code/Magento/CheckoutAgreements/Block/Adminhtml/Agreement/Edit/Form.php#L139. Megento expects that the value of hidden field is string but existing aggreement stores property is always array containing all the store ids it it associated with and is overwrites the default store id on https://github.com/magento/magento2/blob/develop/app/code/Magento/CheckoutAgreements/Block/Adminhtml/Agreement/Edit/Form.php#L186.

The fix is pretty easy - just change the line https://github.com/magento/magento2/blob/develop/app/code/Magento/CheckoutAgreements/Block/Adminhtml/Agreement/Edit/Form.php#L144 to
$model->setStores($this->_storeManager->getStore(true)->getId());

@KrystynaKabannyk
Copy link

@rbostan, the fix will be provided under MAGETWO-63840 (MAGETWO-60143 is closed as duplicate).

@magento-engcom-team magento-engcom-team added 2.1.x Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development bug report Component: Checkout Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed labels Sep 11, 2017
@magento-engcom-team magento-engcom-team added the Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed label Oct 10, 2017
@magento-engcom-team
Copy link
Contributor

@rbostan, thank you for your report.
We've created internal ticket(s) MAGETWO-63840 to track progress on the issue.

@magento-engcom-team magento-engcom-team added 2.2.x Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release labels Oct 11, 2017
@ghost
Copy link

ghost commented Dec 5, 2017

I just encountered this on 2.2.1 too. Can someone please give me a diff/patch to fix that?

edit: switched to another system. so i can not give any more information.

@ajankuv
Copy link

ajankuv commented Mar 2, 2018

Do we have a fix yet?

edit: single store is the cause of most of this, i had an issue with a module switching back to multi-store fixed it. My guess is their should be some logic switch from multi to single to fix this for everything. This issue is going to linger until that's fixed.

@vaso123
Copy link

vaso123 commented May 31, 2018

It still happens in Magento 2.2.4.

Guys, this ticket opened Oct 25, 2016, so it is 1.5 years old.

@efimov-ivan
Copy link

Confirm that error still happening in Magento 2.2.4

@vaso123
Copy link

vaso123 commented Jul 11, 2018

And still exists in 2.2.5

@zaibigits099
Copy link

following therool . I added this below this line in function _prepareForm of class vendor/magento/module-checkout-agreements/Block/Adminhtml/Agreement/Edit/Form.php but i did over-ride to avoid lossing it after upgrade.

$model->setStores($this->_storeManager->getStore(true)->getId());

and it worked on Magento 2.2.4 with me.

pmsteil added a commit to pmsteil/magento2 that referenced this issue Sep 3, 2018
Fixes: magento#7171
magento#7171

Not sure if this is the best fix for this, need someone more senior with Magento to evaluate.  But this fixes the issue I had with this.
pmsteil added a commit to pmsteil/magento2 that referenced this issue Sep 3, 2018
Fix for htmlspecialchars() expects parameter 1 to be string, array given in /Data/Form/Element/AbstractElement.php 

Fixes magento#7171
@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Sep 10, 2018

Can confirm, editing the _escape function work around by pmsteil resolves this.

Not sure if it the call to escape should have multiple argument types in same function?

_escape($string : string)
_escape($string : array)

Microsoft Office Word text quotes get lost in saving/editing however.
I'm not sure if that is related to this or the way the string is stored/processed.

“Test”
Gets returned in this encoding.
�Test�
It does render okay on the front end, but the back end editor does not show correctly.

@sdzhepa
Copy link
Contributor

sdzhepa commented May 15, 2019

Hello @rbostan

Thank you for your report.
The issue was fixed and delivered with commits:

@sdzhepa sdzhepa closed this as completed May 15, 2019
magento-engcom-team pushed a commit that referenced this issue Nov 10, 2021
ACP2E-10: Incorrect Discount: Two Cart rules with and without coupon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Checkout Issue: Clear Description Gate 2 Passed. Manual verification of the issue description passed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Reproduced on 2.2.x The issue has been reproduced on latest 2.2 release Reproduced on 2.3.x The issue has been reproduced on latest 2.3 release
Projects
None yet
Development

No branches or pull requests