diff --git a/CCache.php b/CCache.php index 7a35900..4376e5c 100644 --- a/CCache.php +++ b/CCache.php @@ -51,6 +51,15 @@ class CCache return $path; } + if ($create && defined('WINDOWS2WSL')) { + // Special case to solve Windows 2 WSL integration + $path = $this->path . "/" . $subdir; + + if (mkdir($path)) { + return realpath($path); + } + } + if ($create && is_writable($this->path)) { $path = $this->path . "/" . $subdir; diff --git a/CImage.php b/CImage.php index df7fb98..b6b3b6c 100644 --- a/CImage.php +++ b/CImage.php @@ -964,8 +964,11 @@ class CImage { $file = $file ? $file : $this->pathToImage; - is_readable($file) - or $this->raiseError('Image file does not exist.'); + // Special case to solve Windows 2 WSL integration + if (!defined('WINDOWS2WSL')) { + is_readable($file) + or $this->raiseError('Image file does not exist.'); + } $info = list($this->width, $this->height, $this->fileType) = getimagesize($file); if (empty($info)) { diff --git a/REVISION.md b/REVISION.md index afc6ceb..a740ae9 100644 --- a/REVISION.md +++ b/REVISION.md @@ -5,6 +5,14 @@ Revision history [![Build Status](https://scrutinizer-ci.com/g/mosbth/cimage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/mosbth/cimage/build-status/master) +v0.8.5 (2022-11-17) +------------------------------------- + +* Enable configuration fix for solving Windows 2 WSL2 issue with is_readable/is_writable #189. +* Update CHttpGet.php for php 8.1 deprecated notice #188. + + + v0.8.4 (2022-05-30) ------------------------------------- diff --git a/webroot/img_config.php b/webroot/img_config.php index 1e59728..17b9574 100644 --- a/webroot/img_config.php +++ b/webroot/img_config.php @@ -21,6 +21,15 @@ if (!defined("CIMAGE_DEBUG")) { define("CIMAGE_DEBUG_FILE", "/tmp/cimage"); } +/** + * Set this if you work with a webserver in Windows and try to access files + * within WSL2. + * The issue seems to be with functions like `is_writable()` and + * `is_readable()`. + * When WINDOWS2WSL is defined (to any value) it ignores these functions. + */ +#define('WINDOWS2WSL', 1); + return array(