Skip to content

Integer field: setting a default value always triggers change detection in hook #1837

Open
@hiboudev

Description

@hiboudev

Short description of the issue

Default value of Integer field triggers change detection in hook.

Steps to reproduce the issue

  1. Create an Integer field with a default value (zero).
  2. Add the field to a page.
  3. Create a saveReady hook:
$this->addHookBefore('Pages::saveReady',
  function (HookEvent $event): void {
      /** @var Page $page */
      $page = $event->arguments(0);

      $changes = $page->getChanges(true);
      
      if ($changes) {
        var_dump($changes);
        exit();
      }
  }
);
  1. Save the page without any change and see that there is a change detected on the Integer field.
  2. Edit the Integer field configuration and remove the default value.
  3. Save the page without any change and see that no change is detected anymore.

Setup/Environment

  • ProcessWire version: 3.0.228

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions