<commit_before><?php
namespace Chamilo\Libraries\Cache\Doctrine\Provider;

/**
 *
 * @package Chamilo\Libraries\Cache\Doctrine\Provider
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class PhpFileCache extends \Doctrine\Common\Cache\PhpFileCache
{

    /**
     *
     * @var string[] regular expressions for replacing disallowed characters in file name
     */
    private $disallowedCharacterPatterns = array('/\-/', '/[^a-zA-Z0-9\-_\[\]]/');

    /**
     *
     * @var string[] replacements for disallowed file characters
     */
    private $replacementCharacters = array('__', '-');

    /**
     *
     * @param string $id
     *
     * @return string
     */
    protected function getFilename($id)
    {
        return $this->getDirectory() . DIRECTORY_SEPARATOR . md5($id) . DIRECTORY_SEPARATOR .
             preg_replace($this->disallowedCharacterPatterns, $this->replacementCharacters, $id) . $this->getExtension();
    }

    /**
     * Extension of the doDelete function to invalidate the opcache
     *
     * @param string $identifier
     *
     * @return bool
     */
    protected function doDelete($identifier)
    {
        $success = parent::doDelete($identifier);

        $filename = $this->getFilename($identifier);
        if(function_exists('opcache_invalidate'))
        {
            opcache_invalidate($filename, true);
        }

        return $success;
    }
}<commit_msg>[Tryout] Fixes for issues between phpFileCache en opcache<commit_after><?php
namespace Chamilo\Libraries\Cache\Doctrine\Provider;

/**
 *
 * @package Chamilo\Libraries\Cache\Doctrine\Provider
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>.be>
 */
class PhpFileCache extends \Doctrine\Common\Cache\PhpFileCache
{

    /**
     *
     * @var string[] regular expressions for replacing disallowed characters in file name
     */
    private $disallowedCharacterPatterns = array('/\-/', '/[^a-zA-Z0-9\-_\[\]]/');

    /**
     *
     * @var string[] replacements for disallowed file characters
     */
    private $replacementCharacters = array('__', '-');

    /**
     *
     * @param string $id
     *
     * @return string
     */
    protected function getFilename($id)
    {
        return $this->getDirectory() . DIRECTORY_SEPARATOR . md5($id) . DIRECTORY_SEPARATOR .
             preg_replace($this->disallowedCharacterPatterns, $this->replacementCharacters, $id) . $this->getExtension();
    }

    /**
     * Extension of the doDelete function to invalidate the opcache
     *
     * @param string $identifier
     *
     * @return bool
     */
    protected function doDelete($identifier)
    {
        $filename = $this->getFilename($identifier);
        if(function_exists('opcache_invalidate'))
        {
            opcache_invalidate($filename, true);
        }

        return parent::doDelete($identifier);
    }
}
{'fraction_non_alphanumeric': 0.14256269323256612, 'fraction_numerical': 0.0020611473720371005, 'mean_word_length': 2.617391304347826, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3108085', 'n_tokens_mistral': 877, 'n_tokens_neox': 854, 'n_words': 177}