warn("The schema high-water record (option " . self::OPTION . ") held an unreadable value (" . (is_string($raw) ? '"' . $raw . '"' : gettype($raw)) . "); replaced it with " . $version . "."); update_option(self::OPTION, $version, false); return; } if ($stored === '' || version_compare($stored, $version, '<')) { update_option(self::OPTION, $version, false); } } /** * Whether a newer version than the given one has already shaped the schema. * An empty or missing record never blocks: a site that never ran a build * writing the record has no evidence of a newer schema. An unreadable record * always blocks, because a newer build may have written it. * * @param string $version The running plugin version. * @return bool True when the record is unreadable, or exists and is newer than $version. */ public static function isNewerThan(string $version): bool { $recorded = self::read(); if ($recorded === null) { return true; } return $recorded !== '' && version_compare($version, $recorded, '<'); } }