magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Upgrade ZF components. Zend_Json #9236

Closed okorshenko closed 7 years ago

okorshenko commented 7 years ago

Description Upgrade components from ZF1 to ZF2

As a long term goal, we would like to eliminate knowledge about 3rd party libraries from Magento code base. Magento code still can use 3rd party libraries, but they must be wrapped by Magento interfaces and classes (adapters) so that 3rd party libraries can be easily substituted by newest versions or alternative implementations.

Acceptance Criteria

  1. Magento interfaces are defined and can be used instead of ZF1 classes in Magento code
  2. Default implementations for new interfaces are defined and configured as the preferences for new interfaces
  3. Client code of the ZF1 components is refactored to use Magento interfaces
  4. Zend classes are used as private services in Magento adapters
  5. Backward compatibility is preserved
  6. ZF1 components are updated to ZF2

List of the components

# Component Name
(total usages count)
Module Name Usages Count
1 Zend_Json (total: 51) Framework\DataObject.php 1
    Framework\Controller 1
    Framework\Json 2
    Framework\Module 3
    Framework\Webapi 3
    Magento\Weee 6
    Framework\Data 4
    Magento\Theme 31
okorshenko commented 7 years ago

@dmanners if you would like to work on this, I can assign this to you.

dmanners commented 7 years ago

Updated List of the components

# Component Name
(total usages count)
Module Name Usages Count
1 Zend_Json (total: 15) Framework\DataObject.php 1
    Framework\Controller 1
    Framework\Json 2
    Framework\Module 3
    Framework\Webapi 3
    Framework\Data 4
    Magento\Widget 1
dmanners commented 7 years ago

Updated List of the components as of July

# Component Name
(total usages count)
Module Name Usages Count
1 Zend_Json (total: 13) Magento\Customer 1
    Framework\DataObject.php 1
    Framework\Controller 1
    Framework\Json 2
    Framework\Module 5
    Framework\Webapi 3
dmanners commented 7 years ago

Just noticed I forgot to include the setup module in the list of places to change that has 5 occurrences.

dmanners commented 7 years ago

Current status

lib/internal/Magento/Framework/Controller/Result/Json.php:        $this->json = \Zend_Json::encode($data, $cycleCheck, $options);
lib/internal/Magento/Framework/Module/Setup/Migration.php:    protected function _jsonDecode($encodedValue, $objectDecodeType = \Zend_Json::TYPE_ARRAY)
lib/internal/Magento/Framework/Module/Setup/Migration.php:        return \Zend_Json::decode($encodedValue, $objectDecodeType);
lib/internal/Magento/Framework/Module/PackageInfo.php:     * @throws \Zend_Json_Exception
lib/internal/Magento/Framework/Module/PackageInfo.php:                        $packageData = \Zend_Json::decode($jsonData[$key]);
lib/internal/Magento/Framework/Module/PackageInfo.php:                    } catch (\Zend_Json_Exception $e) {
lib/internal/Magento/Framework/Module/PackageInfo.php:                        throw new \Zend_Json_Exception(
lib/internal/Magento/Framework/Json/Decoder.php:        return \Zend_Json::decode($data);
lib/internal/Magento/Framework/Json/Encoder.php:        return \Zend_Json::encode($data);
lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php:        } catch (\Zend_Json_Exception $e) {
lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php:            ->will($this->throwException(new \Zend_Json_Exception));
lib/internal/Magento/Framework/Webapi/Test/Unit/Rest/Request/Deserializer/JsonTest.php:                new \Zend_Json_Exception('Decoding error:' . PHP_EOL . 'Decoding failed: Syntax error')
setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php:            ->will($this->returnValue(\Zend_Json::encode(['success' => true])));
setup/src/Magento/Setup/Test/Unit/Controller/MarketplaceTest.php:            ->will($this->returnValue(\Zend_Json::encode(['success' => true])));
setup/src/Magento/Setup/Model/PackagesAuth.php:                return \Zend_Json::encode(['success' => true]);
setup/src/Magento/Setup/Model/PackagesAuth.php:                return \Zend_Json::encode(['success' => false, 'message' => 'Bad credentials']);
setup/src/Magento/Setup/Model/PackagesAuth.php:            return \Zend_Json::encode(['success' => false, 'message' => $e->getMessage()]);
dmanners commented 7 years ago

Updated List of the components as of 28th of July

# Component Name
(total usages count)
Module Name Usages Count
1 Zend_Json (total: 2) Framework\Json 2

That makes me feel good!

magento-team commented 7 years ago

Internal ticket to track issue progress: MAGETWO-69369

dmanners commented 7 years ago

Small step backwards but no problem 💃 we go again!

# Component Name
(total usages count)
Module Name Usages Count
1 Zend_Json (total: 3) Framework\Json 2
2   Framework\Controller 1
magento-engcom-team commented 7 years ago

Hi @dmanners Thank you for continuous contribution to this component. You almost resolved all issues in that area! 👍 👍 👍 We are closing the issue, but feel free to proceed with Zend_Json refactoring

ishakhsuvarov commented 6 years ago

Hi @okorshenko. Thank you for your report. The issue has been fixed in magento/magento2#13137 by @dmanners in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming patch release.

sidolov commented 6 years ago

Hi @okorshenko. Thank you for your report. The issue has been fixed in magento/magento2#14438 by @dmanners in 2.3-develop branch Related commit(s):

The fix will be available with the upcoming 2.3.0 release.