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:
9
vendor/rosell-dk/locate-binaries/LICENSE
vendored
Normal file
9
vendor/rosell-dk/locate-binaries/LICENSE
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Bjørn Rosell
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
39
vendor/rosell-dk/locate-binaries/README.md
vendored
Normal file
39
vendor/rosell-dk/locate-binaries/README.md
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# Locate Binaries
|
||||
|
||||
[](https://github.com/rosell-dk/locate-binaries/actions/workflows/php.yml)
|
||||
[](http://little-b.it/locate-binaries/code-coverage/coverage/index.html)
|
||||
[](https://github.com/rosell-dk/locate-binary/blob/master/LICENSE)
|
||||
[](https://packagist.org/packages/rosell-dk/locate-binaries)
|
||||
[](https://php.net)
|
||||
|
||||
Just a little class for locating binaries.
|
||||
You need `exec()`, `shell_exec()` or similar enabled for it to work. Otherwise, it will throw.
|
||||
|
||||
Works on Linux, Windows and Mac.
|
||||
|
||||
## Usage
|
||||
|
||||
To locate installed `cwebp` binaries (found on Linux with `which -a`, falling back to `whereis -b`; on Windows found using `where`):
|
||||
```
|
||||
$cwebBinariesFound = LocateBinaries::locateInstalledBinaries('cwebp');
|
||||
```
|
||||
Note that you get an array of matches - there may be several versions of a binary on a system.
|
||||
|
||||
The library also adds another method for locating binaries by peeking in common system paths, such as *usr/bin* and `C:\Windows\System32`
|
||||
However, beware that these dirs could be subject to open_basedir restrictions which can lead to warning entries in the error log. The other method is therefore best.
|
||||
|
||||
Well warned, here it is the alternative, which you in some cases might want to fall back to after trying the first.
|
||||
```
|
||||
$imagickBinariesFound = LocateBinaries::locateInCommonSystemPaths('convert');
|
||||
```
|
||||
|
||||
## Notes
|
||||
The library uses the [exec-with-fallback](https://github.com/rosell-dk/exec-with-fallback) library in order to be able to use alternatives to exec() when exec() is disabled.
|
||||
|
||||
## Do you like what I do?
|
||||
Perhaps you want to support my work, so I can continue doing it :)
|
||||
|
||||
- [Become a backer or sponsor on Patreon](https://www.patreon.com/rosell).
|
||||
- [Buy me a Coffee](https://ko-fi.com/rosell)
|
||||
|
||||
Thanks!
|
||||
69
vendor/rosell-dk/locate-binaries/composer.json
vendored
Normal file
69
vendor/rosell-dk/locate-binaries/composer.json
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"name": "rosell-dk/locate-binaries",
|
||||
"description": "Locate a binaries by means of exec() or similar",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"keywords": ["locate", "binary", "whereis", "which", "discover"],
|
||||
"scripts": {
|
||||
"ci": [
|
||||
"@test",
|
||||
"@phpcs-all",
|
||||
"@composer validate --no-check-all --strict",
|
||||
"@phpstan"
|
||||
],
|
||||
"phpunit": "phpunit --coverage-text",
|
||||
"test": "phpunit --coverage-text=build/coverage.txt --coverage-clover=build/coverage.clover --coverage-html=build/coverage --whitelist=src tests",
|
||||
"test-no-cov": "phpunit --no-coverage tests",
|
||||
"test-41": "phpunit --no-coverage --configuration 'phpunit-41.xml.dist'",
|
||||
"test-with-coverage": "phpunit --coverage-text --configuration 'phpunit-with-coverage.xml.dist'",
|
||||
"test-41-with-coverage": "phpunit --coverage-text --configuration 'phpunit-41.xml.dist'",
|
||||
"cs-fix-all": [
|
||||
"php-cs-fixer fix src"
|
||||
],
|
||||
"cs-fix": "php-cs-fixer fix",
|
||||
"cs-dry": "php-cs-fixer fix --dry-run --diff",
|
||||
"phpcs": "phpcs --standard=phpcs-ruleset.xml",
|
||||
"phpcs-all": "phpcs --standard=phpcs-ruleset.xml src",
|
||||
"phpcbf": "phpcbf --standard=PSR2",
|
||||
"phpstan": "vendor/bin/phpstan analyse src --level=4",
|
||||
"phpstan-global-old": "~/.composer/vendor/bin/phpstan analyse src --level=4",
|
||||
"phpstan-global": "~/.config/composer/vendor/bin/phpstan analyse src --level=4"
|
||||
},
|
||||
"extra": {
|
||||
"scripts-descriptions": {
|
||||
"ci": "Run tests before CI",
|
||||
"phpcs": "Checks coding styles (PSR2) of file/dir, which you must supply. To check all, supply 'src'",
|
||||
"phpcbf": "Fix coding styles (PSR2) of file/dir, which you must supply. To fix all, supply 'src'",
|
||||
"cs-fix-all": "Fix the coding style of all the source files, to comply with the PSR-2 coding standard",
|
||||
"cs-fix": "Fix the coding style of a PHP file or directory, which you must specify.",
|
||||
"test": "Launches the preconfigured PHPUnit"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "LocateBinaries\\": "src/" }
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": { "LocateBinaries\\Tests\\": "tests/" }
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Bjørn Rosell",
|
||||
"homepage": "https://www.bitwise-it.dk/contact",
|
||||
"role": "Project Author"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.6",
|
||||
"rosell-dk/exec-with-fallback": "^1.0.0",
|
||||
"rosell-dk/file-util": "^0.1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^2.11",
|
||||
"phpunit/phpunit": "^9.3",
|
||||
"squizlabs/php_codesniffer": "3.*",
|
||||
"phpstan/phpstan": "^1.5"
|
||||
},
|
||||
"config": {
|
||||
"sort-packages": true
|
||||
}
|
||||
}
|
||||
8
vendor/rosell-dk/locate-binaries/phpcs-ruleset.xml
vendored
Normal file
8
vendor/rosell-dk/locate-binaries/phpcs-ruleset.xml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0"?>
|
||||
<ruleset name="Custom Standard">
|
||||
<description>PSR2 without line ending rule - let git manage the EOL cross the platforms</description>
|
||||
<rule ref="PSR2" />
|
||||
<rule ref="Generic.Files.LineEndings">
|
||||
<exclude name="Generic.Files.LineEndings.InvalidEOLChar"/>
|
||||
</rule>
|
||||
</ruleset>
|
||||
163
vendor/rosell-dk/locate-binaries/src/LocateBinaries.php
vendored
Normal file
163
vendor/rosell-dk/locate-binaries/src/LocateBinaries.php
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace LocateBinaries;
|
||||
|
||||
use FileUtil\FileExists;
|
||||
use ExecWithFallback\ExecWithFallback;
|
||||
|
||||
/**
|
||||
* Locate path (or multiple paths) of a binary
|
||||
*
|
||||
* @package LocateBinaries
|
||||
* @author Bjørn Rosell <it@rosell.dk>
|
||||
*/
|
||||
class LocateBinaries
|
||||
{
|
||||
|
||||
/**
|
||||
* Locate binaries by looking in common system paths.
|
||||
*
|
||||
* We try a small set of common system paths, such as "/usr/bin".
|
||||
* On Windows, we only try C:\Windows\System32
|
||||
* Note that you do not have to add ".exe" file extension on Windows, it is taken care of
|
||||
*
|
||||
* @param string $binary the binary to look for (ie "cwebp")
|
||||
*
|
||||
* @return array binaries found in common system locations
|
||||
*/
|
||||
public static function locateInCommonSystemPaths($binary)
|
||||
{
|
||||
$binaries = [];
|
||||
|
||||
$commonSystemPaths = [];
|
||||
|
||||
if (stripos(PHP_OS, 'WIN') === 0) {
|
||||
$commonSystemPaths = [
|
||||
'C:\Windows\System32',
|
||||
];
|
||||
$binary .= '.exe';
|
||||
} else {
|
||||
$commonSystemPaths = [
|
||||
'/usr/bin',
|
||||
'/usr/local/bin',
|
||||
'/usr/gnu/bin',
|
||||
'/usr/syno/bin',
|
||||
'/bin',
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($commonSystemPaths as $dir) {
|
||||
// PS: FileExists might throw if exec() or similar is unavailable. We let it.
|
||||
// - this class assumes exec is available
|
||||
if (FileExists::fileExistsTryHarder($dir . DIRECTORY_SEPARATOR . $binary)) {
|
||||
$binaries[] = $dir . DIRECTORY_SEPARATOR . $binary;
|
||||
}
|
||||
}
|
||||
return $binaries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate installed binaries using ie "whereis -b cwebp" (for Linux, Mac, etc)
|
||||
*
|
||||
* @return array Array of paths locateed (possibly empty)
|
||||
*/
|
||||
private static function locateBinariesUsingWhereIs($binary)
|
||||
{
|
||||
$isMac = (PHP_OS == 'Darwin');
|
||||
$command = 'whereis ' . ($isMac ? '' : '-b ') . $binary . ' 2>&1';
|
||||
|
||||
ExecWithFallback::exec($command, $output, $returnCode);
|
||||
//echo 'command:' . $command;
|
||||
//echo 'output:' . print_r($output, true);
|
||||
|
||||
if (($returnCode == 0) && (isset($output[0]))) {
|
||||
// On linux, result looks like this:
|
||||
// "cwebp: /usr/bin/cwebp /usr/local/bin/cwebp"
|
||||
// or, for empty: "cwebp:"
|
||||
|
||||
if ($output[0] == ($binary . ':')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// On mac, it is not prepended with name of binary.
|
||||
// I don't know if mac returns one result per line or is space seperated
|
||||
// As I don't know if some systems might return several lines,
|
||||
// I assume that some do and convert to space-separation:
|
||||
$result = implode(' ', $output);
|
||||
|
||||
// Next, lets remove the prepended binary (if exists)
|
||||
$result = preg_replace('#\b' . $binary . ':\s?#', '', $result);
|
||||
|
||||
// And back to array
|
||||
return explode(' ', $result);
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* locate installed binaries using "which -a cwebp"
|
||||
*
|
||||
* @param string $binary the binary to look for (ie "cwebp")
|
||||
*
|
||||
* @return array Array of paths locateed (possibly empty)
|
||||
*/
|
||||
private static function locateBinariesUsingWhich($binary)
|
||||
{
|
||||
// As suggested by @cantoute here:
|
||||
// https://wordpress.org/support/topic/sh-1-usr-local-bin-cwebp-not-found/
|
||||
ExecWithFallback::exec('which -a ' . $binary . ' 2>&1', $output, $returnCode);
|
||||
if ($returnCode == 0) {
|
||||
return $output;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate binaries using where.exe (for Windows)
|
||||
*
|
||||
* @param string $binary the binary to look for (ie "cwebp")
|
||||
*
|
||||
* @return array binaries found
|
||||
*/
|
||||
private static function locateBinariesUsingWhere($binary)
|
||||
{
|
||||
ExecWithFallback::exec('where.exe ' . $binary . ' 2>&1', $output, $returnCode);
|
||||
if ($returnCode == 0) {
|
||||
return $output;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate installed binaries
|
||||
*
|
||||
* For linuk, we use "which -a" or, if that fails "whereis -b"
|
||||
* For Windows, we use "where.exe"
|
||||
* These commands only searces within $PATH. So it only finds installed binaries (which is good,
|
||||
* as it would be unsafe to deal with binaries found scattered around)
|
||||
*
|
||||
* @param string $binary the binary to look for (ie "cwebp")
|
||||
*
|
||||
* @return array binaries found
|
||||
*/
|
||||
public static function locateInstalledBinaries($binary)
|
||||
{
|
||||
if (stripos(PHP_OS, 'WIN') === 0) {
|
||||
$paths = self::locateBinariesUsingWhere($binary);
|
||||
if (count($paths) > 0) {
|
||||
return $paths;
|
||||
}
|
||||
} else {
|
||||
$paths = self::locateBinariesUsingWhich($binary);
|
||||
if (count($paths) > 0) {
|
||||
return $paths;
|
||||
}
|
||||
|
||||
$paths = self::locateBinariesUsingWhereIs($binary);
|
||||
if (count($paths) > 0) {
|
||||
return $paths;
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user