- Issue created by @hussainweb
- Assigned to Shreya_98
- First commit to issue fork.
- 🇮🇳India sarwan_verma
Hi @hussainweb,
I have fixed this issue " Attempt to read property "value" on array in Drupal\do_username\DOComputedFields->getValue()" and also attached patch ,
please review and verify. - 🇮🇳India jagraj_singh_gill
Hello @hussainweb,
I have fixed this issue 'Attempt to read property "value" on array in Drupal\do_username\DOComputedFields->getValue()' and also attached patch.
I feel there were only one change required as all other fields were not fetching any array data.
Please review and verify.Thank You !!
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 6:22am 19 October 2023 - 🇮🇳India Shreya_98
@sarwan_verma i have applied your patch on my local but it doesn't resolved my error.
- 🇮🇳India Shreya_98
Hi @hussainweb,
I have fixed this issue and it is also working fine on my local . Also created MR for this issue . Kindly review the changes.Thank you!
- 🇨🇦Canada hussainweb
Thanks for the fixes.
@Shreya_th, I see your patch and MR are different. The patch has accidentally changed the indentation.
+++ b/src/DOComputedFields.php @@ -33,42 +33,59 @@ class DOComputedFields extends TypedData { + return is_array($userInformation->field_bio) && isset($userInformation->field_bio[0]['value']) ? $userInformation->field_bio[0]['value'] : 'N/A';
I see you are treating the `$userInformation` as a Drupal field value. It is not. It is a simple PHP class and the `field_bio` (magic) property is not an array (unless it is empty). So the above code will always return "N/A". Yes, it won't throw an error.
In your MR, on the other hand, you are using a function called `get` but that function doesn't exist on the `User` class at all (nor on the base class).
- Status changed to Needs work
about 1 year ago 12:32pm 19 October 2023 - 🇨🇦Canada hussainweb
@jagraj_singh_gill, your change is good in theory but we should return an empty string rather than `NULL`. This value gets used within Drupal and I am worried this NULL will throw other errors. We only hit this case when the bio is empty on Drupal.org. In that case, empty string is good enough. Please make this change and I can commit.
- 🇮🇳India Shreya_98
Hi @hussainweb,
Sorry for the mistake, I have made changes as per your requirement . kindly review the changes. - 🇨🇦Canada hussainweb
Thanks, @Shreya_th. I am afraid this doesn't work either. You are reading the expression into a variable and the warning is generated at that point. By the time you check for `!empty`, the warning is already generated.
The fix is to use the null-coalescing operator.
- 🇮🇳India jagraj_singh_gill
Hi @hussainweb,
Thank you for your feedback. I have revised my patch and attached it. Please review and verify. Thanks again !! -
hussainweb →
committed fb701722 on 2.x authored by
jagraj_singh_gill →
Issue #3394985 by jagraj_singh_gill: Attempt to read property "value" on...
-
hussainweb →
committed fb701722 on 2.x authored by
jagraj_singh_gill →
- Status changed to Fixed
about 1 year ago 5:46pm 20 October 2023 Automatically closed - issue fixed for 2 weeks with no activity.