lavary / crunz

A PHP-based job scheduler
MIT License
1.42k stars 136 forks source link

schedule:run [Crunz\Exception\WrongTaskNumberException] Passed task number is not string. #156

Closed bitbybit closed 5 years ago

bitbybit commented 5 years ago

Crunz version: 1.10.1, 1.10.0, 1.9.0, 1.8.0

PHP version: 7.1.20

Operating system type and version: Debian 9

Description
I can not run commands on crunz versions higher 1.7.3

$ /usr/bin/php vendor/bin/crunz -vvv schedule:run

In TaskNumber.php line 37:

  [Crunz\Exception\WrongTaskNumberException]  
  Passed task number is not string.           

Exception trace:
 Crunz\Task\TaskNumber::fromString() at vendor/lavary/crunz/src/Console/Command/ScheduleRunCommand.php:126
 Crunz\Console\Command\ScheduleRunCommand->execute() at vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Application.php:946
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at vendor/lavary/crunz/src/Application.php:83
 Crunz\Application->run() at vendor/lavary/crunz/crunz:49

schedule:run [-f|--force] [-t|--task TASK] [--] [<source>]

How to reproduce
/usr/bin/php vendor/bin/crunz schedule:run

PabloKowalczyk commented 5 years ago

Hello, could you also paste versions of other dependencies (command composer show)? I must admin for now i cannot reproduce this bug.

bitbybit commented 5 years ago

Hi Here it is

behat/transliterator                  v1.2.0   String transliterator
composer/ca-bundle                    1.1.2    Lets you find a path to the system CA bundle, and includes a fallback to the Mozil...
dflydev/doctrine-orm-service-provider v2.0.1   Doctrine ORM Service Provider
doctrine/annotations                  v1.6.0   Docblock Annotations Parser
doctrine/cache                        v1.8.0   Caching library offering an object-oriented API for many cache backends
doctrine/collections                  v1.5.0   Collections Abstraction library
doctrine/common                       v2.9.0   Common Library for Doctrine projects
doctrine/dbal                         v2.8.0   Database Abstraction Layer
doctrine/event-manager                v1.0.0   Doctrine Event Manager component
doctrine/inflector                    v1.3.0   Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator                 1.1.0    A small, lightweight utility to instantiate objects in PHP without invoking their ...
doctrine/lexer                        v1.0.1   Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.
doctrine/orm                          v2.6.2   Object-Relational-Mapper for PHP
doctrine/persistence                  v1.0.1   Doctrine Persistence abstractions.
doctrine/reflection                   v1.0.0   Doctrine Reflection component
dompdf/dompdf                         v0.8.2   DOMPDF is a CSS 2.1 compliant HTML to PDF converter
egulias/email-validator               2.1.6    A library for validating emails against several RFCs
erusev/parsedown                      1.7.1    Parser for Markdown.
fig/link-util                         1.0.0    Common utility implementations for HTTP links
gedmo/doctrine-extensions             v2.4.36  Doctrine2 behavioral extensions
guzzlehttp/guzzle                     6.3.3    Guzzle is a PHP HTTP client library
guzzlehttp/promises                   v1.3.1   Guzzle promises library
guzzlehttp/psr7                       1.4.2    PSR-7 message implementation that also provides common utility methods
ingenerator/tokenista                 v1.1.0   Simple signed and expiring token generator and validator - for password reset, CSR...
jbzoo/pimpledumper                    1.2.2    Easy way to auto create pimple.json and .phpstorm.meta.php for Pimple Container
jeremeamia/SuperClosure               2.4.0    Serialize Closure objects, including their context and binding
jhaoda/smscenter                      v2.0.1   Класс для работы с API сервиса smsc.ru
lavary/crunz                          v1.10.1  Schedule your tasks right from the code.
mesilov/bitrix24-php-sdk              0.4.0    A powerfull PHP library for the Bitrix24 REST API
monolog/monolog                       1.23.0   Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/cron-expression             v1.2.1   CRON for PHP: Calculate the next or previous run date and determine if a CRON expr...
nesbot/carbon                         1.34.0   A simple API extension for DateTime.
nikic/php-parser                      v4.1.0   A PHP parser written in PHP
paragonie/random_compat               v9.99.99 PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phenx/php-font-lib                    0.5.1    A library to read, parse, export and make subsets of different types of font files.
phenx/php-svg-lib                     v0.3.2   A library to read, parse and export to PDF SVG files.
pimple/pimple                         v3.2.3   Pimple, a simple Dependency Injection Container
psr/container                         1.0.0    Common Container Interface (PHP FIG PSR-11)
psr/http-message                      1.0.1    Common interface for HTTP messages
psr/link                              1.0.0    Common interfaces for HTTP links
psr/log                               1.0.2    Common interface for logging libraries
sabberworm/php-css-parser             8.1.0    Parser for CSS Files written in PHP
sensiolabs/security-checker           v4.1.8   A security checker for your composer.lock
silex/silex                           v2.3.0   The PHP micro-framework based on the Symfony Components
silex/web-profiler                    v2.0.11  A WebProfiler for Silex
sorien/silex-dbal-profiler            2.0.0    Doctrine DBAL Profiler for Silex
studio-42/elfinder                    2.1.42   File manager for web
swiftmailer/swiftmailer               v6.1.3   Swiftmailer, free feature-rich PHP mailer
symfony/asset                         v3.4.17  Symfony Asset Component
symfony/config                        v3.4.17  Symfony Config Component
symfony/console                       v3.4.17  Symfony Console Component
symfony/debug                         v4.1.6   Symfony Debug Component
symfony/debug-bundle                  v3.4.17  Symfony DebugBundle
symfony/dependency-injection          v4.0.14  Symfony DependencyInjection Component
symfony/event-dispatcher              v4.1.6   Symfony EventDispatcher Component
symfony/filesystem                    v4.1.6   Symfony Filesystem Component
symfony/finder                        v3.4.17  Symfony Finder Component
symfony/form                          v3.4.17  Symfony Form Component
symfony/http-foundation               v4.1.6   Symfony HttpFoundation Component
symfony/http-kernel                   v4.0.14  Symfony HttpKernel Component
symfony/inflector                     v4.1.6   Symfony Inflector Component
symfony/intl                          v4.1.6   A PHP replacement layer for the C intl extension that includes additional data fro...
symfony/monolog-bridge                v3.4.17  Symfony Monolog Bridge
symfony/options-resolver              v4.1.6   Symfony OptionsResolver Component
symfony/polyfill-ctype                v1.9.0   Symfony polyfill for ctype functions
symfony/polyfill-intl-icu             v1.9.0   Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring             v1.9.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php56                v1.9.0   Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70                v1.9.0   Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-php72                v1.9.0   Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-util                 v1.9.0   Symfony utilities for portability of PHP codes
symfony/process                       v4.1.6   Symfony Process Component
symfony/property-access               v4.1.6   Symfony PropertyAccess Component
symfony/routing                       v4.1.6   Symfony Routing Component
symfony/security                      v3.4.17  Symfony Security Component
symfony/security-bundle               v3.4.17  Symfony SecurityBundle
symfony/stopwatch                     v3.4.17  Symfony Stopwatch Component
symfony/translation                   v3.4.17  Symfony Translation Component
symfony/twig-bridge                   v3.4.17  Symfony Twig Bridge
symfony/twig-bundle                   v3.4.17  Symfony TwigBundle
symfony/validator                     v3.4.17  Symfony Validator Component
symfony/var-dumper                    v4.1.6   Symfony mechanism for exploring and dumping PHP variables
symfony/web-link                      v3.4.17  Symfony WebLink Component
symfony/web-profiler-bundle           v3.4.17  Symfony WebProfilerBundle
symfony/yaml                          v3.4.17  Symfony Yaml Component
touhonoob/rate-limit                  1.2.0    Rate Limiting Library With Token Bucket Algorithm
twig/extensions                       v1.5.2   Common additional features for Twig that do not directly belong in core
twig/twig                             v1.35.4  Twig, the flexible, fast, and secure template language for PHP
PabloKowalczyk commented 5 years ago

