Problem/Motivation

Run a standard check against the Drupal coding standards (./vendor/bin/phpcs --standard=Drupal,DrupalPractice --extensions=php,module,inc,install,test,profile,theme,info,txt,md):

FILE: /app/web/modules/contrib/field_encrypt/src/Form/SettingsForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 136 | ERROR | [x] Use null coalesce operator instead of ternary
     |       |     operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...pp/web/modules/contrib/field_encrypt/src/Form/EntityTypeForm.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 184 | ERROR | [x] Use null coalesce operator instead of ternary
     |       |     operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: .../field_encrypt/src/Plugin/QueueWorker/UpdateEntityEncryption.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 6 | WARNING | [x] Unused use statement
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...encrypt/src/Plugin/Field/FieldType/EncryptedFieldStorageItem.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 95 | ERROR | unserialize() is insecure unless allowed classes are
    |       | limited. Use a safe format like JSON or use the
    |       | allowed_classes option.
----------------------------------------------------------------------


FILE: ...les/contrib/field_encrypt/tests/src/Functional/KeyChangeTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 38 | WARNING | [x] '@TODO: Simplify setUp() by extending
    |         |     EncryptTestBase when
    |         |     https://www.drupal.org/node/2692387 lands.'
    |         |     should match the format '@todo Fix problem X
    |         |     here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...trib/field_encrypt/tests/src/Functional/FieldEncryptTestBase.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 58 | WARNING | [x] '@TODO: Simplify setUp() by extending
    |         |     EncryptTestBase when
    |         |     https://www.drupal.org/node/2692387 lands.'
    |         |     should match the format '@todo Fix problem X
    |         |     here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...s/contrib/field_encrypt/tests/src/Functional/EntityHooksTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 36 | WARNING | [x] '@TODO: Simplify setUp() by extending
    |         |     EncryptTestBase when
    |         |     https://www.drupal.org/node/2692387 lands.'
    |         |     should match the format '@todo Fix problem X
    |         |     here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...les/contrib/field_encrypt/tests/src/Functional/BaseFieldTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 43 | WARNING | [x] '@TODO: Simplify setUp() by extending
    |         |     EncryptTestBase when
    |         |     https://www.drupal.org/node/2692387 lands.'
    |         |     should match the format '@todo Fix problem X
    |         |     here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...s/contrib/field_encrypt/tests/src/Functional/EncryptUserTest.php
----------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
----------------------------------------------------------------------
 36 | WARNING | [x] '@TODO: Simplify setUp() by extending
    |         |     EncryptTestBase when
    |         |     https://www.drupal.org/node/2692387 lands.'
    |         |     should match the format '@todo Fix problem X
    |         |     here.'
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: ...crypt/tests/modules/field_encrypt_test/field_encrypt_test.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 80 | ERROR | [x] Data types in @var tags need to be fully namespaced
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------


FILE: /app/web/modules/contrib/field_encrypt/field_encrypt.module
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 69 | ERROR | [x] Use null coalesce operator instead of ternary
    |       |     operator.
----------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Command icon 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

ptmkenny created an issue. See original summary.

ptmkenny’s picture

Status: Active » Needs review

This MR fixes all the above-reported issues except

FILE: ...encrypt/src/Plugin/Field/FieldType/EncryptedFieldStorageItem.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 95 | ERROR | unserialize() is insecure unless allowed classes are
    |       | limited. Use a safe format like JSON or use the
    |       | allowed_classes option.
----------------------------------------------------------------------

I'm not sure what the best way to fix this is because according to a comment in the PHP manual, "allowed_classes does not use inheritance" (https://www.php.net/manual/en/function.unserialize.php#125543) so it seems we would have to somehow generate an exhaustive list...

LeoAlcci’s picture

Assigned: Unassigned » LeoAlcci
Category: Bug report » Task

I will review and work on it!

LeoAlcci’s picture

Thanks for the contribution @ptmkenny, I fixed all phpcs issues, please kindly review It.

LeoAlcci’s picture

Assigned: LeoAlcci » Unassigned
Arturo-q’s picture

Assigned: Unassigned » Arturo-q

Hi, I will review it.

Arturo-q’s picture

Assigned: Arturo-q » Unassigned
Status: Needs review » Reviewed & tested by the community

@leoAlcci thanks for the contribution, I reviewed it and all CS errors/warnings are gone and all the test passed as well.
Moving to RTBC.

ptmkenny’s picture

@Arturo1007 Did you test actually using this module and enabling encryption for some content types? Simply saying "the tests passed" isn't really an RTBC review, because the tests are run automatically anyway.

  • alexpott committed 81e0eca9 on 3.1.x
    Issue #3312771 by ptmkenny, LeoAlcci, alexpott: Fixes for coding...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed
alexpott’s picture

Version: 3.0.x-dev » 3.1.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.