Magento 2.2 and PHP 7.2
Are you facing issues after upgrading magento 2.2 to PHP 7.2?
Follow below steps to resolve the same.
Migrating Magento 2.2 to server with PHP version 7.2 , many issues faced and so we have approached many files to solve this.
Keep patient and follow steps one by one.
1) PHP 7.2 does not contain 4 the mcrypt extension 8.
In Debian
pecl install mcrypt-snapshot
In Windows
composer require phpseclib/mcrypt_compat:*
2) Warning: ini_set(): A session is active. You cannot change the session module’s ini settings at this time in lib/internal/Magento/Framework/Session/SessionManager.php on line 129
Replace the lines:
lib/internal/Magento/Framework/Session/SessionManager.php
#Line128-Line129
// Enable session.use_only_cookies
ini_set(‘session.use_only_cookies’, ‘1’);
with the following ones:
if (!$this->isSessionExists()) {
// Enable session.use_only_cookies
ini_set(‘session.use_only_cookies’, ‘1’);
}
3) Declaration of Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php
#Line52-Line52
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
4) Declaration of Magento\Customer\Model\ResourceModel\Address\Attribute\Source\CountryWithWebsites::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions
Replace the line:
app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/CountryWithWebsites.php
#Line74-Line74
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
5) Declaration of Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Region::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Region.php
#Line40-Line40
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
6) Declaration of Magento\Customer\Model\Customer\Attribute\Source\Website::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Customer/Model/Customer/Attribute/Source/Website.php
#Line37-Line37
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
7) Declaration of Magento\Customer\Model\Customer\Attribute\Source\Store::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Customer/Model/Customer/Attribute/Source/Store.php
#Line45-Line45
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
8) Declaration of Magento\Customer\Model\Customer\Attribute\Source\Group::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Customer/Model/Customer/Attribute/Source/Group.php
#Line47-Line47
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
9) Declaration of Magento\Eav\Model\Entity\Attribute\Source\Store::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php
#Line41-Line41
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
10) Declaration of Magento\Eav\Model\Entity\Attribute\Source\Store::getAllOptions() must be compatible with Magento\Eav\Model\Entity\Attribute\Source\Table::getAllOptions($withEmpty = true, $defaultValues = false)
Replace the line:
app/code/Magento/Eav/Model/Entity/Attribute/Source/Store.php
#Line41-Line41
public function getAllOptions()
with the following one:
public function getAllOptions($withEmpty = true, $defaultValues = false)
11) Declaration of Magento\Directory\Model\Config\Source\Country\Full::toOptionArray($isMultiselect = false) must be compatible with Magento\Directory\Model\Config\Source\Country::toOptionArray($isMultiselect = false, $foregroundCountries = ‘’)
Replace the line:
app/code/Magento/Directory/Model/Config/Source/Country/Full.php
#Line22-Line22
public function toOptionArray($isMultiselect = false)
with the following one:
public function toOptionArray($isMultiselect = false, $foregroundCountries = '')
12) Declaration of Magento\Tax\Model\System\Config\Source\Tax\Country::toOptionArray($noEmpty = false) must be compatible with Magento\Directory\Model\Config\Source\Country::toOptionArray($isMultiselect = false, $foregroundCountries = ‘’)
Replace the line:
app/code/Magento/Tax/Model/System/Config/Source/Tax/Country.php
#Line19-Line19
public function toOptionArray($noEmpty = false)
with the following one:
public function toOptionArray($noEmpty = false, $foregroundCountries = '')
13) Warning: count(): Parameter must be an array or an object that implements Countable in lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php on line 237
Replace the line:
lib/internal/Magento/Framework/View/Design/Theme/ThemeList.php
#Line237-Line237
if (count($parentPathPieces) == 1) {
with the following one:
if ($parentPathPieces && count($parentPathPieces) == 1) {
14) Warning: count(): Parameter must be an array or an object that implements Countable in Magento/Backend/Block/Menu.php on line 390
Step 1:
Replace the line:
app/code/Magento/Backend/Block/Menu.php
#Line90-Line390
if (count($colBrakes) && $colBrakes[$itemPosition][‘colbrake’] && $itemPosition != 1) {
with the following one:
if ($colBrakes && count($colBrakes) && $colBrakes[$itemPosition]['colbrake'] && $itemPosition != 1) {
Step 2:
Replace the line:
app/code/Magento/Backend/Block/Menu.php
#Line404-Line404
if (count($colBrakes) && $limit) {
with the following one:
if ($colBrakes && count($colBrakes) && $limit) {
15) Warning: count(): Parameter must be an array or an object that implements Countable in Magento/Wishlist/Observer/AddToCart.php on line 79
Replace the line:
app/code/Magento/Wishlist/Observer/AddToCart.php
#Line79-Line79
16) Warning: sizeof(): Parameter must be an array or an object that implements Countable in app/code/Magento/Sales/view/adminhtml/templates/order/totalbar.phtml on line 10
Replace the line:
app/code/Magento/Sales/view/adminhtml/templates/order/totalbar.phtml
#Line10-Line10
<?php if (sizeof($block->getTotals()) > 0): ?>
with the following one:
<?php if ($block->getTotals()): ?>
You are done!!!!!
-------------------------------------------------------------------------------------------------------------------------------
Useful article
ReplyDelete