? Pending

User tests: Successful: Unsuccessful:

avatar csthomas
csthomas
26 Apr 2017

Pull Request for Issue #15544

Summary of Changes

Check cache file before use.

Reason

To save a cache file joomla requires lock method.
To create a lock for cache joomla has to create a file in the cache folder.
If a view method raise an error then cache process is hung up and the file can not be deleted.
The file is left empty.
Next request could find such file and display it as empty article.

Simple solution

Check if the cache file is not empty.

I have added a more explanation at #10767 (comment)

Testing Instructions

Take a look at the issue.

Expected result

Error 404

Actual result

Blank component.

Documentation Changes Required

No

avatar csthomas csthomas - open - 26 Apr 2017
avatar csthomas csthomas - change - 26 Apr 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Apr 2017
Category Libraries
avatar rdeutz
rdeutz - comment - 26 Apr 2017

I have tested this item successfully on 6fdb602


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15558.

avatar rdeutz rdeutz - test_item - 26 Apr 2017 - Tested successfully
avatar franz-wohlkoenig franz-wohlkoenig - test_item - 26 Apr 2017 - Tested successfully
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Apr 2017

I have tested this item successfully on 6fdb602


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15558.

avatar franz-wohlkoenig franz-wohlkoenig - change - 26 Apr 2017
Status Pending Ready to Commit
Easy No Yes
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 26 Apr 2017

RTC after two successful tests.

avatar wilsonge
wilsonge - comment - 26 Apr 2017

This works. Why do we need to create an empty file though. I'm worried about forcing sites with inode restrictions that people accessing pages that don't exist can just try and access 100 404 id'd and suddenly you've managed to destroy their site.

avatar rdeutz
rdeutz - comment - 26 Apr 2017

I agree with @wilsonge, it would be better, if we don't create empty files

avatar csthomas
csthomas - comment - 26 Apr 2017

I have the same feelings but lock() method is not very flexible.

Do you know a way to lock file without creating it?

Currently we have steps if page exists:

  1. Check if file exists, answer no
  2. Lock file - create empty file.
  3. Call view->display()
  4. Save data to file.
  5. Unlock file.
  6. Display data.

If error 404:

  1. Check if file exists, answer no
  2. Lock file - create empty file.
  3. Call view->display()
    a. Error 404
    b. Now joomla creates a new view with 404 or other error.
    c. Joomla call exit()

4. Save data to file.
5. Unlock file.
6. Display data.

This PR can wait, maybe we will find a better way.

avatar mbabker
mbabker - comment - 26 Apr 2017

Maybe try looking at Symfony's LockHandler for inspiration?

With 4.0 their new Lock component may also be helpful?

avatar csthomas
csthomas - comment - 26 Apr 2017

I think about add register_shutdown_function to cache file constructor.
The function will do:

foreach ($this->_locked_files as $path => $handle)
{
	if ($handle && filesize($path) === 0)
	{
		@flock($this->_locked_files[$path], LOCK_UN);
		@fclose($this->_locked_files[$path]);
		@unlink($path);
	}
}
avatar csthomas
csthomas - comment - 26 Apr 2017

I have created a better solution at PR #15592 which does not leave empty cache file.

avatar zero-24
zero-24 - comment - 27 Apr 2017

So we can close here? If #15592 is the better fix?

avatar csthomas
csthomas - comment - 27 Apr 2017

Yes

avatar csthomas csthomas - change - 27 Apr 2017
Status Ready to Commit Closed
Closed_Date 0000-00-00 00:00:00 2017-04-27 15:22:57
Closed_By csthomas
Labels Added: ?
avatar csthomas csthomas - close - 27 Apr 2017
avatar demis-palma
demis-palma - comment - 7 May 2017

Could you consider #15875 instead?

Add a Comment

Login with GitHub to post a comment