I cannot reproduce this bug but i think this can be related to other type than null in case task param is empty. Could you go to \Crunz\Console\Command\ScheduleRunCommand, add var_dump($task); in line 96, run schedule:run again and show me the result?

bitbybit commented 5 years ago
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->arguments = $input->getArguments();
        $this->options = $input->getOptions();
        $task = $this->options['task'];
        var_dump($task); $files = $this->taskCollection
            ->all($this->arguments['source'])
        ;
$ /usr/bin/php vendor/bin/crunz -vvv schedule:run
NULL

In TaskNumber.php line 37:

  [Crunz\Exception\WrongTaskNumberException]  
  Passed task number is not string.           

Exception trace:
 Crunz\Task\TaskNumber::fromString() at vendor/lavary/crunz/src/Console/Command/ScheduleRunCommand.php:126
 Crunz\Console\Command\ScheduleRunCommand->execute() at vendor/symfony/console/Command/Command.php:255
 Symfony\Component\Console\Command\Command->run() at vendor/symfony/console/Application.php:946
 Symfony\Component\Console\Application->doRunCommand() at vendor/symfony/console/Application.php:248
 Symfony\Component\Console\Application->doRun() at vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at vendor/lavary/crunz/src/Application.php:83
 Crunz\Application->run() at vendor/lavary/crunz/crunz:49

schedule:run [-f|--force] [-t|--task TASK] [--] [<source>]
PabloKowalczyk commented 5 years ago

Very weird, could you test that version https://github.com/PabloKowalczyk/crunz/tree/accept-only-string-task-number ?

bitbybit commented 5 years ago

Sorry but what is a proper way to install it? I did git clone git@github.com:PabloKowalczyk/crunz.git and now i get

$ /usr/bin/php ./vendor/lavary/crunz/crunz -vvv schedule:run
PHP Warning:  require(vendor/composer/../lavary/crunz/src/Helpers.php): failed to open stream: No such file or directory in vendor/composer/autoload_real.php on line 57
PHP Fatal error:  require(): Failed opening required 'vendor/composer/../lavary/crunz/src/Helpers.php' (include_path='.:/usr/share/php') in vendor/composer/autoload_real.php on line 57
PabloKowalczyk commented 5 years ago

Run composer install in the cloned directory or you can install patched version by Composer: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository.

bitbybit commented 5 years ago

This version is working :+1:

$ /usr/bin/php ./vendor/lavary/crunz/crunz -vvv schedule:run
Using config file crunz.yml.
Timezone from config: 'Europe/Moscow'.
Timezone for comparisons: 'Europe/Moscow'.
Invoke Schedule's ping before
There is no ping before url.
Invoke Event's ping before.
There is no ping before url.
Invoke Event's ping after.
There is no ping after url.
Task Checks if application uses dependencies with known security vulnerabilities status: success.
Invoke Schedule's ping after.
There is no ping after url.
PabloKowalczyk commented 5 years ago

I will merge #158 after successful CI build, but there are some problems with Github's webhooks.

PabloKowalczyk commented 5 years ago

158 merged, thanks @bitbybit.