TypeError: Drupal\social_media_links\SocialMediaLinksPlatformManager::getPlatformsWithValue(): Argument #1 ($platforms) must be of type array, null given

Created on 18 August 2025, about 2 months ago

Problem/Motivation

This error occurs if any other module creates the block plugin instance and calls the build method:

```
TypeError: Drupal\social_media_links\SocialMediaLinksPlatformManager::getPlatformsWithValue(): Argument #1 ($platforms) must be of type array, null given, called in /var/www/html/web/modules/contrib/social_media_links/src/Plugin/Block/SocialMediaLinksBlock.php on line 358 in Drupal\social_media_links\SocialMediaLinksPlatformManager->getPlatformsWithValue() (line 85 of /var/www/html/web/modules/contrib/social_media_links/src/SocialMediaLinksPlatformManager.php).
```

And that's fine, doing this in custom code could be easily fixed by passing extra configurations. But when other modules do that, you'll see the error. For example, the experience builder β†’ module.

\Drupal\experience_builder\Plugin\ExperienceBuilder\ComponentSource\renderComponent()

Steps to reproduce

1. Install experience builder module, create first page to be able to populate it with components
2. Install social_media_links module
3. Check the website logs and see the error

Proposed resolution

In the build method of the SocialMediaLinksBlock assume that platforms might be empty:

```
$platforms = $this->platformManager->getPlatformsWithValue($config['platforms'] ?? []);
```
instead of

```
$platforms = $this->platformManager->getPlatformsWithValue($config['platforms']);
```

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine quadrexdev Lutsk

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024