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

Exception: Warning: Trying to access array offset on value of type null #4256

Open
r-martins opened this issue Oct 7, 2024 · 13 comments
Open

Comments

@r-martins
Copy link

Preconditions (*)

  1. Trying to place an order as a new customer
  2. OpenMage 20.10

Steps to reproduce (*)

  1. Add product to cart and proceed to checkout
  2. Create a new customer (instead of login)
  3. Place order

Expected result (*)

  1. Order to be placed with no issues

Actual result (*)

  1. Alert saying something went wrong. The following is logged:

Exception: Warning: Trying to access array offset on value of type null in /var/www/html/app/code/core/Mage/Checkout/Model/Type/Onepage.php on line 733 in /var/www/html/app/code/core/Mage/Core/functions.php:207
Stack trace:
#0 /var/www/html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(733): mageCoreErrorHandler(2, 'Trying to acces...', '/var/www/html/a...', 733)
#1 /var/www/html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(811): Mage_Checkout_Model_Type_Onepage->_prepareNewCustomerQuote()
#2 /var/www/html/app/code/core/Mage/Checkout/controllers/OnepageController.php(605): Mage_Checkout_Model_Type_Onepage->saveOrder()
#3 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(437): Mage_Checkout_OnepageController->saveOrderAction()
#4 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(262): Mage_Core_Controller_Varien_Action->dispatch('saveOrder')
#5 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(192): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#6 /var/www/html/app/code/core/Mage/Core/Model/App.php(381): Mage_Core_Controller_Varien_Front->dispatch()
#7 /var/www/html/app/Mage.php(763): Mage_Core_Model_App->run(Array)
#8 /var/www/html/index.php(93): Mage::run('', 'store')

Additional config that may be relevant:

378|default|0|admin/security/session_cookie_lifetime|50400|
758|default|0|web/default/cms_no_cookies|enable-cookies|
761|default|0|web/cookie/cookie_lifetime|50400|
762|default|0|web/cookie/cookie_path||
763|default|0|web/cookie/cookie_domain||
764|default|0|web/cookie/cookie_httponly|0|
765|default|0|web/cookie/cookie_samesite|None|
766|default|0|web/cookie/cookie_restriction|0|
772|default|0|web/browser_capabilities/cookies|1|


default|0|customer/address/street_lines|4
default|0|shipping/origin/street_line1|Rua Angelo Guerra
default|0|shipping/origin/street_line2|1

  • PHP 8.0.30
  • MariaDB 10.4.17
@r-martins r-martins added the bug label Oct 7, 2024
@kiatng
Copy link
Contributor

kiatng commented Oct 9, 2024

$customer = $this->getCustomerSession()->getCustomer();

As you can see,, line 733 has no var of type array. I also search "[" on the file, I cannot find anything that could cause the error Trying to access array offset on value of type null. Can you copy paste the function that has line 733?

@sreichel
Copy link
Contributor

sreichel commented Oct 9, 2024

Tried to reproduce ... w/o success.

@r-martins
Copy link
Author

        Mage::helper('core')->copyFieldset('checkout_onepage_quote', 'to_customer', $quote, $customer);
        $customer->setPassword($customer->decryptPassword($quote->getPasswordHash()));
        $passwordCreatedTime = $this->_checkoutSession->getData('_session_validator_data')['session_expire_timestamp']
            - Mage::getSingleton('core/cookie')->getLifetime();
        $customer->setPasswordCreatedAt($passwordCreatedTime);
        $quote->setCustomer($customer)
            ->setCustomerId(true);
        $quote->setPasswordHash('');

Line 733 here is the $passwordCreatedTime = ...

@sreichel
Copy link
Contributor

sreichel commented Oct 10, 2024

This should not be there.

It was changed in #2916 (https://github.com/OpenMage/magento-lts/releases/tag/v20.1.0-rc4)

Have you any rewrites in app/code/local?

File from 20.10 release ... https://github.com/OpenMage/magento-lts/blob/v20.10.0/app/code/core/Mage/Checkout/Model/Type/Onepage.php

@r-martins
Copy link
Author

Probably I failed to update it to the latest version. I'm using openMage with composer, but despite the fact that my composer.lock shows I'm using v20.10.2, app/code/core remains with the old 20.5.0.

What is the correct way to update OpenMage? Sorry about that.

@sreichel
Copy link
Contributor

If you composer.lock says "20.10.2" re-run "composer install". (maybe remove vendor dir before)

@r-martins
Copy link
Author

r-martins commented Oct 10, 2024

I tried this in many different ways, but it only says my "/var/www/html/app/Mage.php was already patched" and don't update any of the app/code/core or Mage.php.

openmage.mp4

https://www.dropbox.com/scl/fi/ietx5dxqz6r4pemfqjylo/openmage-update.mp4?rlkey=k4s9v8a32q31w3ej2y9accgp9&dl=0

@r-martins
Copy link
Author

