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 null deprecation in Mage/Catalog/Model/Product/Option/Type/Text #4357

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

kiatng
Copy link
Contributor

@kiatng kiatng commented Nov 15, 2024

    [type] => 8192:E_DEPRECATED
    [message] => trim(): Passing null to parameter #1 ($string) of type string is deprecated
    [file] => .../app/code/core/Mage/Catalog/Model/Product/Option/Type/Text.php
    [line] => 36

@kiatng kiatng added the PHP 8.1 Related to PHP 8.1 label Nov 15, 2024
@github-actions github-actions bot added the Component: Catalog Relates to Mage_Catalog label Nov 15, 2024
@sreichel
Copy link
Contributor

Its an issue in core or 3rd-party?

@kiatng
Copy link
Contributor Author

kiatng commented Nov 15, 2024

It happened in custom code to create an order programmatically, I agree that null check for values can be placed here. But I feel the core should be more tolerant because it works before. It's a matter of opinion, I have no issue if others feel otherwise.

@sreichel sreichel added the 3rd-party Related to 3rd-party code or issues with customization label Nov 15, 2024
@sreichel
Copy link
Contributor

sreichel commented Nov 15, 2024

Mhh, instead of adding null-checks everywhere (not only in this PR), why not to override the magic method calls? Add ... ?

    public function getUserValue(): string
    {
        return (string) $this->getDataByKey('user_value');
    }

@kiatng
Copy link
Contributor Author

kiatng commented Nov 15, 2024

Commit 2 doesn't work: I get Warning: Array to string conversion in .../app/code/core/Mage/Catalog/Model/Product/Option/Type/Default.php on line 59 (in my version in production)

@kiatng kiatng marked this pull request as draft November 15, 2024 07:11
@kiatng
Copy link
Contributor Author

kiatng commented Nov 15, 2024

It's not that straight forward!

@sreichel
Copy link
Contributor

you made the change in the wrong file. check https://github.com/kiatng/magento-lts/pull/2/files

@kiatng kiatng marked this pull request as ready for review November 15, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd-party Related to 3rd-party code or issues with customization Component: Catalog Relates to Mage_Catalog PHP 8.1 Related to PHP 8.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants