joomla / joomla-framework

[READ-ONLY] This repo is no longer in active development. Please see https://github.com/joomla-framework for the individual Framework packages.
http://framework.joomla.org
GNU General Public License v2.0
189 stars 140 forks source link

Error in Path::canChmod #351

Closed Achal-Aggarwal closed 7 years ago

Achal-Aggarwal commented 10 years ago

canChmod doesn't handle the case where the passed path (file or folder) did not exist at all.

fileperms(): stat failed for joomla-framework/src/Joomla/Filesystem/Path

piotr-cz commented 10 years ago

So in case that file doesn't exist, does it make more sense to return false or throw some Exception (InvalidArgumentException or LogicException)?

Achal-Aggarwal commented 10 years ago

could be anything 1) Log::add() and then return false 2) RuntimeException('Path doesn't exist') 3) or any Exception()

dongilbert commented 10 years ago

Definitely not Log::add, as we want to avoid hard dependencies. If it can't stat the file for some reason, then it's more than likely that it can't chmod either, so in that case, canChmod should just return false. No need to throw an exception or anything.

Achal-Aggarwal commented 10 years ago

@dongilbert yeah you are right. If file exist but the directory in which it exist is not accessible by the user then fileperms() is giving stat error.