Cron broken when they trying to encrypt existing data ( Using Queue worker ) .
Reason : i deleted the old data but Queue worker have their entityId , so the try to load that entity but they not exist and it through fatal error .
Solution : check Entity Exist or not .
error :

 PHP Fatal error:  Call to a member function getTranslationLanguage
s() on a non-object in /var/www/html/ttn-reimbursement/modules/contrib/field_encrypt/src/FieldEncryptProcessEntities.php on line 406
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jitendra verma created an issue. See original summary.

Jitendra verma’s picture

Jitendra verma’s picture

Assigned: Unassigned » Jitendra verma
Status: Active » Needs review
daggerhart’s picture

Status: Needs review » Reviewed & tested by the community

I've run into this problem as well. Patch approach seems fine (testing that the entity can be loaded).

One very minor nitpick with the patch is defining variables for values that already exist in the $data variable. You could easily perform the entity existence check like this: \Drupal::entityTypeManager()->getStorage($data['entity_type'])->load($data['entity_id']);

Regardless, this patch applies and works for me, marking as reviewed.

perarg’s picture

It doesn't seem to work in 8.7.x. The problem seems to be that some entities allow revisions and others don't. The solution to this is to check if the entity type allows revision so in that case the check should be with loadRevision(). Otherwise the load() function should be used to get the entity.

Here is a patch fixing things. I have included also, @daggerhart little tip.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 5: field_encrypt-2900641-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

maskedjellybean’s picture

#5 works for me on 8.7.5! Thanks perarg!

ptmkenny’s picture

Status: Needs work » Closed (outdated)

I'm closing this issue because this is fixed in 3.x; UpdateEntityEncryption.php already contains similar logic.