Changes for version 0.27 - 2026-12-02
- Incompatible Changes
- Config files larger than 16K (16384 bytes) are now refused. configure() croaks with "config file is too large (SIZE bytes; the limit is 16384 bytes)" before parsing the file, and a hot reload of a file that has grown past the limit warns and keeps the object's current settings. This applies to ancestor class files and universal.yml too. If you keep large data in a config file, move it to a separate file and put its path in the config.
- Enhancements
- New optional 'cache' argument to configure() and instantiate(): pass any object with get() and set() (CHI, Cache::Cache, Cache::Memcached ...) and parsed config files are reused while nothing that affects them has changed: about 3x faster configure() for a two-file hierarchy. The cache key covers the file, every other file read for it, the class's environment variables, the environment name, --CLASS__key=value arguments, the current directory and module versions. Without 'cache', nothing changes. If the cache fails, a warning is given and the files are parsed as before. Cached values are decrypted, so use an in-memory cache if your config holds encrypted secrets.
- Performance: configure() without a config file (environment variables only) is about 23% faster. It built two identical Config::Abstraction parsers for the class itself; each one searches every default config directory. Results are unchanged.
- register_object() now removes references to objects that no longer exist as its list grows. Before, they were only removed when SIGUSR1 arrived, so a long-running program that registered short-lived objects (for example one per request via instantiate()) and never reloaded used more memory for every object it ever made. 100,000 short-lived registrations now leave 19 entries instead of 100,000.
- Hot reload now re-reads every file an object was configured from (universal.yml, ancestor class files and its own files) and merges them base-first, as configure() did. Previously only the most specific file was re-read, so edits to an ancestor's file or to universal.yml triggered a reload but were ignored until restart. configure() records the section each file was read with in a new _config_sections key, parallel to _config_files. Objects built by hand without it keep the old behaviour.
- Each config file is parsed once per reload, however many objects use it, instead of once per object. The parsers are kept between reloads and refreshed with Config::Abstraction's reload() when it is available (0.44 and later, now a recommended dependency); with 0.38 to 0.43 a new parser is built each time, as before.
- SIGUSR1 is shared properly with other code (daisy chaining). A handler that was in $SIG{USR1} before the first object was registered is now always called after Object::Configure's own work, even if the reload or the hot-reload callback dies (that failure is reported as "Object::Configure: hot reload failed: ERROR" or the existing callback warning). A handler given as a sub name, such as 'main::on_usr1' or 'on_usr1', is now called; before, it was skipped with a "Cannot chain" warning. That warning is now given only for a name with no sub behind it.
- At program exit the previous SIGUSR1 handler is put back (in the DESTROY of an internal guard object), but only if Object::Configure's handler is still the installed one. Previously the exit-time restore was unconditional, which removed any handler that other code had installed on top of ours. An explicit call to restore_signal_handlers() still restores unconditionally.
- Bug Fixes
- get_signal_handler_info() reported hot_reload_active as true on Windows after register_object(), although hot reload does not run there. It is now always false on Windows.
- With the new 'cache' argument, changing a class's environment variable (CLASS__key) did not invalidate its cached settings on Windows, or on any platform when the variable's name was written in a different case (CLASS__KEY): the cache key matched names case- sensitively, but Config::Abstraction reads them in any case, and Windows reports every name in upper case.
- A program that had enabled hot reload usually exited with status 15 (or sometimes 9) instead of its real exit status: stopping the watcher at program end overwrote $?. disable_hot_reload() now leaves $? alone, so "exit 0" exits 0 again.
- Stopping the watcher (disable_hot_reload(), restore_signal_handlers() or program end) took five seconds about one time in ten. The watcher's SIGTERM handler was a Perl sub, which could miss a signal that arrived just before it went to sleep, so it was only killed after the five-second timeout. The watcher now uses SIGTERM's default action and stops at once.
- Calling enable_hot_reload() before any object was registered (with register_object() or instantiate()) left SIGUSR1 unhandled, so the first edit to a config file ended the program. enable_hot_reload() now installs the handler itself.
- restore_signal_handlers() now also stops the watcher. Before, the watcher kept running, and its next SIGUSR1 met the restored handler; if that was DEFAULT, the program ended.
- The watcher process now exits when the program that started it dies without stopping it (POSIX::_exit, SIGKILL, a crash). Before, it ran forever, and sent SIGUSR1 to whatever process adopted it (init, or a session manager such as systemd --user). An orphaned watcher also kept inherited pipes open, which made a test harness wait forever.
- Security (Windows): the path-traversal check on config_file (and on config_path and hot-reload paths) could be bypassed on Windows. Windows treats \ as a separator and strips trailing dots and spaces from each path component, so "...", ".. " and "..\x.yml" all reach the parent directory, but only "../" with exactly two dots was refused. On Windows those forms are now refused too. Unix is unchanged: there "..." and backslashes are ordinary filename characters.
- instantiate() no longer dies with the internal message "register_object: Usage ($class, $obj)" (or "$obj must be a blessed reference") when the class's new() returns undef or an unblessed reference and a config file was loaded. The value new() returned is now passed back to you unregistered, so a constructor that signals failure by returning undef can be checked as usual.
- configure() no longer modifies the hash you pass it. When a config file was loaded, coderefs and arrayref loggers were deleted from your args hash and never put back, so code that re-used one args hash for several constructors lost them after the first call.
- A config_file given as a bare name (e.g. 'my-child.yml', relative to the current directory) now finds ancestor config files in the same directory. Previously they were looked for in the root directory, so values from base-class files were silently missing.
- A config file found through config_dirs is now watched for hot reload. Previously it was loaded but edits to it were never noticed.
- croak_on_error is now honoured. It was documented but ignored. It is passed to Log::Abstraction only when you set it, so the default behaviour (error() does not croak) is unchanged; the POD wrongly said the default was 1.
- The hot-reload watcher now notices a file replaced by an older copy (cp -p, rsync -t, a VCS checkout) or changed in size within the same second; it compares mtime, size and inode instead of only "mtime is newer". A file that an editor deletes and re-creates is no longer dropped from the watch list for good.
- The watcher child now exits with POSIX::_exit, so your program's END blocks and destructors no longer run a second time in the child (which could close shared database handles or remove temp files).
- enable_hot_reload() is now a no-op on Windows, as documented. Previously it started a pseudo-process that polled forever.
- reload_config() now counts only objects that actually had a config file re-read, as documented.
- _config_file is now set only when a config file was really loaded, as documented, and holds the full path when the file was found through config_dirs. Previously it held whatever name you passed even if nothing was found, so instantiate() registered the object for hot reload of a file that did not exist.
- A hot-reload callback that dies no longer throws out of the SIGUSR1 handler into whatever code happened to be running; the error is reported with carp and the reload carries on. A previously installed coderef handler is now passed the signal name when it is chained, as Perl itself would pass it.
- disable_hot_reload() now always clears the watcher state. If the recorded pid was missing or 0 the state was left behind, and enable_hot_reload() then refused ever to start a watcher again.
- configure(), instantiate() and reload_config() no longer change your $!. Missing-file probes left it set to ENOENT, and because reload_config() runs from the SIGUSR1 handler, $! could change under unrelated code at any moment.
- The "CLASS: FILE: OS-ERROR" croak for an existing but unreadable config_file now always says "Permission denied" (in your locale). It used to show whatever $! happened to hold beforehand, which could be an unrelated error or nothing at all.
- configure() no longer crashes ("Can't use string as a HASH ref") when a config file is found but no installed parser can read it, for example a YAML-style .conf without YAML::XS. The file is now skipped with "Warning: Can't load configuration from FILE: no settings could be read", and your other values are kept. Hot reload of such a file leaves the object unchanged.
- A logger that dies while logging "Configuration reloaded" no longer makes reload_config() report the reload as failed; the new settings were already applied.
- config_dirs => [] (an empty list) now croaks for a missing config_file, as leaving config_dirs out does, instead of silently loading nothing.
- Changes
- logger => 'NULL', a logger object or a coderef now always wins, as arrayrefs already did. Previously a logger: section in a site file such as ~/.conf/local.yaml or universal.yml could replace them, so an explicit 'NULL' could still produce logging, and only when no config_file was given. A hashref logger is unchanged: it is options, and a config file's logger: section still overrides its keys.
- Error messages for an unreadable or path-traversing config_file now name the class as My::Class rather than My__Class. If you match on the old form, update your pattern.
- configure($class, %args) (a hash instead of a hashref) now croaks with "params must be a hash reference" instead of Perl's "Not a HASH reference".
- enable_hot_reload() croaks if callback is given but is not a code reference, instead of failing later inside the SIGUSR1 handler.
- configure() croaks with "config_dirs must be an array reference" when config_dirs is a string, instead of Perl's "Can't use string as an ARRAY ref".
- Documentation fixes and new LIMITATIONS entries (hot reload re-reads only the most specific file; removed keys stay on the object; the watcher only knows files loaded before it started).
Documentation
Modules
Runtime Configuration for an Object
Provides
in lib/Object/Configure.pm