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

Fix Deprecated Functionality Error Caused by Passing NULL to nl2br() in Sharing Template #3779

Merged
merged 8 commits into from
Feb 5, 2024

Conversation

ahudock
Copy link
Contributor

@ahudock ahudock commented Feb 2, 2024

Description (*)

Prevents an error caused by passing null to nl2br() in the rwd default catalog product view sharing template if the product short description is not set.

It is possible for the short description product attribute to be empty if a site is upgraded from legacy Magento and/or the attribute setting is changed to Values Required "No".

If the product short description isn't set, the sharing template passes null to nl2br(), resulting in "ERR (3): Deprecated functionality: nl2br(): Passing null to parameter #1 ($string) of type string is deprecated in [docroot]/app/design/frontend/rwd/default/template/catalog/product/view/sharing.phtml on line 30".

This change makes sure even if the product short description is null, we at least pass an empty string to nl2br().

Related Pull Requests

n/a

Fixed Issues (if relevant)

n/a

Manual testing scenarios (*)

  1. If it isn't already, change the short description product attribute Values Required "No"
  2. Create a product with no short description or remove it from an existing one
  3. Browse the catalog product view and see that nl2br throws an error in the system log

Questions or comments

  • How do the automated tests mentioned in the contribution checklist work, and how can I tell if all builds are green please?
  • I'm new here; am I doing this right?
  • Thank you all so much for your dedication this project!

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 documentation Component: Catalog Relates to Mage_Catalog Template : rwd Relates to rwd template labels Feb 2, 2024
README.md Show resolved Hide resolved
@addison74
Copy link
Contributor

I think that the change should not strictly target that line in the template file, but it should be analyzed to solve in one place all similar situations related to usage of nl2br through templates. If an attribute used in the template is null, the error could appear, it is not a problem related only to the short_description attribute.

kiatng
kiatng previously approved these changes Feb 4, 2024
@fballiano
Copy link
Contributor

I'm merging this although @kiatng's review got invalidated by my last commit, but I just had to fix a conflict on the README file.

@fballiano fballiano merged commit c976b10 into OpenMage:main Feb 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Catalog Relates to Mage_Catalog documentation Template : rwd Relates to rwd template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants