Conversation
The get_original_from_post_id() method returns a taxonomy term slug (string), which may include WordPress slug deduplication suffixes (e.g., '12363971-2'). This string was passed directly to get_permalink() which has a strict ?int type hint for $original_id, causing a PHP fatal TypeError. Cast $original_id to (int) after the falsy check to ensure type compatibility. Co-authored-by: dd32 <767313+dd32@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix TypeError in GP_Route_Translation_Helpers get_permalink method
Fix TypeError in get_permalink: cast taxonomy slug to int
Mar 20, 2026
… parameter The `get_permalink()` method only uses `$original_id` for string concatenation, so the strict `?int` type hint was unnecessarily restrictive. Multiple callers naturally pass string values (taxonomy term slugs, untyped route parameters, DB object properties). Remove the type hint entirely (keeping PHPDoc as `string|int|null`) to be consistent with the rest of the codebase which uses `?type` nullable syntax rather than PHP 8.0+ union types. Also revert the previous `(int)` cast workaround in helper-translation-discussion.php since it's no longer needed. Co-authored-by: dd32 <767313+dd32@users.noreply.github.com>
Copilot
AI
changed the title
Fix TypeError in get_permalink: cast taxonomy slug to int
Remove strict Mar 20, 2026
?int type hint from get_permalink() $original_id parameter
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @copilot. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Member
|
@copilot ? Follow up on above? |
…s PHP 8.1+ Co-authored-by: dd32 <767313+dd32@users.noreply.github.com>
Author
Copilot
AI
changed the title
Remove strict
Replace strict Mar 20, 2026
?int type hint from get_permalink() $original_id parameter?int type hint with string|int|null union type for get_permalink() $original_id parameter
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GP_Route_Translation_Helpers::get_permalink()declares?int $original_idbut multiple callers pass strings — taxonomy term slugs fromget_original_from_post_id(), untyped route parameters, DB object properties. This causes a fatalTypeErroron PHP 8+.The parameter is only used for string concatenation (
$project_path . '/' . $original_id), so the strict int type was wrong.?inttype hint withstring|int|nullunion type (codebase targets PHP 8.1+)(int)cast workaround previously added inrewrite_original_post_type_permalink()📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.