• Resolved halshaky

    (@halshaky)


    I’m seeing this in our PHP error log when replacing an image:

    PHP message: PHP Warning: is_dir(): open_basedir restriction in effect. File(/wp-content/uploads/2025/09/headshot) is not within the allowed path(s): (/www/USERNAME/public:/www/USERNAME/mysqleditor:/www/USERNAME/web:/www/USERNAME/deploy:/www/USERNAME/deployment:/www/USERNAME/deployments:/www/USERNAME/tmp:/usr/share:/tmp:/www/USERNAME/marketo_env:/dev/urandom) in /www/USERNAME/public/wp-content/plugins/enable-media-replace/build/shortpixel/replacer/src/Replacer.php on line 87" while reading response header from upstream, client: 127.0.0.1, server: www.domain.com, request: "POST /wp-admin/upload.php?page=enable-media-replace/enable-media-replace.php&action=media_replace_upload&attachment_id=128797 HTTP/2.0", upstream: "fastcgi://unix:/var/run/php8.3-fpm-resolvercom.sock:", host: "www.domain.com:59087", referrer: "https://www.domain.com/wp-admin/upload.php?page=enable-media-replace%2Fenable-media-replace.php&action=media_replace&attachment_id=128797

    I spoke with my host and they say it’s because File(/wp-content/uploads/2025/09/headshot) is not within the allowed path(s) doesn’t have the absolute path that includes /www/USERNAME/public/.

    Images get replaced just fine, it’s just that this error will always show in the error log whenever I do a replacement.

    (Username, IP, and domain have been obfuscated by me for this post.)

Viewing 1 replies (of 1 total)
  • Plugin Support Gerard Blanco

    (@sixaxis)

    Hi halshaky,

    When the plugin replaces the path of the old images with the new path, several things need to be checked. For a faulty website, it’s possible that the end result of the source image path is a directory (i.e. the image metadata is empty, corrupted or something else caused by other plugins). Let’s imagine the source was /var/www/site/wp-content/uploads/2024/05, in which case all images in that directory would be replaced with the new image, and that would corrupt a lot of post content.

    To prevent this, we check if something exists that shouldn’t exist, and if that’s the case, we abort the process. On basedir-sensitive websites, however, this leads to a basedir warning, because the correct input here should be a relative and not a full path. In any case, don’t worry, it’s just a warning and not an error.

    I hope that clarifies the matter 🙂

    Best,

Viewing 1 replies (of 1 total)

The topic ‘PHP warning whenever I replace an image’ is closed to new replies.