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

Remove dead / unreachable code in core/calendar block renderer. #14546

Merged

Conversation

svenvanhal
Copy link
Contributor

Description

The core/calendar block registration file contains variable assignments after a return statement (hence dead code). After removing this code, I discovered that the variables in question ($previous_monthnum and $previous_year) are never used anyway (not in this function, not in get_calendar and never in the entire codebase for that matter).

This PR removes dead code and unused variables to prevent any future ambiguities or bugs.

How has this been tested?

Tests pass, not sure how to test server side rendering well
This change seems safe / harmless, however

Types of changes

Refactor, non-breaking

@gziolo gziolo added [Type] Code Quality Issues or PRs that relate to code quality [Block] Calendar Affects the Calendar Block labels Mar 21, 2019
@gziolo
Copy link
Member

gziolo commented Mar 21, 2019

@jorgefilipecosta - what was the reason these global variables had to be updated? If it is still necessary, they should be assigned back to the initial value before the return statement.

Copy link
Member

@jorgefilipecosta jorgefilipecosta left a comment

Choose a reason for hiding this comment

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

The change looks good to me 👍
Thank you for submitting this fix!

@jorgefilipecosta jorgefilipecosta merged commit 9d3292b into WordPress:master Mar 21, 2019
@youknowriad youknowriad added this to the 5.4 (Gutenberg) milestone Mar 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Calendar Affects the Calendar Block [Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants