processwire-issues icon indicating copy to clipboard operation
processwire-issues copied to clipboard

Call to undefined function chmod (php8 disable_functions)

Open v-maillard opened this issue 1 year ago • 1 comments

Short description of the issue

On a web host I'm testing (www.lautre.net), I get a fatal error "Call to undefined function chmod()". It's linked to the files wire/core/FileCompiler.php on line 230 and wire/core/WireFileTools.php on lines 201, 207 and 215. I think this is happening because the host has added chmod to "disable_functions".

Expected behavior

Check if chmod() exists.

Actual behavior

Call to undefined function chmod()

Suggestion for a possible fix

I found the same issue on the git of an open-source web publishing software called Dotclear: https://git.dotclear.org/dev/dotclear/issues/308

It's on the same web host. I hope it won't be too complicated that the issue is written in French.

Setup/Environment

  • ProcessWire version: 3.0.229
  • PHP version: 8.2

v-maillard avatar Apr 23 '24 07:04 v-maillard

@v-maillard ProcessWire requires chmod for security, making sure files are writable to who they need to be, and not writable to others. So it's something that I don't think would be good for ProcessWire itself to bypass. But I think should be okay for you to bypass if you have determined that it is safe in your environment. If that's the case, maybe do what they suggested in that dotclear example you mentioned, except put it in a separate file using the root namespace, and then include that file from /site/init.php. Or if you find it needs to come earlier in the boot process, include it directly from the top of your /index.php file.

<?php
if(!function_exists('chmod')): 
  function chmod($file, $permissions) {
    return true;
  }
endif; 

ryancramerdesign avatar May 10 '24 16:05 ryancramerdesign

@v-maillard, are you ok with Ryan's proposed solution? Can we close this issue?

matjazpotocnik avatar Jun 14 '24 20:06 matjazpotocnik

@v-maillard, I'll close this issue, reopen if needed.

matjazpotocnik avatar Jul 05 '24 16:07 matjazpotocnik