Search
Other ReReplacer questions
Forum

2 Million files in tmp/regularlabs/custom_php

Jacob Hodara's Avatar Jacob Hodara
Peter, I'm not sure if this is coming from ReReplacer but once of our client's site has 2 million files in this folder. We removed them and in about 24-48 hours 100k were added.

Do we need to delete these files? What is the purpose of them?
Peter van Westen's Avatar Peter van Westen ADMIN
These files are created by custom hp assignments or use of php blocks via Sourcerer.
However, these files should get deleted on the same pageload.
So the folder should always be pretty much empty.

It looks like there are issues on your server with files being locked after they are used, preventing them to get deleted. I recommend you ask your host to look into this.
Please post a rating at the Joomla! Extensions Directory
Jacob Hodara's Avatar Jacob Hodara
Peter, our client manages his own server, he is a Linux admin himself (30+ years).

Info he sent me:
I can delete the files using the same user as the one who created them, so not sure how it could be an apache or server problem.

We need more info, like a "permission denied" statement or otherwise be able to replicate the process being used to delete them from this "sorcerer" code.
Peter van Westen's Avatar Peter van Westen ADMIN
I can delete the files using the same user as the one who created them, so not sure how it could be an apache or server problem.
The test should be this:
During 1 pageload/process:
- Create a php file
- Include (execute) that file via an ob_start/ob_get_contents/ob_end_clean block
- Delete the file
Please post a rating at the Joomla! Extensions Directory
Jacob Hodara's Avatar Jacob Hodara
Peter, what is the purpose of these cache files if they get deleted on page loads?
Peter van Westen's Avatar Peter van Westen ADMIN
To be able to execute the php code, without having to do that via the evil eval command.
Please post a rating at the Joomla! Extensions Directory
Jacob Hodara's Avatar Jacob Hodara
Peter, we create a simple PHP script test to generate a file with ob functions, then deletion using unlink function and it worked well. This rules out permission issue.

What is our next step here to resolve the issue?
Peter van Westen's Avatar Peter van Westen ADMIN
By the way, do you have debugging on?

This is the code that ReReplacer uses (the Regular Labs Library):
private static function createFunctionInMemory(string $string): void
    {
        $file_name = getmypid() . '_' . md5($string);

        $tmp_path  = JFactory::getApplication()->get('tmp_path', JPATH_ROOT . '/tmp');
        $temp_file = $tmp_path . '/regularlabs/custom_php/' . $file_name;

        // Write file
        if ( ! file_exists($temp_file) || is_writable($temp_file))
        {
            JFile::write($temp_file, $string);
        }

        // Include file
        include_once $temp_file;

        // Delete file
        if ( ! JFactory::getApplication()->get('debug'))
        {
            @chmod($temp_file, 0777);
            @unlink($temp_file);
        }
    }
Please post a rating at the Joomla! Extensions Directory
Jacob Hodara's Avatar Jacob Hodara
Peter, I see the issue, we have Debug enabled for admins only. This is causing files to get deleted.
Peter van Westen's Avatar Peter van Westen ADMIN
This is causing files to get deleted.
I guess you mean:
"This is causing files to NOT get deleted."
Please post a rating at the Joomla! Extensions Directory
Jacob Hodara's Avatar Jacob Hodara
Yes, correct, I meant that
Jacob Hodara's Avatar Jacob Hodara
Peter, our client is asking if there is any way to add a feature to not tie the cache deletion to Debug state as we have it enabled by default (output for admins only)
Peter van Westen's Avatar Peter van Westen ADMIN
Debug mode disables a bunch of things in Joomla too. It should only be used when testing things. It should NOT be enabled by default.
Please post a rating at the Joomla! Extensions Directory
You can only post on the extension support forum if you have an active subscription and you log in

Buy a Pro subscription