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

Fixed warning Undefined array key 0 when installing OM via command line (dev mode on) (#3672) #3677

Merged
merged 5 commits into from
Feb 6, 2024
Merged

Fixed warning Undefined array key 0 when installing OM via command line (dev mode on) (#3672) #3677

merged 5 commits into from
Feb 6, 2024

Conversation

akunzai
Copy link
Contributor

@akunzai akunzai commented Nov 23, 2023

Description (*)

Handle posible false value in App::getWebsite from Store::getWebsite at mysql4-data-upgrade-1.4.0.0.7-1.4.0.0.8.php

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Undefined array key 0 warning at console Installation #3672

Manual testing scenarios (*)

  1. create docker env from this gist
  2. run the containers
  3. change the source code in OpenMage container as this PR
  4. run the install.sh from gist to install OpenMage

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)
  • Add yourself to contributors list

@github-actions github-actions bot added the Component: Core Relates to Mage_Core label Nov 23, 2023
@sreichel
Copy link
Contributor

Not sure if its the best way, but i have no better idea right now. Needs some investigation.

fballiano
fballiano previously approved these changes Dec 11, 2023
Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine to me

@sreichel
Copy link
Contributor

false leads to another exception in behind.

I run into same and did not fix it that way. At least add a "todo" annotation.

@Sekiphp
Copy link
Contributor

Sekiphp commented Dec 19, 2023

This can provide unexpectable behavior of application. In ideal case method should throw Exception, that website not exists and fix places, where the error is provided.

I do not think, that if you call Mage::app()->getWebsite(false) you should get current website instance.

@midlan
Copy link
Contributor

midlan commented Dec 19, 2023

Why not just fix the file mysql4-data-upgrade-1.4.0.0.7-1.4.0.0.8.php?

@fballiano fballiano self-requested a review December 20, 2023 10:20
@akunzai
Copy link
Contributor Author

akunzai commented Dec 20, 2023

Thanks for everyone's advice. I made some changes to this PR, and I think that null should be enough to throw exceptions and clarify that the website does not exist!

@midlan
Copy link
Contributor

midlan commented Dec 20, 2023

@akunzai I still believe we shouldn't modify one of the most commonly used method in code. Instead, let's focus on fixing the specific file where you discovered the issue.

app/code/core/Mage/Core/Model/Store.php Outdated Show resolved Hide resolved
Co-authored-by: Fabrizio Balliano <[email protected]>
Copy link
Contributor

@midlan midlan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current solution is ok for me, approving

@fballiano fballiano changed the title Fixed warning: Undefined array key 0 (#3672) Fixed warning Undefined array key 0 when installing OM via command line (#3672) Dec 20, 2023
@fballiano
Copy link
Contributor

@akunzai silly question, did you test the current implementation of this PR?

@akunzai
Copy link
Contributor Author

akunzai commented Dec 20, 2023

@fballiano Yes, I tested the CLI installation via with current implementation.

@sreichel
Copy link
Contributor

It "works", but seems wrong as @Sekiphp pointed out.

@akunzai
Copy link
Contributor Author

akunzai commented Dec 20, 2023

Please explain your point, I didn't get it. or fire another PR to fix it?

@fballiano
Copy link
Contributor

fballiano commented Jan 26, 2024

@akunzai is the latest implementation of this PR tested?

everybody: Since this PR patches the install file, it seems to be ok to me and I'd merge it, anything against it?

@github-actions github-actions bot added the Component: Customer Relates to Mage_Customer label Jan 26, 2024
@sreichel
Copy link
Contributor

I do not think, that if you call Mage::app()->getWebsite(false) you should get current website instance.

This. But i had no better idea so far.

@fballiano
Copy link
Contributor

I do not think, that if you call Mage::app()->getWebsite(false) you should get current website instance.

This. But i had no better idea so far.

@sreichel in that case it could be fixed in a different place but could probably be another PR right?

@sreichel
Copy link
Contributor

sreichel commented Jan 26, 2024

I really dont know ... as said, i faced same issue and thought about to fix it that way, but it leads to another exception in background (needs to turn dev-mode on, or xdebug on ... )

imho ... this need more investigation

@akunzai
Copy link
Contributor Author

akunzai commented Feb 3, 2024

@fballiano

The console installation success without any errors with the latest implementation of this PR.

CleanShot 2024-02-03 at 23 00 59@2x

@sreichel
Copy link
Contributor

sreichel commented Feb 3, 2024

@akunzai this error only occurs with dev-mode on.

You can set the environment variable to 0 in CLI too.

This "fix" seems wrong to me. (otherwise I'd have already made a pr)

@akunzai
Copy link
Contributor Author

akunzai commented Feb 4, 2024

@sreichel

  1. In my setup, I have already turn on the dev-mode by set MAGE_IS_DEVELOPER_MODE=1, Are we using the same environment?
  2. Can you provide the error details (Include the file and line number information)?

@fballiano
Copy link
Contributor

@akunzai I'm testing this PR now but I get this error:

ERROR: Error in file: "openmage/app/code/core/Mage/Sales/sql/sales_setup/upgrade-1.6.0.3-1.6.0.4.php" - Deprecated functionality: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in /Users/fab/Projects/openmage/lib/Varien/Db/Adapter/Pdo/Mysql.php on line 1783

@akunzai
Copy link
Contributor Author

akunzai commented Feb 6, 2024

@fballiano

In my setup, the deprecated errors was suppressed by ~E_STRICT & ~E_DEPRECATED,

IMHO, the deprecated errors should be fix in another PRs.

@fballiano fballiano changed the title Fixed warning Undefined array key 0 when installing OM via command line (#3672) Fixed warning Undefined array key 0 when installing OM via command line (dev mode on) (#3672) Feb 6, 2024
@fballiano
Copy link
Contributor

I don't think it's that useful without fixing #3677 (comment) (and probably more that would appear) but ok

@fballiano fballiano merged commit 208165c into OpenMage:main Feb 6, 2024
17 checks passed
@akunzai akunzai deleted the fix-undefined-array-key0 branch February 6, 2024 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core Relates to Mage_Core Component: Customer Relates to Mage_Customer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Undefined array key 0 warning at console Installation
5 participants