Skip to content

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

Merged
jorgefilipecosta merged 1 commit into
WordPress:masterfrom
delft-swa-gutenberg:remove/dead_code
Mar 21, 2019
Merged

jorgefilipecosta merged 1 commit into
WordPress:masterfrom
delft-swa-gutenberg:remove/dead_code

Conversation

@svenvanhal

Copy link
Copy Markdown
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

gziolo commented Mar 21, 2019

Copy link
Copy Markdown
Member

@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.

@jorgefilipecosta jorgefilipecosta left a comment

Copy link
Copy Markdown
Member

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