JBZoo / CSV-Blueprint

Strict and automated line-by-line CSV validation tool based on customizable Yaml schemas
https://github.com/JBZoo/CSV-Blueprint-Demo
MIT License
48 stars 0 forks source link

[BUG] `validate-schema` crash - Call to undefined function opcache_invalidate() #190

Closed SierraKomodo closed 4 months ago

SierraKomodo commented 4 months ago

Describe the issue

Running validate-schema on a schema file crashes with the below error message. Error confirmed in various terminals (Nushell, cmd, powershell, git bash)

To Reproduce

available_crafting_apparel.csv

NOTE: Github apparently doesn't support uploading .yaml files, so I renamed it to .yaml.txt for uploading purposes available_crafting_apparel.yaml.txt

PHP Fatal error:  Uncaught Error: Call to undefined function opcache_invalidate() in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\src\Commands\AbstractValidate.php:144
Stack trace:
#0 G:\Projects\Tools\vendor\jbzoo\csv-blueprint\src\Commands\ValidateSchema.php(74): JBZoo\CsvBlueprint\Commands\AbstractValidate->findFiles('schema')
#1 G:\Projects\Tools\vendor\jbzoo\cli\src\CliCommand.php(159): JBZoo\CsvBlueprint\Commands\ValidateSchema->executeAction()
#2 G:\Projects\Tools\vendor\symfony\console\Command\Command.php(279): JBZoo\Cli\CliCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 G:\Projects\Tools\vendor\symfony\console\Application.php(1031): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 G:\Projects\Tools\vendor\symfony\console\Application.php(318): Symfony\Component\Console\Application->doRunCommand(Object(JBZoo\CsvBlueprint\Commands\ValidateSchema), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 G:\Projects\Tools\vendor\symfony\console\Application.php(169): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php(48): Symfony\Component\Console\Application->run()
#7 G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint(18): require_once('G:\\Projects\\Too...')
#8 G:\Projects\Tools\vendor\bin\csv-blueprint(119): include('G:\\Projects\\Too...')
#9 {main}
  thrown in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\src\Commands\AbstractValidate.php on line 144

Fatal error: Uncaught Error: Call to undefined function opcache_invalidate() in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\src\Commands\AbstractValidate.php on line 144

Error: Call to undefined function opcache_invalidate() in G:\Projects\Tools\vendor\jbzoo\csv-blueprint\src\Commands\AbstractValidate.php on line 144

Call Stack:
    0.0003     863048   1. {main}() G:\Projects\Tools\vendor\bin\csv-blueprint:0
    0.0201    2424504   4. JBZoo\CsvBlueprint\CliApplication->run() G:\Projects\Tools\vendor\jbzoo\csv-blueprint\csv-blueprint.php:48
    0.0422    2884568   5. JBZoo\CsvBlueprint\CliApplication->doRun() G:\Projects\Tools\vendor\symfony\console\Application.php:169
    0.0427    2912896   6. JBZoo\CsvBlueprint\CliApplication->doRunCommand() G:\Projects\Tools\vendor\symfony\console\Application.php:318
    0.0428    2912896   7. JBZoo\CsvBlueprint\Commands\ValidateSchema->run() G:\Projects\Tools\vendor\symfony\console\Application.php:1031
    0.0429    2916640   8. JBZoo\CsvBlueprint\Commands\ValidateSchema->execute() G:\Projects\Tools\vendor\symfony\console\Command\Command.php:279
    0.0460    3125288   9. JBZoo\CsvBlueprint\Commands\ValidateSchema->executeAction() G:\Projects\Tools\vendor\jbzoo\cli\src\CliCommand.php:159
    0.0463    3125480  10. JBZoo\CsvBlueprint\Commands\ValidateSchema->findFiles() G:\Projects\Tools\vendor\jbzoo\csv-blueprint\src\Commands\ValidateSchema.php:74

Expected behavior

The validate-schema command should validate the schema file as described in the help text, instead of crashing.

Your environment

Question Answer
CSV Blueprint version 1.0.1
OS Windows 10
PHP 8.3.6
XDebug 3.3.2
Composer 2.7.6
Installation Method Composer

Any links to the CI logs or the repository, if any.

SmetDenis commented 4 months ago

Hello.

opcache is a standard PHP module that is the default in all versions of the language. For some reason you have it disabled. It speeds up any your code dramatically.

Of course I will do an additional check for such an exclusive case. I would strongly recommend that you enable it. I assume you disabled it on your own or you have PHP specifically installed. It's very easy to do and another link. Even the very first line of the PHP documentation says so.

jbzoo_csv-blueprint 2024-05-09 11-44-45 PHP: Recommended Configuration on Windows systems - Manual 2024-05-09 11-44-20
SmetDenis commented 4 months ago

Btw, I see you have XDebug enabled. Just keep in mind that it also affects performance and slows down any PHP code a lot. If you don't need it, it's better to disable it. Just a friendly advice.

SierraKomodo commented 4 months ago

That makes sense - Didn't realise that was a PHP extension. In that case, I recommend adding that extension as a requirement in the composer package.

As for XDebug, I only have it enabled when I'm developing and debugging things (I.e., when doing bug reports).

SmetDenis commented 4 months ago

Fixed in https://github.com/JBZoo/CSV-Blueprint/releases/tag/1.0.2