Skip to content

Logger cron fatals on PHP 7.4 when Optimole settings are absent #1099

Description

@pirate-bot

Summary

Optimole's logger cron can terminate with TypeError: Return value of Optml_Main::add_settings() must be of the type array, null returned when the plugin has no stored settings. The logger callback is expected to return an array so the scheduled telemetry request can complete. Instead, the WP-CLI cron request exits with an uncaught exception, preventing that cron event from completing.

Customer context

  • Product / area: Optimole logger cron
  • Version: Optimole 4.2.10; ThemeIsle SDK 3.3.58 and 3.3.59 observed
  • Environment: PHP 7.4.33; WordPress 6.8.6, 6.9.5, and 7.0.2; WP-CLI cron requests
  • Integration / third party: ThemeIsle SDK logger
  • Reported error / symptom: TypeError: Return value of Optml_Main::add_settings() must be of the type array, null returned
  • Impact: 465 occurrences across 311 distinct sites in the telemetry window; the affected cron invocation terminates

Reproduction notes

Reported production path:

  1. Use Optimole 4.2.10 on PHP 7.4.33 with logging active and no stored optml_settings option.
  2. Run the product logger cron event through WP-CLI.
  3. ThemeIsle SDK applies optimole_wp_logger_data, invoking Optml_Main::add_settings().
  4. The callback emits the captured return-type TypeError, and the cron request terminates.

The failure is confirmed by telemetry and source inspection; it was not reproduced in a local WordPress runtime during this investigation.

Diagnosis

Conclusion

The defect is confirmed in Optimole 4.2.10. Optml_Main::add_settings() passes the raw option value directly to array_merge(), while Optml_Settings::get_raw_settings() returns false when optml_settings does not exist. On the reported PHP 7.4 runtime, that invalid merge returns null after a warning, which violates the callback's declared array return type and matches the production exception. The stack trace identifies this product callback rather than ThemeIsle SDK code.

Where this likely occurs

  • Logger registration: inc/main.phpOptml_Main::instance() approx. lines 96–110 registers Optml_Main::add_settings() on optimole_wp_logger_data.
  • Failing callback: inc/main.phpOptml_Main::add_settings() lines 152–165 reads raw settings and merges them without validating that both values are arrays.
  • Missing-option path: inc/settings.phpOptml_Settings::__construct() lines 130–142 uses the default schema for normal in-memory settings but does not persist it merely by constructing the object.
  • Raw settings contract: inc/settings.phpOptml_Settings::get_raw_settings() lines 780–787 calls get_option(..., false), allowing false despite its array PHPDoc.
  • Git history: commit 8716dd792bffbbef1dbae21e5eaab8edd5535091 introduced the filter and callback on 2025-08-18. The relevant files are unchanged between tags v4.2.9 and v4.2.10.

Engineering notes

The representative ThemeIsle SDK 3.3.58 source was checked externally and its Logger::send_log() invokes the product logger-data filter with an empty array. This supports routing to Optimole: the invalid merge operand comes from the product's raw settings read. Runtime reports also include SDK 3.3.59, whose source was not available through the inspected reference. The observed crashes are limited to PHP 7.4.33 and CLI context in the supplied telemetry; behavior on PHP 8 was not runtime-tested here and may surface as a different array_merge() type error. A fresh install, deleted option, or another state where optml_settings is absent can reach this path.

Test coverage status

No unit, integration, or e2e test covering Optml_Main::add_settings(), optimole_wp_logger_data, or an absent raw settings option was found during inspection. Existing test references to Optml_Main do not exercise this logger callback.

What to verify or explore next

  • Reproduce with PHP 7.4.33 by running the Optimole logger event through WP-CLI while optml_settings is absent.
  • Compare the same scenario on supported PHP 8 versions and record whether the failure moves to array_merge() argument validation.
  • Run the relevant PHP unit suite with cases for absent, malformed, and valid optml_settings values.
  • Confirm the packaged SDK 3.3.59 Logger::send_log() filter input against the 3.3.58 reference.

Unknowns / follow-up

The telemetry does not identify why the option was absent on each affected site or whether all 311 sites shared the same lifecycle state.

Confidence

Confidence: 97/100

Production telemetry confirms 465 uncaught exceptions across 311 sites, and the 4.2.10 source exposes the PHP 7.4 failure path when the Optimole settings option is absent. No matching GitHub issue was found.

Crash telemetry

Occurrences 465
Distinct sites 311
First seen 2026-07-29 12:45 UTC
Last seen 2026-07-30 10:15 UTC
Crash location product:inc/main.php:164
Request context cli
Inside Themeisle SDK no
Product versions 4.2.10
WP versions 6.8.6, 6.9.5, 7.0.2
PHP versions 7.4.33
SDK versions 3.3.58, 3.3.59

Source: automated crash report — optimole-wp, fingerprint dfacaeffb739cd0193a65e0860c571a8
Generated by bug-report-triage (ID: bug-report-triage_6a6b3c2d4e7b09.37142254)

Metadata

Metadata

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions