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: get_edit_term_link() optional taxonomy parameter error #7070

Conversation

Debarghya-Banerjee
Copy link

@Debarghya-Banerjee Debarghya-Banerjee commented Jul 23, 2024

Trac Ticket: Core-61726

Problem

  • The get_edit_term_link() function currently generates an incorrect URL when the $taxonomy parameter is omitted. This issue arises because $taxonomy was made optional. However, the implementation overlooked consistently using $tax->name to populate the taxonomy query parameter in all scenarios.

Solution

  • To resolve this issue, we have updated get_edit_term_link() to consistently use $tax->name instead of $taxonomy when generating the URL. This ensures that the correct taxonomy name is always included in the URL structure, preventing errors and inconsistencies.

Steps to Reproduce

  • Call get_edit_term_link( 42 ) where 42 is the ID of a term.
    • Without the fix, observe that the generated URL lacks the taxonomy parameter, leading to incorrect behavior.

Changes Made

  • Modified get_edit_term_link() to use $tax->name for populating the taxonomy query parameter.
  • Added a test case to verify that the issue is resolved and the correct URL structure is maintained.

Testing

  • Tested the fix by invoking get_edit_term_link() with and without the $taxonomy parameter.
  • Verified that the URL structure is correct in both cases and no errors occur.
  • This enhancement ensures consistent behavior in get_edit_term_link() when determining the correct taxonomy for generating term edit URLs.

Copy link

github-actions bot commented Jul 23, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props debarghyabanerjee, flixos90.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@Debarghya-Banerjee Thank you for the pull request!

It looks great overall. Just a few minor suggestions to polish the test.

tests/phpunit/tests/link/getEditTermLink.php Outdated Show resolved Hide resolved
tests/phpunit/tests/link/getEditTermLink.php Outdated Show resolved Hide resolved
tests/phpunit/tests/link/getEditTermLink.php Outdated Show resolved Hide resolved
@Debarghya-Banerjee
Copy link
Author

Hi @felixarntz , Thanks you for the feedback, I have addressed them and made the necessary changes, assigning you again for re-review.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

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

@Debarghya-Banerjee Thank you, this looks excellent!

@felixarntz
Copy link
Member

@felixarntz felixarntz closed this Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants