Filter does not work
cosmonoid opened this issue · 6 comments
Filtering does not work for me:
$cfileDir = Yii::app()->file->set('ext.file');
print_r($cfileDir->getContents(false,'php'));
results in
Array
(
[0] => /var/www/web0/protected/extensions/file/.svn
[1] => /var/www/web0/protected/extensions/file/CFile.php
[2] => /var/www/web0/protected/extensions/file/CFileHelper.php
[3] => /var/www/web0/protected/extensions/file/CHANGELOG
[4] => /var/www/web0/protected/extensions/file/LICENSE
[5] => /var/www/web0/protected/extensions/file/README.rst
[6] => /var/www/web0/protected/extensions/file/tests
)
Thank you for the report. Seems to be fixed.
Thanks for the quick fix. In my special case it wont work. I have a folder structur for my logs in the format /YYYY/MM/DD. In this case filtering fails because the length of the filter (csv) is greater than the length of the filepath.
Adding :
if ($rule[0]!='/') {
if(strlen($str)-strlen($rule) > 0 )
$passed = (bool)substr_count($str, $rule, strlen($str)-strlen($rule));
else
$passed=0;
}
will fix it.
It seems that filterPassed description was misleading: $str does contain file name, not an entire path, as it were.
Hm. In the morning that filenames-only filtering decision doesn't seem so great %) I'll need some time to think it over again.
Have another try %)
Thanks, this works well for me!