processwire / processwire-issues

ProcessWire issue reports.
44 stars 2 forks source link

Call to undefined function chmod (php8 disable_functions) #1913

Closed v-maillard closed 1 week ago

v-maillard commented 2 months ago

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

ryancramerdesign commented 2 months ago

@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; 
matjazpotocnik commented 4 weeks ago

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

matjazpotocnik commented 1 week ago

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