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 possible bug when saving address with empty street line #10582

Merged

Conversation

vovayatsyuk
Copy link
Member

@vovayatsyuk vovayatsyuk commented Aug 18, 2017

Description

The changes affect address street data preparation to guarantee that street array will be converted to the string.

Manual testing scenarios

  1. Make the street address as an optional field (third-party extension is required or edit DB properties of the field)
  2. Save the address without street
  3. exception 'Exception' with message 'Notice: Array to string conversion on line 2903 in lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php will be raised.

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@ishakhsuvarov ishakhsuvarov self-assigned this Aug 18, 2017
@ishakhsuvarov ishakhsuvarov added this to the August 2017 milestone Aug 18, 2017
@ishakhsuvarov
Copy link
Contributor

@vovayatsyuk Please take a look at the failed unit tests.

@vovayatsyuk
Copy link
Member Author

vovayatsyuk commented Aug 26, 2017

Hi!

Don't know if I did it right, please take a look. (I've added a suppress instruction for failed static test)

@ishakhsuvarov
Copy link
Contributor

@vovayatsyuk Thank you for the update. We will proceed with review and merge.

@ishakhsuvarov
Copy link
Contributor

@vovayatsyuk I've tried to reproduce the described scenario with the develop branch and could not get any E_NOTICE level errors.
I've followed these steps:

  • Make street non-required and remove validation options in Customer module Setup Scripts.
  • Comment out hard-coded address validation in \Magento\Customer\Model\Address\AbstractAddress.
  • Create customer via admin ui with address which does not contain street.

Please provide precise scenario you are following.

Thanks

@vovayatsyuk
Copy link
Member Author

Maybe this issue is reproducible at frontend only, I didn't check backend.

  1. Open eav_attribute table and change is_required column of street attribute to 0
  2. Proceed to checkout at frontend
  3. Fill all fields except address lines
  4. Press "Next" button.

An error will be returned in response:

```
{
"message":"Unable to save address. Please check input data.",
"trace":"
#0 /app/code/Magento/Checkout/Model/GuestShippingInformationManagement.php(48): Magento\Checkout\Model\ShippingInformationManagement->saveAddressInformation('5', Object(Magento\Checkout\Model\ShippingInformation))
#1 [internal function]: Magento\Checkout\Model\GuestShippingInformationManagement->saveAddressInformation('c67a496c937bfdf...', Object(Magento\Checkout\Model\ShippingInformation))
#2 /app/code/Magento/Webapi/Controller/Rest.php(330): call_user_func_array(Array, Array)
#3 /app/code/Magento/Webapi/Controller/Rest.php(239): Magento\Webapi\Controller\Rest->processApiRequest()
#4 /lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))
#5 /lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->___callParent('dispatch', Array)
#6 /lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#7 /generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(39): Magento\Webapi\Controller\Rest\Interceptor->___callPlugins('dispatch', Array, Array)
#8 /lib/internal/Magento/Framework/App/Http.php(135): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#9 /lib/internal/Magento/Framework/App/Bootstrap.php(256): Magento\Framework\App\Http->launch()
#10 /index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#11 {main}
"
}
```

And the following messages will be logged into exception.log:

[2017-08-30 13:57:53] main.CRITICAL: Notice: Array to string conversion in /lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php on line 2999 {"exception":"[object] (Exception(code: 0): Notice: Array to string conversion in /lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php on line 2999 at /lib/internal/Magento/Framework/App/ErrorHandler.php:61)"} []
[2017-08-30 13:57:53] main.CRITICAL: Unable to save address. Please check input data. {"exception":"[object] (Magento\Framework\Exception\InputException(code: 0): Unable to save address. Please check input data. at /app/code/Magento/Quote/Model/ShippingAddressManagement.php:119)"} []

@ishakhsuvarov
Copy link
Contributor

@vovayatsyuk Thank you for the clear and rapid answer

@gwharton
Copy link
Contributor

gwharton commented Nov 8, 2017

@vovayatsyuk Is there a way to get this backported into 2.2?

@vovayatsyuk
Copy link
Member Author

Yep, I will create a backport PR shortly

okorshenko pushed a commit that referenced this pull request Nov 13, 2017
…ving address with empty street line #10582 #12130

 - Merge Pull Request #12130 from vovayatsyuk/magento2:fix-address-empty-street-array-2.2
 - Merged commits:
   1. db377d0
okorshenko pushed a commit that referenced this pull request Nov 13, 2017
okorshenko pushed a commit that referenced this pull request Nov 13, 2017
Public Pull Requests

#11952 11832: Create order (on Customer edit page) - not working from admin environment by @RomaKis
#12141 Fix js error when disable/enable wysiwyg editor by @vovayatsyuk
#12130 [Backport 2.2] MAGETWO-71697: Fix possible bug when saving address with empty street line #10582 by @vovayatsyuk
#12173 8022: Uncaught Error: Call to a member function addItem() on array in app/code/Magento/Sales/Model/Order/Shipment.php(backport to 2.2) by @RomaKis
#12001 11532: Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122 by @RomaKis
#12077 10628: Color attribute swatches are not visible if sorting is enabled by @RomaKis
#12035 Fix newsletter subscriptions between stores by @sbaixauli
#11274 Fix #10477 Check cart rule subselect conditions against quote item children too by @marinagociu

Fixed Public Issues

#11832 Create order (on Customer edit page) - not working from admin environment
#8022 Uncaught Error: Call to a member function addItem() on array in app/code/Magento/Sales/Model/Order/Shipment.php
#11532 Duplicate Simple Product Throws Error: Undefined offset: 0 in SaveHandler.php on line 122
#10628 Color attribute swatches are not visible if sorting is enabled
#10014 Newsletter subscriptions status not isolated between multi stores
#10477 Cart price rule has failed if use dropdown attribute
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants