Problem/Motivation
In the user stream page (user/*/stream) I have an error saying
Warning: Illegal string offset '#markup' in social_core_preprocess_block() (line 408 of profiles/contrib/social/modules/social_features/social_core/social_core.module).
Steps to reproduce
Go to user > profile, an error is shown complaining about #Markup
Proposed resolution
Replace actual code (around line 408)
$variables['button_text'] = t('All @label', [
'@label' => $variables['label']['#markup'],
]);
With
if (isset($variables['label']['#markup'])) {
$label = $variables['label']['#markup'];
}
else {
$label = t('events');
}
$variables['button_text'] = t('All @label', [
'@label' => $label,
]);
Remaining tasks
Creating a patch for this issue
User interface changes
None
API changes
None
Data model changes
None
Comments
Comment #2
immaculatexavier commentedComment #3
avpadernoComment #4
immaculatexavier commentedAttached patch in accordance to the proposed resolution
Comment #5
avpadernoSince PHP 7 is required, that code can be written on a single line, with the null coalescing operator.
Comment #6
pflora commentedThank you for your suggestion, @apaderno!
Here's a patch with the requested changes.
Comment #7
avpadernoThat's not how the null coalescing operator is used.
Comment #8
immaculatexavier commentedAttached patch against #6 and #7
Comment #9
avpadernoEventually, the code could directly set
'@label'without using a intermediate variable, if the resulting line doesn't exceed the 80-character limit, but I will let the project maintainers decide about that.Comment #10
tbsiqueiraThank you all for your work!
I created a PR for this change, and also made a slight change on the proposed solution, I removed the
t()function from the "else" because the text is already encapsulated on at()functionhttps://github.com/goalgorilla/open_social/pull/3155
Comment #11
tbsiqueiraIssue is fixed and will be available on the next 11.4.x and above versions