Skip to content

[6.x] Prevent term localizations from saving a copy of the non-localizable slug - #15952

Merged
duncanmcclean merged 1 commit into
6.xfrom
15951
Nov 17, 2026
Merged

duncanmcclean merged 1 commit into
6.xfrom
15951

Conversation

@duncanmcclean

Copy link
Copy Markdown
Member

This pull request fixes an issue where saving a term in a non-default site would store a copy of the slug in that localization's data, even when the slug field isn't localizable. From then on, the localization would keep the old slug instead of following the origin's.

This was happening because TermsController set the slug on every localization, on both update() and store() (when creating a term in a non-default site). LocalizedTerm::slug() prefers the localization's own slug value over the origin's, so the stored copy won.

This PR fixes it by only setting the slug on a localization when the slug field is localizable and it's been localized, similar to how EntriesController handles the entry date. When creating a term in a non-default site, the slug is now only set on the origin.

Since the check also looks at whether the slug field is localizable, terms which have already been affected will start following the origin's slug again the next time they're saved.

Fixes #15951

Amp thread: https://ampcode.com/threads/T-bf2c0206-7eb1-4546-8dfb-f0485607c3e8

`TermsController` set the slug on every localization, which stored a copy in its data and stopped it following the origin's slug.

Amp-Thread-ID: https://ampcode.com/threads/T-bf2c0206-7eb1-4546-8dfb-f0485607c3e8
Co-authored-by: Duncan McClean <duncan@duncanmcclean.com>
@duncanmcclean
duncanmcclean merged commit 72ed564 into 6.x Nov 17, 2026
65 checks passed
@duncanmcclean
duncanmcclean deleted the 15951 branch November 17, 2026 16:58
joshdaugherty added a commit to UAMS-Web/aether-wordpress-importer that referenced this pull request Nov 24, 2026
Closes #616.

Raises the exact `statamic/cms` pin from `6.42.0` to `6.43.1`, so a
release cut from `main` installs beside `uams-web/patches-statamic-cms`
v1.2.0, which pins `6.43.1`. No other package moves.

## Files

- **edit**
[`composer.json`](https://github.com/UAMS-Web/aether-wordpress-importer/blob/616-statamic-cms-6-43-1/composer.json):
`require.statamic/cms` `6.42.0` to `6.43.1`.
- **edit**
[`composer.lock`](https://github.com/UAMS-Web/aether-wordpress-importer/blob/616-statamic-cms-6-43-1/composer.lock):
`statamic/cms` `v6.42.0` (`3b28f8c`) to `v6.43.1` (`71387ae`), and the
`content-hash`.

## Verification

- `composer update statamic/cms` reported `Lock file operations: 0
installs, 1 update, 0 removals`: `Upgrading statamic/cms (v6.42.0 =>
v6.43.1)`. The lock diff touches only the `statamic/cms` entry and
`content-hash`, so `ueberdosis/tiptap-php` stays where it was. The local
Composer wrote `plugin-api-version` `2.11.0`; that line was restored to
`2.9.0` so the diff carries no tool-version churn. `composer validate
--no-check-publish` reports no lock-file errors.
- Clean install (`vendor/` removed, `composer install`) exit 0, read to
its end: `Patching pestphp/pest-plugin-mutate` lists 15 patch lines and
no failure line, against 15 entries in `patches.json`. Reversing all 15
patches in stack order on a copy of the installed package succeeded for
15 of 15, so each one is applied. Every registered patch targets
`pestphp/pest-plugin-mutate`, none `statamic/cms`.
- Pre-push checks on `9df54f3` (Windows 11): Pint `--test` passed,
Rector dry run clean, `node scripts/run-spell.mjs` 135 files 0 issues,
`check-mutate-ignore-breadth` no annotation flagged outside the
baseline, PHPStan `[OK] No errors`.

### Statamic changes between 6.42.0 and 6.43.1 that touch importer
surfaces

Read from the upstream release notes for `v6.43.0` and `v6.43.1`. None
needs a code change here; each is listed because an import exercises the
area:

- Prevent term localizations from saving a copy of the non-localizable
slug (statamic/cms#15952): term writes in non-default sites.
- Rebuild a collection's entries when its sites change
(statamic/cms#15906).
- Throw an exception when an uploaded file cannot be written to the disk
(statamic/cms#15919): an asset write that failed silently now throws.
- Do not regenerate asset meta when a value is null
(statamic/cms#15978).
- Prevent duplicate field handles across imported fieldsets
(statamic/cms#15933).
- Skip a Stache file that is removed while it is being read
(statamic/cms#15903).

## Behavior change found: re-imported flat terms are not found

Remote CI on `9df54f3` fails `checks / Pest` on ubuntu-latest and
macos-latest: all 5 cases of
`tests/Integration/FlatTermReimportTest.php` (13152 passed, 5 failed, 4
skipped). Reproduced on Windows 11: 5 of 5 fail.

- **Cause:** statamic/cms#15897 (in `v6.43.0`) stops `Store::clear()`
from forgetting which indexes queries have used. Restoring the two
removed lines in the installed `src/Stache/Stores/Store.php` makes all 5
cases pass; with the file as shipped, all 5 fail.
- **Effect on the importer:** after the flat term pass saves,
`rebuildTermStoreFromDisk()` runs `clear()` and `warm()` on the
taxonomy's term store. Under `6.43.1`,
`Term::whereTaxonomy('tags')->count()` then returns `0` while the term
file is on disk and the store's `paths()` lists it; a second `clear()`
and `warm()` returns `1`. So a re-import does not see its existing
terms: `Overwrite matching terms` creates instead of updating, and
`Create an additional term` reuses the base slug.
- This pull request stays a draft until that is resolved.

## Companion PRs

`UAMS-Web/uams-statamic#1248` waits on a release that carries this pin.
Cutting that release is separate and is not part of this pull request.

## Out of scope

- Cutting a release.
- Moving any other package.

## Test plan

- [x] `composer.json` requires `statamic/cms` `6.43.1` and
`composer.lock` locks it; the lock diff changes no other package.
- [x] Clean install read to its end: 15 of 15 registered patches
applied, none failed.
- [x] Pre-push checks pass on `9df54f3`, and again on `b7a2661` after
the sync with `main` (Pint, PHPStan, Rector, cspell,
`check-mutate-ignore-breadth`).
- [x] Remote CI green on the head (Linux, Windows, macOS): [`CI` run
45451223175](https://github.com/UAMS-Web/aether-wordpress-importer/actions/runs/45451223175)
on `b7a2661` succeeded; 45 checks succeeded and 11 were skipped. The end
of each Pest job:

  ```text
ubuntu-latest Tests: 4 skipped, 13172 passed (36771 assertions)
Duration: 274.44s
macos-latest Tests: 3 skipped, 13173 passed (36827 assertions) Duration:
305.43s
windows-latest Tests: 26 skipped, 13150 passed (36619 assertions)
Duration: 491.47s
  ```

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

Saving a term in a non-default site stores a copy of the non-localizable slug, which then stops following the origin

2 participants