fix: clear legacy _projects_portfolio_github_url on provider switch / empty repo URL

This commit is contained in:
Keith Solomon
2026-08-09 23:49:06 -05:00
parent 981c29ab39
commit 0480abe292
3 changed files with 85 additions and 1 deletions
+10 -1
View File
@@ -114,7 +114,16 @@ function projects_portfolio_save_meta_box( $post_id ) {
// Maintain the legacy key for backward-compat reads (only when this is a GitHub project).
$provider_now = get_post_meta( $post_id, '_projects_portfolio_provider', true );
if ( 'github' === $provider_now ) {
update_post_meta( $post_id, '_projects_portfolio_github_url', $repo_url );
if ( '' === $repo_url ) {
// Clearing the field on a GitHub project should clear the legacy key too.
delete_post_meta( $post_id, '_projects_portfolio_github_url' );
} else {
update_post_meta( $post_id, '_projects_portfolio_github_url', $repo_url );
}
} else {
// Provider is gitea (or any non-github): ensure no stale GitHub URL can
// resurrect via the legacy fallback chain.
delete_post_meta( $post_id, '_projects_portfolio_github_url' );
}
}