Closed (fixed)
Project:
Scheduler
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Aug 2017 at 10:59 UTC
Updated:
28 Nov 2017 at 19:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
mpp commentedComment #3
jonathan1055 commentedThat's interesting. Thanks for the patch and link to the other issue.
It would seem that your patch should fix the problem, and obviously won't cause any current tests to fail. But I'd like to try and replicate it before I fix it (always a good idea). Do you know how the reproduction steps could be made simple? Where you migrating from a 7.x to 8.x site?
Jonathan
Comment #4
mpp commentedIndeed, I was migrating a node translation from Drupal 7.
Comment #5
jonathan1055 commentedHaving thought about this a bit more, is it actually the contrib module's responsibility to ensure that
$node->type->entityreturns a valid entity object? There may be many 3rd-party implementations ofhook_ENTITY_TYPE_presave()for node entities and I would expect it to be the initiating function's duty to ensure the $node object is complete? If we fix this in Scheduler, is it just hiding the problem, and will it have to be fixed in every other hook_node_presave() that might be invoked during node translation migration? Just asking the question ...Comment #6
mpp commentedAccording to its signature the method expects an EntityInterface:
So normally you can only perform operations on that interface, in this case I'd assume the operation getEntityType() would suffice.
Now it appears that core has a number of instances where it doesn't respect the interface and just grabs publicly available properties:
Since the ENTITY_TYPE in your case is node (scheduler_node_presave) you 'could' presume the $node parameter is a NodeTypeInterface but still, accessing properties directly seems fishy.
Comment #7
taggartj commentedHad the same issue
Error: Call to a member function getThirdPartySetting() on null in /app/web/modules/contrib/scheduler/scheduler.module on line 333 #0 [internal function]: scheduler_node_presave(Object(Drupal\node\Entity\Node))
After testing this patch in PHP 7.1
https://www.drupal.org/files/issues/scheduler_fatal_error_call_to_member...
aka composer
patches":
"drupal/scheduler": {
"site install fix": "https://www.drupal.org/files/issues/scheduler_fatal_error_call_to_member..."
}
allowed me to get back in business !
thanks @ mpp
as you saved me time to make my own lol.
also Thanks for the hooks it made workbench integration not so bad.
Comment #8
jonathan1055 commentedHi taggartj,
What kind of things were you doing when the error happened? I'd like to replicate this.
@mmp,
Yes I see that it might be better if we use the functions in the EntityInterface I will try this.
Comment #9
jonathan1055 commentedI tried to use methods available in $node to detect if this parameter is as expected, for example
$node->getEntityTypeId(),$node->getType()and$node->getEntityType()to determine if methodgetThirdPartySetting()exists. I could not get it working as desired so decided to be safe and simply check for NULL as before.Comment #11
jonathan1055 commentedI'm going to call this fixed for now. However, it would be useful to add a test to cover the problem.