- Issue created by @dave_______1
- 🇬🇧United Kingdom 2dareis2do
Hi Dave
Thanks for posting this issue.
I have this working locally but I am using with
"name": "drupal/social_api", "version": "3.1.0",
I have not really looked into this but it sounds like something may have broken this in social_api 4.x
- 🇬🇧United Kingdom 2dareis2do
It looks like the signature has changed on 4.x branch. I n particular sdk is a mixed type. mixed type was introduced in php 8.0. Probably this needs updating so that the child class has the same.
e.g.
3.x
/** * Sets the underlying SDK library. * * @return mixed * The initialized 3rd party library instance. * * @throws \Drupal\social_api\SocialApiException * If the SDK library does not exist or other validation fails. */ abstract protected function initSdk(): mixed;
4.x
/** * The SDK client. * * @var mixed */ protected mixed $sdk = NULL;
I think the quick fix (and to check this) would be to make sure you are using social post 3.x
e.g. in your project require
"drupal/social_post": "^3.0",
1. Probably need to specify a version of social_post that is compatible currently 3.x
2. Test with 4.x version and a make sure signature is the same
3. Make 4.x compatible - 🇬🇧United Kingdom 2dareis2do
Sorry previous comments about the signature were incorrect. Please ignore.
One thing I was wondering is how you managed to install social_api 4.x as from what I can see social_post has dependency of 3.x?
The latest version of social_post is still 3.x afict
https://git.drupalcode.org/project/social_post/-/blob/3.x/composer.json?...
- 🇬🇧United Kingdom 2dareis2do
Ok so for social api 4.x we have social_api/src/Plugin/NetworkInterface.php
https://git.drupalcode.org/project/social_api/-/blob/4.0.x/src/Plugin/Ne...
<?php namespace Drupal\social_api\Plugin; use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; /** * Defines an interface for Social Network plugins. */ interface NetworkInterface extends PluginInspectionInterface, ContainerFactoryPluginInterface { /** * Gets the underlying SDK library. * * @return mixed * The SDK client. */ public function getSdk(): mixed; }
where as in 3.x branch it is just:
<?php namespace Drupal\social_api\Plugin; use Drupal\Component\Plugin\PluginInspectionInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; /** * Defines an interface for Social Network plugins. */ interface NetworkInterface extends PluginInspectionInterface, ContainerFactoryPluginInterface { /** * Gets the underlying SDK library. * * @return mixed * The SDK client. */ public function getSdk(); }
Notice how the signature has changed
in
we have
/** * {@inheritdoc} */ protected function initSdk() { $class_name = '\Abraham\TwitterOAuth\TwitterOAuth'; if (!class_exists($class_name)) { throw new SocialApiException(sprintf('The PHP SDK for X could not be found. Class: %s.', $class_name)); } /** @var \Drupal\social_post_x\Settings\XPostSettings $settings */ $settings = $this->settings; retu
so perhaps this need to be updated so that we have
protected function initSdk(): mixed {
That said I am still not sure why you have social_api 4.x installed?
- 🇬🇧United Kingdom 2dareis2do
Ok so it looks like social_post 4.x that is compatible with social_api 4.x is in the works.
https://www.drupal.org/project/social_post/issues/3307661 💬 Support Social API v4 RTBC
Perhaps it makes sense to add a a new branch/tag that supports that?
- 🇬🇧United Kingdom dave_______1
Thanks for looking into this. That signature mixed is a bit woolly and doesn't make a whole lot of difference, but I'd expect a change to the actual return value in the future. Might just be to pass linting rules...
To get around this I added a change in workflow, the editor now creates content, and when happy, uses the share button on the Front End to post to different social networks.
However, this workflow does not work for the scheduled content, which needs an automated approach like yours, so I'll need to add a ticket to try again.FYI I try not to use composer for the modules, I download and install manually. I've had problems with module dependencies and changes in the past, so when I get a selection that works together I add them to the repo. I can then duplicate the site with modules for different clients. If I need to update, I can do it locally and test everything before I go to prod. Symfony, Laravel or other PHP project I use Composer