Replaced app/code/core, Mage.php and lib folders for the ones in the latest version of vendor/openmage/magento-lts.
Still got some other deprecated errros. The only way I found to to get rid of them in the development environment was to disable developerMode (Mage::setIsDeveloperMode(false) in index.php).

@kiatng
Copy link
Contributor

kiatng commented Oct 15, 2024

Replaced app/code/core, Mage.php and lib folders for the ones in the latest version of vendor/openmage/magento-lts. Still got some other deprecated errros. The only way I found to to get rid of them in the development environment was to disable developerMode (Mage::setIsDeveloperMode(false) in index.php).

Alternatively, if you can list the deprecated errors here, we can try and fix it.

@r-martins
Copy link
Author

r-martins commented Oct 15, 2024

Sure. This happened when placing an order with OSC.

==> src/htdocs/var/log/exception.log <==
2024-10-15T22:55:13+00:00 ERR (3): 
Exception: Deprecated functionality: Function mcrypt_module_open() is deprecated  in /var/www/html/lib/Varien/Crypt/Mcrypt.php on line 61 in /var/www/html/app/code/core/Mage/Core/functions.php:184
Stack trace:
#0 /var/www/html/lib/Varien/Crypt/Mcrypt.php(61): mageCoreErrorHandler(8192, 'Function mcrypt...', '/var/www/html/l...', 61)
#1 /var/www/html/app/code/core/Mage/Core/Model/Encryption.php(172): Varien_Crypt_Mcrypt->init('670c202bafcedd3...')
#2 /var/www/html/app/code/core/Mage/Core/Model/Encryption.php(185): Mage_Core_Model_Encryption->_getCrypt()
#3 /var/www/html/app/code/core/Mage/Core/Helper/Data.php(221): Mage_Core_Model_Encryption->encrypt('teste2024101685...')
#4 /var/www/html/app/code/core/Mage/Customer/Model/Customer.php(568): Mage_Core_Helper_Data->encrypt('teste2024101685...')
#5 /var/www/html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(441): Mage_Customer_Model_Customer->encryptPassword('teste2024101685...')
#6 /var/www/html/app/code/core/Mage/Checkout/Model/Type/Onepage.php(311): Mage_Checkout_Model_Type_Onepage->_validateCustomerData(Array)
#7 /var/www/html/.modman/oscbrasil6/app/code/community/Inovarti/Onestepcheckout/controllers/AjaxController.php(353): Mage_Checkout_Model_Type_Onepage->saveBilling(Array, false)
#8 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Action.php(424): Inovarti_Onestepcheckout_AjaxController->placeOrderAction()
#9 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(255): Mage_Core_Controller_Varien_Action->dispatch('placeOrder')
#10 /var/www/html/app/code/core/Mage/Core/Controller/Varien/Front.php(181): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#11 /var/www/html/app/code/core/Mage/Core/Model/App.php(358): Mage_Core_Controller_Varien_Front->dispatch()
#12 /var/www/html/app/Mage.php(761): Mage_Core_Model_App->run(Array)
#13 /var/www/html/index.php(93): Mage::run(4, 'website')

@kiatng
Copy link
Contributor

kiatng commented Oct 16, 2024

@r-martins You need to install "phpseclib/mcrypt_compat": "^2.0.3" for the deprecated function mcrypt_module_open(). See

"phpseclib/mcrypt_compat": "^2.0.3",

@r-martins
Copy link
Author

it is there..

root@b21df065f3a7:/var/www/html# ./composer.phar info phpseclib/mcrypt_compat
you may want to add the packages.firegento.com repository to composer.
add it with: composer.phar config -g repositories.firegento composer https://packages.firegento.com
name     : phpseclib/mcrypt_compat
descrip. : PHP 5.x-8.x polyfill for mcrypt extension
keywords : cryptograpy, encryption, mcrypt, polyfill
versions : * 2.0.6
released : 2024-02-26, 7 months ago
type     : library
license  : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
homepage : 
source   : [git] https://github.com/phpseclib/mcrypt_compat.git e5924504997b4f90772034cefd89dc2f4ec189dc
dist     : [zip] https://api.github.com/repos/phpseclib/mcrypt_compat/zipball/e5924504997b4f90772034cefd89dc2f4ec189dc e5924504997b4f90772034cefd89dc2f4ec189dc
path     : /var/www/html/vendor/phpseclib/mcrypt_compat
names    : phpseclib/mcrypt_compat, ext-mcrypt

support
email : [email protected]
issues : https://github.com/phpseclib/mcrypt_compat/issues
source : https://github.com/phpseclib/mcrypt_compat

autoload
files

requires
php >=5.6.1
phpseclib/phpseclib >=3.0.36 <4.0.0

requires (dev)
phpunit/phpunit ^5.7|^6.0|^9.4

suggests
ext-openssl Will enable faster cryptographic operations

provides
ext-mcrypt 5.6.40
root@b21df065f3a7:/var/www/html# 

@sreichel
Copy link
Contributor

sreichel commented Oct 17, 2024

Do you have a vendor dir outside openmages?

Install clearly says it installs 20.10.2 .... so it loads files from anywhere else (?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants