Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Lots more exception throwing and catching is needed throughout the code base, especially for all simple_sitemap API methods.
Issue fork simple_sitemap-3027987
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
joshi.rohit100Patch added.
Comment #3
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedWhile this is a valid objection, it's not a bug, as you should do checks anyway when using the api directly.
Also this kind of improvements only end up in 3.x, as 2.x moves towards deprecation.
It would be beneficial to find all the places in the code where entities are loaded without that check. Lots more exception throwing and catching is needed throughout the code base. Looking forward to a patch!
Comment #4
joshi.rohit100@gbyte.co I raised for 2.x as currently we using this.
Regarding the check, the scenario was like that we called this api in custom code while deleting nodes. So somehow there was exception (deadlock) and node deleted partially. But this code still executed without checking object.
Comment #5
raselkabir CreditAttribution: raselkabir at Digitalist commentedSame problem for getEntityInstanceSettings also. So I am adding a patch for both.
Comment #6
raselkabir CreditAttribution: raselkabir at Digitalist commentedSame problem for getEntityInstanceSettings also. So I am adding a patch for both.
Comment #8
joshi.rohit100Setting as NW as this require try/catch instead entity object check.
Comment #9
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedI agree and committing a community provided patch adding exceptions to the API (and preferably elsewhere) would make my day.
Comment #10
GrimreaperHello,
I also encountered the problem when dealing with deleted entities.
Here is a patch that is more complete than patch from comment 6.
I have search in the module codebase 'load'.
Thanks for the review.
Comment #11
johnpicozziI was having the issue described here - https://www.drupal.org/project/simple_sitemap/issues/3066138
The patch in #10 above resolved the issue for me.
Comment #12
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commented@Grimreaper Please refer to #8. When using the API, we need sensible exceptions and not for the code to silently fail when an entity does not exist.
@johnpicozzi Try the latest dev, there have been some chanes in terms of checks when using UI. For raw API, you still need to make sure entities exist.
Comment #13
Grimreaper@gbyte.co The load() method on EntityStorageInterface does not trigger exception in case of error. So you mean triggering custom exceptions? Or before returning logging an error?
Comment #14
johnpicozziThe patch in #10 doesn't apply to 8.x-3.4, looks like it needs to be re-rolled.
Comment #15
GrimreaperHere is a patch for the last dev version (8.x-3.5 +1 commit).
Comment #16
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedYour changes add additional class checking on top of the entity exists check, but the class check should not be necessary here, as only content entities are allowed in the queue anyway.
API methods where the API is being used incorrectly should trigger a custom verbose exception; Drupal will log it automatically.
Comment #17
DamienMcKennaI just wanted to mention that I was having a lot of problems with the 8.x-3.6 release on a test infrastructure, the latest dev snapshot has resolves these and is working really well for us. Good work everyone!
Comment #18
GrimreaperHello,
Here is an updated patch because patch from comment 15 no more apply on 8.x-3.7.
I hope it takes comment 16 into account otherwise I don't see what is expected in this comment.
Regards,
Comment #19
GrimreaperOups, wrong patch...
Comment #20
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commentedI am addressing this in the 4.x rewrite of this module.
Comment #23
gbyte CreditAttribution: gbyte as a volunteer and at gbyte commented