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:
60
lib/classes/KeepEwwwSubscriptionAlive.php
Normal file
60
lib/classes/KeepEwwwSubscriptionAlive.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace WebPExpress;
|
||||
|
||||
use \WebPExpress\Config;
|
||||
use \WebPExpress\Messenger;
|
||||
use \WebPExpress\State;
|
||||
use \WebPConvert\Converters\Ewww;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
class KeepEwwwSubscriptionAlive
|
||||
{
|
||||
public static function keepAlive($config = null) {
|
||||
include_once __DIR__ . '/../../vendor/autoload.php';
|
||||
|
||||
if (is_null($config)) {
|
||||
$config = Config::loadConfigAndFix(false); // false, because we do not need to test if quality detection is working
|
||||
}
|
||||
|
||||
$ewww = Config::getConverterByName($config, 'ewww');
|
||||
if (!isset($ewww['options']['key'])) {
|
||||
return;
|
||||
}
|
||||
if (!$ewww['working']) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ewwwConvertResult = Ewww::keepSubscriptionAlive(__DIR__ . '/../../test/very-small.jpg', $ewww['options']['key']);
|
||||
if ($ewwwConvertResult === true) {
|
||||
Messenger::addMessage(
|
||||
'info',
|
||||
'Successfully optimized regular jpg with <i>ewww</i> converter in order to keep the subscription alive'
|
||||
);
|
||||
State::setState('last-ewww-optimize', time());
|
||||
} else {
|
||||
Messenger::addMessage(
|
||||
'warning',
|
||||
'Failed optimizing regular jpg with <i>ewww</i> converter in order to keep the subscription alive'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function keepAliveIfItIsTime($config = null) {
|
||||
|
||||
$timeSinseLastSuccesfullOptimize = time() - State::getState('last-ewww-optimize', 0);
|
||||
if ($timeSinseLastSuccesfullOptimize > 3 * 30 * 24 * 60 * 60) {
|
||||
|
||||
$timeSinseLastOptimizeAttempt = time() - State::getState('last-ewww-optimize-attempt', 0);
|
||||
if ($timeSinseLastOptimizeAttempt > 14 * 24 * 60 * 60) {
|
||||
State::setState('last-ewww-optimize-attempt', time());
|
||||
self::keepAlive($config);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user