Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am using the latest Dev version with the fontawesome icons. I set up a block and fill in the ones that I want then save it. Everything works great until I go to edit it at which point everything under platforms except for Youtube vanishes.
Thoughts? Suggestions?
Comment | File | Size | Author |
---|---|---|---|
#14 | 2878942-14-weight-issue.patch | 7.94 KB | cbeier |
#9 | 2878942-9-weights-issue.patch | 3.39 KB | smaz |
Comments
Comment #2
cbeier CreditAttribution: cbeier commentedDo you use a adblocker extension (or similar, like uBlock) in your browser?
Comment #3
Christopher Riley CreditAttribution: Christopher Riley commentedActually I do use adblock plus but it is disabled on the site.
Comment #4
cbeier CreditAttribution: cbeier commentedBecause, often adblocker will hide the social media icons.
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous commentedI believe I am having a similar issue. In my case, I can configure the block when I initially use "Place block". However, if I go to edit the block, all options except for Drupal are removed.
I am not using an adblocker, and I have also tested this in Chrome using incognito mode with no extensions being loaded.
Comment #6
cbeier CreditAttribution: cbeier commentedHmmm, I have no idea what the problem might be. In my work and test instances I don't have the behavior.
What for php version are you using and is there any error messages?
Comment #7
dddbbb CreditAttribution: dddbbb as a volunteer commentedSame issue here. No ad blocker in use. PHP 7.0.16.
Comment #8
smazYup, same issue - very easy to reproduce:
1. Install module
2. Add new "Social Media Links" block to a region.
3. Configure block to include 1 or more social accounts. No need to play with any other config.
4. Save new block.
5. Edit said block (either via blocks admin UI or contextual link - doesn't matter)
6. Platforms listed in the edit screen will be only 1: YouTube.
7. Rendered block will still display platforms as per your original configuration.
The reason:
The platforms were all saved with a weight of -10.
SocialMediaLinksBlock::getPlatforms loops through the platforms, and builds an array keyed by weight so that it can be sorted.
Because of the weights all being -10, each loop through the platforms just overwrites one key, and just leaves Youtube at the end.
Will see if I can fix.
Comment #9
smazPatch attached. I've tested this with both existing & new blocks.
The issue:
Caused by https://www.drupal.org/node/2873603.
The default maximum weight range of a weight field is -10 to 10.
Because the default was being set to 100, this was outside of that range & so the default value was then set to the first option in the list, -10.
As mentioned, SocialMediaLinksBlock::getPlatforms set the key of an array to be the weight. All having -10, you ended up with just one option.
To fix this, I've:
* Changed SocialMediaLinksBlock::getPlatforms to add a #weight property to each platform, then sort on this. This means that duplicate weights won't cause this issue again.
* Kept a note of what the highest weight is, added the number of platforms to this & set this as the maximum delta for the weight field.
* Because each platform has a #weight property, we can use that rather than `$this->getPlatformWeight($platform_id, $default_weight);` every time we want to know the weight.
Comment #10
dddbbb CreditAttribution: dddbbb as a volunteer commented@smaz I recognise those reproduction steps! ಥ_ಥ
Comment #11
smazApologies - meant to say!
Credit to @danbohea for providing me the steps to reproduce this :)
Comment #12
cbeier CreditAttribution: cbeier commentedYes, I have today catch a similar problem in a new feature implementation for this module (commit). So I can port the solution from this location also to this form.
#9: For the weight sort we can use the default Drupal callbacks from class: Drupal\Component\Utility\SortArray
Comment #13
cbeier CreditAttribution: cbeier commentedComment #14
cbeier CreditAttribution: cbeier commented@smaz Thank your for your work and explanation. I have your patch refactored and adjusted to my developments from the last days.
New patch is attached. Feel free to test it. :)
I will commit and create a new release asap.
Comment #15
dddbbb CreditAttribution: dddbbb as a volunteer commentedPatch in #14 works as expected for me. Thanks all.
Comment #17
cbeier CreditAttribution: cbeier commentedI have committed the last patch to the 8.x-2.x branch.
I will create a new stable release latest tomorrow (25.05.2017) including this fix.