WebP Express CloudHost.es Fix v0.25.9-cloudhost

 Fixed bulk conversion getting stuck on missing files
 Added robust error handling and timeout protection
 Improved JavaScript response parsing
 Added file existence validation
 Fixed missing PHP class imports
 Added comprehensive try-catch error recovery

🔧 Key fixes:
- File existence checks before conversion attempts
- 30-second timeout protection per file
- Graceful handling of 500 errors and JSON parsing issues
- Automatic continuation to next file on failures
- Cache busting for JavaScript updates

🎯 Result: Bulk conversion now completes successfully even with missing files

🚀 Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-09-23 10:22:32 +02:00
commit 37cf714058
553 changed files with 55249 additions and 0 deletions

45
lib/classes/State.php Normal file
View File

@@ -0,0 +1,45 @@
<?php
namespace WebPExpress;
use \WebPExpress\Option;
/**
* Store state in db
* We are using update_option WITHOUT autoloading.
* So this class is not intended for storing stuff that is needed on every page load.
* For such things, use update_option / get_option directly
*/
class State
{
public static function getStateObj() {
// TODO: cache
$json = Option::getOption('webp-express-state', '[]');
return json_decode($json, true);
}
/**
* Return state by key. Returns supplied default if key doesn't exist, or state object is corrupt
*/
public static function getState($key, $default = null) {
$obj = self::getStateObj();
if ($obj != false) {
if (isset($obj[$key])) {
return $obj[$key];
}
}
return $default;
}
public static function setState($key, $value) {
$currentStateObj = self::getStateObj();
$currentStateObj[$key] = $value;
$json = json_encode($currentStateObj, JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
// Store in db. No autoloading.
Option::updateOption('webp-express-state', $json, false);
}
}