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

Problem with invalid escaping in Clockwork FileStorage when using fputcsv #730

Open
SheylaSilvana opened this issue Jan 22, 2025 · 0 comments

Comments

@SheylaSilvana
Copy link

SheylaSilvana commented Jan 22, 2025

Problem with invalid escaping in Clockwork FileStorage when using fputcsv

When configuring Clockwork to use FileStorage, an error occurs when writing to the index file using the fputcsv function. The error occurs because the escape character provided for the function is not valid. The problem appears with the following error message:

ErrorException: fputcsv(): escape must be a character

This problem occurs because the fourth parameter of fputcsv (escape) is not a valid character. By default, FileStorage escapes an empty value (''), which causes the error.

To reproduce the issue, configure Clockwork to use FileStorage in the configuration file as follows:

'storage' => env('CLOCKWORK_STORAGE', 'files'),
'storage_files_path' => env('CLOCKWORK_STORAGE_FILES_PATH', storage_path('clockwork')),

Then, make a request to the application and observe the error generated in the log. This issue has been identified in the following environment:

  • Operating System: Windows/Linux
  • PHP version: 7.3
  • Clockwork version: 5.3.3
  • Framework: Laravel Lumen 8.3

Related Code:

In the file Clockwork\Storage\FileStorage, the updateIndex method uses:

fputcsv($handle, [...], ',', '"', '');

Possible Solution:

Change the updateIndex method in the FileStorage file to use a valid escape character (for example, ):

fputcsv($handle, [...], ',', '"', '\\');
@SheylaSilvana SheylaSilvana reopened this Jan 22, 2025
@SheylaSilvana SheylaSilvana changed the title Problema com escape inválido no FileStorage do Clockwork ao usar fputcsv Problem with invalid escaping in Clockwork FileStorage when using fputcsv Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant