- 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?