Closed (fixed)
Project:
Drupal.org username field
Version:
2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
18 Oct 2023 at 17:25 UTC
Updated:
5 Sep 2024 at 16:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
shreya_th commentedComment #4
sarwan_verma commentedHi @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.
Comment #5
jagraj_singh_gill commentedHello @hussainweb,
I have fixed the issue and also attached the patch. I feel there was only one change required and we can use null-coalescing operator there which will fix the issue for us.
Please review and verify.
Thank You !!
Comment #7
shreya_th commented@sarwan_verma i have applied your patch on my local but it doesn't resolved my error.
Comment #8
shreya_th commentedHi @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!
Comment #9
hussainwebThanks for the fixes.
@Shreya_th, I see your patch and MR are different. The patch has accidentally changed the indentation.
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).
Comment #10
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.
Comment #11
shreya_th commentedHi @hussainweb,
Sorry for the mistake, I have made changes as per your requirement . kindly review the changes.
Comment #12
hussainwebThanks, @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.
Comment #13
jagraj_singh_gill commentedHi @hussainweb,
Thank you for your feedback. I have revised my patch and also attached it. Please review and verify. Thanks again !!
Comment #15
hussainwebCommitted and pushed. Thanks!