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

Undefined array key 0 warning at console Installation #3672

Closed
akunzai opened this issue Nov 22, 2023 · 5 comments · Fixed by #3677
Closed

Undefined array key 0 warning at console Installation #3672

akunzai opened this issue Nov 22, 2023 · 5 comments · Fixed by #3677

Comments

@akunzai
Copy link
Contributor

akunzai commented Nov 22, 2023

Preconditions (*)

  1. OpenMage 20.2.0
  2. PHP 8.2

See my gist

Steps to reproduce (*)

# start containers
docker compose up -d

# install OpenMage
bash ./install.sh

Expected result (*)

Install success without errors

Checking database...
Installing OpenMage...
SUCCESS: ef6481244432fb89d109db9017743b1e

Actual result (*)

Checking database...
Installing OpenMage...
ERROR: Error in file: "/var/www/html/app/code/core/Mage/Customer/sql/customer_setup/mysql4-data-upgrade-1.4.0.0.7-1.4.0.0.8.php" - Warning: Undefined array key 0  in /var/www/html/app/code/core/Mage/Core/Model/App.php on line 1006

Workaround: change php.ini to ignore warnings

error_reporting=E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED & ~E_WARNING

I wrote some simple code to reproduce exception at App.php.

<?php
function mageCoreErrorHandler($errno, $errstr, $errfile, $errline)
{
  $errno = $errno & error_reporting();
  if ($errno == 0) {
    return false;
  }
  throw new Exception($errstr);
}
set_error_handler('mageCoreErrorHandler');
error_reporting(E_ALL);
$website = 1;
$websites = [];
$id = false;
$code = null;
$websites[$code] = $website;
echo $websites[$code], "\n"; # [''] => 1
echo $websites[$id], "\n"; # [0] => Undefined array key 0
print_r($websites);
@akunzai akunzai added the bug label Nov 22, 2023
@fballiano
Copy link
Contributor

I've tested a clean installation without seeing your problem, can you provide a install.php script with all the parameters for a quick check?

@sreichel
Copy link
Contributor

I remember this error.

Can you test #3248 or install via n98-magerun?

@akunzai
Copy link
Contributor Author

akunzai commented Nov 22, 2023

@sreichel
Copy link
Contributor

@akunzai its nothing about your env ...

For some reason false is passed to Mage_Core_Model_App::getWebsite($id = null), but false isnt an expeccted input ... and not handled.

@akunzai
Copy link
Contributor Author

akunzai commented Nov 23, 2023

the false was return by Store::getWebsite

and the warning only becomes exception in Developer mode(MAGE_IS_DEVELOPER_MODE=1)

I'll try to fire a PR to handle the false value

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

Successfully merging a pull request may close this issue.

4 participants