Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create "cache" folder if it doesn't exist before trying to write to it #21952

Merged
merged 4 commits into from Apr 29, 2019

Conversation

@AndySDH
Copy link
Contributor

@AndySDH AndySDH commented Sep 1, 2018

This fixes this issue:

Steps to reproduce the issue

  • Have cache enabled
  • Delete cache folder

Result before PR

Sites breaks. Goes blank.

With error reporting on, throws error:
"Error: Call to a member function getTag() on null: The file Cache Storage is not supported on this platform."

Result after PR

Joomla creates "cache" folder if it doesn't exist

Additional comments

Now, of course there is no reason why one should delete the cache folder but it can happen by accident or for whatever other reason. The principle that Joomla doesn't check if the folder is there or not (and breaks the site if it's not) before trying to write to it is wrong.

This fixes this issue:

### Steps to reproduce the issue

- Have cache enabled
- Delete cache folder

### Expected result

- Joomla creates "cache" folder if it doesn't exist

### Actual result

- Sites breaks. Goes blank.

### Additional comments

Now, of course there is no reason why one should delete the cache folder but it can happen by accident or for whatever other reason. The principle that Joomla doesn't check if the folder is there or not (and breaks the site if it's not) before trying to write to it is wrong.
@AndySDH AndySDH mentioned this pull request Sep 1, 2018
if (!is_dir($folder))
{
@mkdir($folder);
}
Copy link
Member

@brianteeman brianteeman Sep 1, 2018

Don't we need some code then if for any reason joomla cannot create the folder

@mbabker
Copy link
Contributor

@mbabker mbabker commented Sep 1, 2018

This is the wrong place to be doing this type of thing. A check for platform support shouldn't have side effects, in this case the side effect is creating the directory.

This type of directory creation is better suited in com_config when the global configuration is saved (which, we already do except for trying to (re-)create the core cache directory).

TBH, the more I think about this the more I think this particular isSupported method should just return true and leave it to runtime to raise issues if there are problems reading from or writing to the configured cache directory (we don't try to create the root cache path at runtime, which IMO should correctly be an error, but we do create the subdirectories as needed).

@mbabker
Copy link
Contributor

@mbabker mbabker commented Sep 1, 2018

Taking some inspiration from https://github.com/joomla-framework/cache/blob/2.0-dev/src/Adapter/File.php

  1. Make the isSupported method only return true, don't check config or anything like that (especially because the cache path is injectable in the handler's constructor, which may be different from the config path)
  2. Check that the path exists and is readable in the handler's constructor, if not throw a CacheConnectingException (this is in line with how we fail on the Memcached handler if the connection can't be created at runtime)
  3. The same changes should be made to the Cache_Lite handler (it too is a filesystem cache API just using a third party PEAR library)

By removing the isSupported method from that file, it will fall back on its parent isSupported method, which simply returns true.
@AndySDH
Copy link
Contributor Author

@AndySDH AndySDH commented Sep 1, 2018

@mbabker Thanks for the comment. Deleting the method solves the issue too. Updated.
Beyond this, I'm not that knowledgeable, so this is as far as I can go with this. If you want to implement a different/more thorough solution, please go ahead.
But let's not take months for a simple fix, this is already better than before when it was breaking the site.

zwiastunsw pushed a commit to zwiastunsw/joomla-cms that referenced this issue Sep 2, 2018
* [4.0] Workflow - list and edit

I can't see any point in having the author or creation/modified dates. We dont have them for stages/transitions and unless I have missed something they are not needed.

So this PR simplifies the edit form (inline with joomla#21952) and updates the list view accordingly

NOTE I removed the manage text link as its really a duplicate of the other stages link that has the number in it - although that might need tweaking in the UI - as you should not have two links to do the same thing for a11y

* typo - thanks @alikon
@ghost ghost added the J3 Issue label Apr 5, 2019
@ghost ghost removed the J3 Issue label Apr 19, 2019
@ghost
Copy link

@ghost ghost commented Apr 28, 2019

@HLeithner do you plan to merge this in J3 or is it for J4?

@HLeithner
Copy link
Member

@HLeithner HLeithner commented Apr 29, 2019

I will merge it. @AndySDH please resolve the conflict

@AndySDH
Copy link
Contributor Author

@AndySDH AndySDH commented Apr 29, 2019

Done (I think. First time I resolve conflicts stuff)

@HLeithner HLeithner merged commit d678266 into joomla:staging Apr 29, 2019
4 checks passed
@HLeithner
Copy link
Member

@HLeithner HLeithner commented Apr 29, 2019

thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants