silverstripe-terraformers / silverstripe-embargo-expiry

BSD 3-Clause "New" or "Revised" License
7 stars 7 forks source link

the method 'setIsUnPublishJobRunning' does not exist on 'MyCustomPageType' #55

Closed eehondas closed 5 years ago

eehondas commented 5 years ago

Hello, First of all thanks for the module. I used the SS3 version of this module multiple times without a problem. I seem to have one with this one. I installed the module and applied the extension to SiteTree, the interface works fine: I can schedule publish and unpublish and clear them from the tab in page view. Problem comes when the scheduled job tries to execute from my Job queue: I always get a broken job state with the job spitting this out:

[2019-08-07 16:06:01][INFO] Job caused exception Object->__call(): the method 'setIsUnPublishJobRunning' does not exist on 'StandardInnerPage' in /var/www/isf/githtdocs/vendor/silverstripe/framework/src/Core/CustomMethods.php at line 54
[2019-08-07 16:06:01][INFO] ERROR [Emergency]: Uncaught BadMethodCallException: Object->__call(): the method 'setIsUnPublishJobRunning' does not exist on 'StandardInnerPage'
IN GET dev/tasks/ProcessJobQueueTask
Line 54 in /var/www/isf/githtdocs/vendor/silverstripe/framework/src/Core/CustomMethods.php

Source
======
45: * @throws BadMethodCallException
46: */
47: public function __call($method, $arguments)
48: {
49: // If the method cache was cleared by an an Object::add_extension() /
Object::remove_extension()
50: // call, then we should rebuild it.
51: $class = static::class;
52: $config = $this->getExtraMethodConfig($method);
53: if (empty($config)) {
* 54: throw new BadMethodCallException(
55: "Object->__call(): the method '$method' does not exist on '$class'"
56: );
57: }
58: 
59: switch (true) {
60: case isset($config['callback']): {

Trace
=====
SilverStripe\View\ViewableData->__call(setIsUnPublishJobRunning, Array)
UnPublishTargetJob.php:91

Terraformers\EmbargoExpiry\Job\UnPublishTargetJob->process()
QueuedJobService.php:784

Symbiote\QueuedJobs\Services\QueuedJobService->runJob(26)
QueuedJobService.php:1186

Symbiote\QueuedJobs\Services\QueuedJobService->processJobQueue(2)
QueueRunner.php:23

Symbiote\QueuedJobs\Tasks\Engines\QueueRunner->runQueue(2)
QueuedJobService.php:1163

Symbiote\QueuedJobs\Services\QueuedJobService->runQueue(2)
ProcessJobQueueTask.php:59

Symbiote\QueuedJobs\Tasks\ProcessJobQueueTask->run(SilverStripe\Control\HTTPRequest)
TaskRunner.php:104

SilverStripe\Dev\TaskRunner->runTask(SilverStripe\Control\HTTPRequest)
RequestHandler.php:320

SilverStripe\Control\RequestHandler->handleAction(SilverStripe\Control\HTTPRequest, runTask)
Controller.php:284

SilverStripe\Control\Controller->handleAction(SilverStripe\Control\HTTPRequest, runTask)
RequestHandler.php:202

SilverStripe\Control\RequestHandler->handleRequest(SilverStripe\Control\HTTPRequest)
Controller.php:212

SilverStripe\Control\Controller->handleRequest(SilverStripe\Control\HTTPRequest)
RequestHandler.php:226

SilverStripe\Control\RequestHandler->handleRequest(SilverStripe\Control\HTTPRequest)
Controller.php:212

SilverStripe\Control\Controller->handleRequest(SilverStripe\Control\HTTPRequest)
Director.php:361

SilverStripe\Control\Director->SilverStripe\Control\{closure}(SilverStripe\Control\HTTPRequest)
VersionedHTTPMiddleware.php:41

SilverStripe\Versioned\VersionedHTTPMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
BasicAuthMiddleware.php:68

SilverStripe\Security\BasicAuthMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
AuthenticationMiddleware.php:61

SilverStripe\Security\AuthenticationMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
CanonicalURLMiddleware.php:188

SilverStripe\Control\Middleware\CanonicalURLMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
HTTPCacheControlMiddleware.php:42

SilverStripe\Control\Middleware\HTTPCacheControlMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
ChangeDetectionMiddleware.php:27

SilverStripe\Control\Middleware\ChangeDetectionMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
FlushMiddleware.php:29

SilverStripe\Control\Middleware\FlushMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
RequestProcessor.php:66

SilverStripe\Control\RequestProcessor->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
SessionMiddleware.php:20

SilverStripe\Control\Middleware\SessionMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
AllowedHostsMiddleware.php:60

SilverStripe\Control\Middleware\AllowedHostsMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
TrustedProxyMiddleware.php:176

SilverStripe\Control\Middleware\TrustedProxyMiddleware->process(SilverStripe\Control\HTTPRequest, Closure)
HTTPMiddlewareAware.php:62

SilverStripe\Control\Director->SilverStripe\Control\Middleware\{closure}(SilverStripe\Control\HTTPRequest)
HTTPMiddlewareAware.php:65

SilverStripe\Control\Director->callMiddleware(SilverStripe\Control\HTTPRequest, Closure)
Director.php:370

SilverStripe\Control\Director->handleRequest(SilverStripe\Control\HTTPRequest)
HTTPApplication.php:48

SilverStripe\Control\HTTPApplication->SilverStripe\Control\{closure}(SilverStripe\Control\HTTPRequest)

call_user_func(Closure, SilverStripe\Control\HTTPRequest)
HTTPApplication.php:66

SilverStripe\Control\HTTPApplication->SilverStripe\Control\{closure}(SilverStripe\Control\HTTPRequest)
HTTPMiddlewareAware.php:65

SilverStripe\Control\HTTPApplication->callMiddleware(SilverStripe\Control\HTTPRequest, Closure)
HTTPApplication.php:67

SilverStripe\Control\HTTPApplication->execute(SilverStripe\Control\HTTPRequest, Closure, )
HTTPApplication.php:49

SilverStripe\Control\HTTPApplication->handle(SilverStripe\Control\HTTPRequest)
cli-script.php:22

In this case my 'StandardInnerPage' is just my custom page type. I am positive the extension is applied because I'm able to add the scheduled publish / unpublish from the page view and also because I can run the job manually from the job queue without an error (correctly publishes unpublishes the page).

It sort of looks like the extension is not applied when the job runs from the ProcessJobQueueTask, however I have absolutely no idea why this happens. My other scheduled jobs are running fine.

Any insight on this or direction you can point me to? I'm using version 1.0.1

Thanks

chrispenny commented 5 years ago

Hi @eehondas, thank you for raising an issue. Sorry it's taken me a while to get to, I've been on annual leave.

The fact that it works when you manually process the queue is a bit confusing. The only thing that comes to mind here is that perhaps the cache in your CLI is not flushed? This could explain why processing the Job through the CMS works, but through CLI does not.

It might also be worth adding some logging to the Job to see what you get. In process(), you could look to add some logging like:

// existing code
$target = $this->getTarget();

if ($target === null) {
    $this->completeJob();

    return;
}

// add debugging
Debug::dump($target->ClassName);
Debug::dump($target->hasExtension(EmbargoExpiryExtension::class));
Debug::dump(Extensible::get_extensions(StandardInnerPage::class));

You could try running the Job again through the CMS and CLI to see what the difference is.

Outputs should go to your log file (whatever you've set that up to be), and it should also be in the QueuedJobDescriptor record in the database (I think it goes under the SavedJobMessages field).

Out of curiosity, what version of SilverStripe are you using this on?

eehondas commented 5 years ago

hey @chrispenny thank you so much. You were right on the dot. I manually cleaned the temporary cache of my webserver and it started working scheduled. Sorry for the issue it was clearly nothing to do with the module just my webserver that was failing to correctly invalidate the silverstripe-cache/ folder Thank you!

chrispenny commented 5 years ago

Hi @eehondas. Sweet! I'm glad that it's sorted for you now. Please don't hesitate to raise any new issues/questions that you might have.