Skip to content

v0.3.0

Choose a tag to compare

@Amorfx Amorfx released this 12 Oct 21:45
bd8722b

⚠️ Upgrading

  1. Composer constraints of your project (root composer.json, created from the boilerplate):

    • clementdecou/simply-framework: ^0.3;
    • clementdecou/simply-maker: ^0.4;
    • clementdecou/simply-mvc (if installed): ^0.3;
    • symfony/dotenv: ^7.4.

    Then run composer update -W. Any other package of the project that requires Symfony 6 blocks the update. WordPress plugins that bundle an unscoped copy of Symfony load the same classes as Simply, so check them as well.

  2. Your own code extending Symfony classes (in your plugins and theme src/):

    • Console commands: replace protected static $defaultName with #[AsCommand(name: '…', description: '…')] and declare execute(...): int. Simply Maker registers every command it finds, so a single command without a name breaks the whole bin/console.
    • Configuration classes: declare getConfigTreeBuilder(): TreeBuilder. Otherwise the container build fails on the first request.
    • ContainerAwareInterface and ContainerAwareTrait no longer exist: inject the services you need.
    • See Symfony's UPGRADE-7.0 for the other changes.
  3. Check on a staging environment: run php bin/console list and load a few pages before deploying.

There is no need to clear the cache for the upgrade itself: the new package versions change the cache fingerprint.

⚠️ Breaking changes

Symfony 7.4 is required

symfony/dependency-injection, symfony/config, symfony/finder and symfony/yaml now require ^7.4. Use simply-maker 0.4 and simply-mvc 0.3, which require this version.

Cache (#74)

  • The container and Twig templates are cached in SIMPLY_CACHE_DIRECTORY/<fingerprint>/. The fingerprint is computed from the installed Composer packages, the configuration directories, the registered plugins and theme, and WP_DEBUG. Updating a package, switching theme or adding a configuration directory rebuilds the cache automatically. When the cache is rebuilt, caches of other fingerprints that have not been modified for an hour are removed.
  • The cached container class is now CachedContainer_<fingerprint> instead of CachedContainer.
  • Code changes that Composer does not see (your services, YAML configuration, Twig templates) still require php bin/console simply:cache:clear when deploying with WP_DEBUG set to false.

Hooks declared with #[Action] and #[Filter] (#75)

  • Services are resolved lazily: a service holding attribute hooks is instantiated the first time WordPress runs one of its hooks, no longer on every request. Its constructor runs at that moment.
  • The WordPress callback is a Simply\Core\Hook\LazyHookListener, no longer [$service, 'method']. remove_action() and has_filter() called with [$service, 'method'] no longer find these hooks.
  • A service whose id is not its class name, and several services of the same class, now get their hooks.
  • The container build now fails with an explicit message when an attribute method is not public or takes a parameter by reference.
  • Removed:
    • Simply\Core\Compiler\HookCompiler;
    • Action::setCallable(), Action::register(), Filter::setCallable() and Filter::register(). Action and Filter are plain attributes and no longer implement HookableInterface;
    • the simply.compile_hooks container parameter.
  • HookManager::__construct() now takes the attribute hooks and a service locator.

HookableInterface and the wp.hook tag are unchanged.

New

  • simply:debug:hook is now available in bin/console. It was never registered before. It resolves closures, invokable objects and lazy attribute hooks, and shows the service id when it differs from the class.
  • Hook services may use ServiceMethodsSubscriberTrait. ServiceSubscriberTrait is deprecated by Symfony but still supported.
  • With PHP 8.4, lazy services use native lazy objects and no longer emit var-exporter deprecations.

What's Changed

  • feat(cache): rebuild the cache reliably when its inputs change by @Amorfx in #74
  • refactor(hook): register attribute hooks by service id and lazily by @Amorfx in #75
  • feat(core)!: require Symfony 7.4 by @Amorfx in #76

Full Changelog: v0.2.8...v0.3.0