cross-solution / YAWIK

YAWIK is a web application. It can be used as an ATS applicant tracking system or as a jobboard.
https://yawik.org
MIT License
125 stars 67 forks source link

bin/console jobs expire --info gives errer #442

Closed cbleek closed 4 years ago

cbleek commented 6 years ago
root@yawik:/var/www/jobs.yawik.org# bin/console jobs expire --info
10 Jobs

ERROR: application encountered an error and can not continue. Error was logged

look at

Fatal Error

Call to a member function format() on null search?

Source file

File: .../Jobs/src/Jobs/Controller/ConsoleController.php:202

192:                $org = $job->getOrganization();
193:                if ($org) {
194:                    $org = $org->getName();
195:                } else {
196:                    $org = $job->getCompany();
197:                }
198:                printf(
199:                    '%s   %s   %s   %-30s   %-20s' . PHP_EOL,
200:                    $id,
201:                    $job->getDatePublishStart()->format('Y-m-d'),
202:                    $job->getDatePublishEnd()->format('Y-m-d'),
203:                    substr($job->getTitle(), 0, 30),
204:                    substr($org, 0, 20)
205:                );
206:            }
cbleek commented 6 years ago

was fixed in develop branch of SimpleJobMail module

cbleek commented 4 years ago
cbleek@php7-cb:~/Projects/Karriere24$ ./vendor/bin/yawik jobs expire --days=300 --info
10 Jobs

======================================================================
   The application has thrown an exception!
======================================================================
 Error
 Call to a member function format() on null
----------------------------------------------------------------------
/home/cbleek/Projects/Karriere24/vendor/yawik/jobs/src/Controller/ConsoleController.php:204
#0 /home/cbleek/Projects/Karriere24/vendor/yawik/jobs/src/Controller/ConsoleController.php(93): Jobs\Controller\ConsoleController->listExpiredJobs()
#1 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-mvc/src/Controller/AbstractActionController.php(77): Jobs\Controller\ConsoleController->expireJobsAction()
#2 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\Controller\AbstractActionController->onDispatch()
#3 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners()
#4 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-mvc/src/Controller/AbstractController.php(103): Laminas\EventManager\EventManager->triggerEventUntil()
#5 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-mvc/src/DispatchListener.php(139): Laminas\Mvc\Controller\AbstractController->dispatch()
#6 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-eventmanager/src/EventManager.php(321): Laminas\Mvc\DispatchListener->onDispatch()
#7 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-eventmanager/src/EventManager.php(178): Laminas\EventManager\EventManager->triggerListeners()
#8 /home/cbleek/Projects/Karriere24/vendor/laminas/laminas-mvc/src/Application.php(331): Laminas\EventManager\EventManager->triggerEventUntil()
#9 /home/cbleek/Projects/Karriere24/vendor/yawik/core/bin/yawik(27): Laminas\Mvc\Application->run()
#10 {main}
======================================================================
   Previous Exception(s):
TiSiE commented 4 years ago

@kilip Can you have a look at this, please?

kilip commented 4 years ago

@cbleek @TiSiE

Yes, I will take a look at this issue.

kilip commented 4 years ago

@TiSiE @cbleek

This error caused by null value on Job::datePublishStart or Job::datePublishEnd. I fix this error by displaying a null value with N/A:

https://github.com/kilip/yawik/commit/57e760502bebb6df6aeacc1845e2ad57c687cc3f#diff-693430b2ed2e1a31e15a24372ee59779R204-R214

Should I exclude jobs that have null value on datePublishStart and datePublishEnd from query?

cbleek commented 4 years ago

sorry, I missed the question.

No,

the query should expire all jobs with a DatePublishEnd or DatePublishStart Date lower than current date - n days. Maybe the following pseudo code helps to clarify

if ( DatePublishEnd exists and DatePublishEnd < now()-n days ) {
  expire
} elseif ( DatePublishStart exists and DatePublishStart < now() - n days ) {
 expire
}
TiSiE commented 4 years ago

@cbleek I think @kilip 's question is, what should be done if both dates are null

cbleek commented 4 years ago

If both dates are null, expire the job, too. Active jobs have always a DatePublishStart. So if it's missing, there is another mistake. We should expire these bad jobs to get rid of them.

TiSiE commented 4 years ago

There are only dateModified or dateCreated left, which are always not null because of the Lifecycle Events.

So only three options if both, datePublishStart and datePublishEnd are null:

TiSiE commented 4 years ago

I second @cbleek here. There should be no jobs without either datePublishStart or datePubilshEnd.

kilip commented 4 years ago

@cbleek @TiSiE

I have recheck the query and just leave the query as is, because it is working as expected.

TiSiE commented 4 years ago

@kilip how convenient! :smirk:

TiSiE commented 4 years ago

582 is merged, this issue therefor is closed.