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

Shortcode: Fix issue when no attributes are passed #13264

Merged

Conversation

AnuragVasanwala
Copy link
Collaborator

@AnuragVasanwala AnuragVasanwala commented May 8, 2023

Context

This PR fixes #13262 by adding initialization check for the attributes as described in the issue.

Summary

When no argument is passed to the shortcode raises following error:

Fatal error: Uncaught TypeError: Google\Web_Stories\Shortcode\Stories_Shortcode::render_stories(): Argument #1 ($attrs) must be of type array, string given, called in /wp-includes/shortcodes.php on line 355 and defined in /wp-content/plugins/web-stories/includes/Shortcode/Stories_Shortcode.php on line 67

As per the issue #13262, I have addressed changes mentioned and tested it.

TODO

  • Add unit-testing for the PR

Testing Instructions

  1. Insert shortcode block in post editor
  2. Insert [web_stories /]
  3. Try to save post
  4. Get errors
  • This is a non-user-facing change and requires no QA

Reviews

Does this PR have a security-related impact?

No.

Does this PR change what data or activity we track or use?

No.

Does this PR have a legal-related impact?

No.

Checklist

  • This PR addresses an existing issue and I have linked this PR to it in ZenHub
  • I have tested this code to the best of my abilities
  • This code is covered by automated tests (unit, integration, and/or e2e) to verify it works as intended (docs)
  • I have added documentation where necessary

Fixes #13262

@google-cla
Copy link

google-cla bot commented May 8, 2023

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@AnuragVasanwala AnuragVasanwala marked this pull request as draft May 9, 2023 04:46
@swissspidy swissspidy added Type: Bug Something isn't working P2 Should do soon Group: WordPress Changes related to WordPress or Gutenberg integration Group: Shortcodes labels May 10, 2023
@swissspidy swissspidy added this to the 1.33.0 milestone May 10, 2023
@swissspidy swissspidy self-requested a review May 10, 2023 14:00
@AnuragVasanwala AnuragVasanwala marked this pull request as ready for review May 16, 2023 06:33
@swissspidy swissspidy changed the title Fix: Shortcode issue when no attribute is passed Shortcode: Fix issue when no attributes are passed May 16, 2023
Copy link
Collaborator

@swissspidy swissspidy left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

@swissspidy swissspidy merged commit c1f2e4e into GoogleForCreators:main May 16, 2023
25 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Shortcodes Group: WordPress Changes related to WordPress or Gutenberg integration P2 Should do soon Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shortcode: Fatal error when passing no attributes
2 participants