Problem/Motivation
In \Drupal\focal_point\FocalPointManager::getCropEntity(), we use \Drupal\crop\Entity\Crop::cropExists() before calling \Drupal\crop\Entity\Crop::findCrop() or creating a new Crop entity.
This can cause a point of failure when cropExists returns TRUE and findCrop returns NULL (this can happen during migrations or content deployment for example) and it adds an unneeded database request.
FYI, the type of error triggered in this case is:
Error: Call to a member function isNew() on null in /app/web/modules/contrib/focal_point/focal_point.module on line 79 #0 /app/web/modules/contrib/focal_point/focal_point.module(53): focal_point_entity_update(Object(Drupal\media\Entity\Media))
Proposed resolution
Only use the \Drupal\crop\Entity\Crop::findCrop() method and test its result.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | 3513777-5.patch | 744 bytes | duaelfr |
Issue fork focal_point-3513777
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 #4
duaelfrComment #5
duaelfrHere is a patch for composer
Comment #6
catchJust found this profiling a site, the MR is exactly what I came up with.
I'm seeing this take 40ms compared to 20ms for actually loading the crop entity, maybe due to the entity query that runs, so bumping priority.
Comment #8
rajeshreeputraAdded to merge train!