Problem/Motivation

\Drupal\serialization\Normalizer\FieldableEntityNormalizerTrait::extractBundleData() has the following docblock:

   * @return string
   *   The valid bundle name.

However, the return value is an array:

    return [$bundle_key => $bundle_value];

Steps to reproduce

Proposed resolution

Fix the docblock to match the code.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

rivimey’s picture

Suggested by https://lendude.gitlab.io/bug-smash-initiative/

Issue is correct, docs return type is incorrect. Patch fixes that and improves some other aspects of that function docblock.

nod_’s picture

Status: Active » Needs review
longwave’s picture

Status: Needs review » Needs work

CSpell caught a spelling error:

+++ b/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php	(date 1669340677958)
@@ -82,14 +82,16 @@
+   *   If the bundle value is invalid or the bundle type is ineligable.

ineligable -> ineligible

Otherwise this looks good to me.

_pratik_’s picture

Assigned: Unassigned » _pratik_
_pratik_’s picture

Assigned: _pratik_ » Unassigned
Status: Needs work » Needs review
FileSize
1.31 KB
736 bytes

Attache updated patch with inter diff
Thanks

rivimey’s picture

Status: Needs review » Reviewed & tested by the community

Do it!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php
@@ -82,14 +82,16 @@ protected function getEntityTypeDefinition($entity_type_id) {
-   *   The data being denormalized.
+   *   The data being denormalized. On return, $data[$bundle_key] will have been
+   *   unset, where $bundle_key is read from the entity type (provided).

This documentation is confusing. It took me a while to get why this was here. At first I was wondering why we are documenting return things in @param. But I see, this is passed in by reference. For me the current comment is a bit to like implementation. I think this will be clearer and easier to think about if it was more similar to the comment where this method is called:

        // Get an array containing the bundle only. This also remove the bundle
        // key from the $data array.
        $create_params = $this->extractBundleData($data, $entity_type_definition);

So something like:

   * @param array $data
   *   The data being denormalized. The bundle information will be removed.
asad_ahmed’s picture

Status: Needs work » Needs review
FileSize
1.23 KB
801 bytes

Made changes as per #13. Please review. Thanks

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/modules/serialization/src/Normalizer/FieldableEntityNormalizerTrait.php
@@ -82,14 +82,15 @@ protected function getEntityTypeDefinition($entity_type_id) {
    * @param array $data
-   *   The data being denormalized.
+   * The data being denormalized. The bundle information will be removed.
    * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type_definition

The indentation of the new text is not correct here.

NivethaSubramaniyan’s picture

Status: Needs work » Needs review
FileSize
1.23 KB

Fixing CCF in #14

nod_’s picture

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

Version: 10.1.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 7ad6ad979a to 10.1.x and a4fc325d58 to 10.0.x and 0114e01cba to 9.5.x and 7af567b658 to 9.4.x. Thanks!

  • alexpott committed 7ad6ad9 on 10.1.x
    Issue #3174108 by _pratik_, asad_ahmed, rivimey, NivethaSubramaniyan,...

  • alexpott committed a4fc325 on 10.0.x
    Issue #3174108 by _pratik_, asad_ahmed, rivimey, NivethaSubramaniyan,...

  • alexpott committed 0114e01 on 9.5.x
    Issue #3174108 by _pratik_, asad_ahmed, rivimey, NivethaSubramaniyan,...

  • alexpott committed 7af567b on 9.4.x
    Issue #3174108 by _pratik_, asad_ahmed, rivimey, NivethaSubramaniyan,...

Status: Fixed » Closed (fixed)

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