Skip to content

fix(ui,next): resolve globals copy and versions config lookup bugs - #17072

Open
ligong wants to merge 2 commits into
payloadcms:3.xfrom
ligong:fix-copy-to-locale-on-globals-16747
Open

ligong wants to merge 2 commits into
payloadcms:3.xfrom
ligong:fix-copy-to-locale-on-globals-16747

Conversation

@ligong

@ligong ligong commented Jun 21, 2026

Copy link
Copy Markdown

What?

This PR fixes two bugs in Payload CMS related to how global configurations are looked up in the Admin UI and the Next.js views:

  1. A crash (TypeError) when copying localized data from one locale to another on a Global.
  2. A silent bug where draft/version queries for globals did not detect that versions were enabled, leading to incorrect
    queries (returning draft content when published was expected).

Why?

  1. In copyDataFromLocale.ts, the code looked up global fields using globals[globalSlug].config.fields. However, payload.globals only contains the database model instances or initial states and is not keyed by slug with configurations, leading to a crash.
  2. In fetchVersions.ts, the logic checked if versions were enabled on the entity using req.payload.globals[globalSlug]?.config. Because req.payload.globals is not structured this way, the configuration returned undefined (falsy). As a result, the code incorrectly assumed drafts/versions were disabled for all globals, causing version queries to bypass status-based filtering.

How?

  1. Modified packages/ui/src/utilities/copyDataFromLocale.ts to retrieve the global configuration correctly using payload.config.globals.find((g) => g.slug === globalSlug)?.fields.
  2. Modified packages/next/src/views/Version/fetchVersions.ts to locate the global configuration via req.payload.config.globals.find((g) => g.slug === globalSlug).
  3. Added a new integration test should copy global data to another locale in test/localization/int.spec.ts (using a new test global global-copy-test) to prevent regressions on copy-locale operations for globals.
  4. Added a new integration test should retrieve the latest published version of a global in test/versions/int.spec.ts
    using simpleDraftGlobalSlug to ensure version querying fetches correct published drafts on globals.

Fixes #16747

@mikkeldev

Copy link
Copy Markdown

Any updates on this?

@ligong
ligong force-pushed the fix-copy-to-locale-on-globals-16747 branch from f0b6204 to c2b3201 Compare August 4, 2026 14:11
@ligong

ligong commented Aug 4, 2026

Copy link
Copy Markdown
Author

It looks that the CI issue has been fixed. I've rebased the latest 3.x code and pushed it.

@mikkeldev

Copy link
Copy Markdown

It looks that the CI issue has been fixed. I've rebased the latest 3.x code and pushed it.

So basically just need review from @AlessioGr , @JarrodMFlesch and @jacobsfletch it seems? :) 🤞

This behaviour has been reported quite heavily from our colleagues using payloadcms, which is why I requested an update. Sorry for the intrusion :D

@mikkeldev

Copy link
Copy Markdown

Any news?

@ligong
ligong force-pushed the fix-copy-to-locale-on-globals-16747 branch from c2b3201 to 110d5ec Compare September 5, 2026 13:40
@ligong

ligong commented Sep 5, 2026

Copy link
Copy Markdown
Author

Hi team, I've rebased this branch onto latest 3.x to refresh the PR and re-trigger the CI checks. Whenever someone has a moment, could you please approve the workflow run? Thanks!

@coderabbitai

coderabbitai Bot commented Oct 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 483c2183-5882-4b2b-a621-bdbdbf9738cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@ligong

ligong commented Nov 17, 2026

Copy link
Copy Markdown
Author

Hi @denolfe, thanks for triaging this with the v3 label. Following up here since the previous CI run expired waiting for workflow approval—before I rebase again to re-trigger the checks, are you still merging community bug fixes into 3.x right now (or has focus shifted to v4)? Happy to update the branch if this is on your radar to merge.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants