Issue #3632550: hook_webform_presave() silently enables draft purging and changes purge settings

Closes #3632550

Changes

  • hook_webform_presave() no longer changes purge or purge_days. Enabling auto-save or optimistic locking never enables deletion of submission data.
  • Drafts (for auto-save) and the submission log (for optimistic locking) are still enabled automatically. A status message names each setting that was changed. No message is shown during config sync or when nothing changed.
  • The third-party settings form shows a warning, with a link to the Submissions settings, when auto-save is checked and drafts are not being purged. Optimistic locking on its own doesn't create a draft on every visit, so it doesn't trigger the warning.
  • The initial draft created in hook_webform_submission_form_alter() now depends only on drafts being enabled, not on the purge setting. Existing webforms behave the same, since the old presave hook always forced purging on. Whether that draft should be created during a GET at all is left to #3632552.
  • README explains what is enabled automatically and recommends purging drafts.

Release note

Webform Autosave no longer enables purging or sets a purge period when a webform is saved. Existing webforms keep whatever purge settings they already have; nothing is changed retroactively. When auto-save is enabled, a warning in the webform's third-party settings now recommends enabling draft purging.

Testing

  • AutosaveSettingsTest (kernel): purge settings are left untouched, notices are shown for each changed setting, and re-saving is silent. testConfigSyncIsSilent checks that a config import still enables the needed settings without showing a message, and fails without the isSyncing() check.
  • AutosaveFormTest::testInitialDraft (functional, existing): runs with purging off, so it covers the initial draft no longer depending on the purge setting.
  • WebformAutosaveThirdPartySettingsTest::testPurgeWarning (functional): the warning appears when drafts are not purged, saving the form keeps the purge setting, and the warning is hidden once drafts are purged.
Edited by Ryan McVeigh

Merge request reports

Loading
Loading