Error SocialAuthSettingsForm & TwitterAuth

Created on 17 October 2023, about 1 year ago

Error: Call to a member function getBaseId() on null in /var/www/html/project/www/modules/contrib/social_auth/src/Form/SocialAuthSettingsForm.php on line 81 #0 /var/www/html/project/www/modules/contrib/social_auth_twitter/src/Form/TwitterAuthSettingsForm.php(68): Drupal\\social_auth\\Form\\SocialAuthSettingsForm->buildForm()\

🐛 Bug report
Status

Active

Version

4.0

Component

Code

Created by

🇫🇷France Nicolas S. Lyon, France

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

Comments & Activities

  • Issue created by @Nicolas S.
  • Assigned to sarwan_verma
  • 🇫🇷France Nicolas S. Lyon, France

    With this diff a fix more error but now on this form settings /admin/config/social-api/social-auth/twitter

    I have this error but I don't see where it is

    Uncaught PHP Exception Symfony\\Component\\Routing\\Exception\\RouteNotFoundException: "Route "" does not exist." at /var/www/html/project/www/core/lib/Drupal/Core/Routing/RouteProvider.php line 206

    diff --git a/social_auth_twitter/src/Form/TwitterAuthSettingsForm.php b/social_auth_twitter/src/Form/TwitterAuthSettingsForm.php
    index fb976a351..7b8f0a229 100644
    --- a/social_auth_twitter/src/Form/TwitterAuthSettingsForm.php
    +++ b/social_auth_twitter/src/Form/TwitterAuthSettingsForm.php
    @@ -33,6 +33,10 @@ protected function getEditableConfigNames(): array {
    * {@inheritdoc}
    */
    public function buildForm(array $form, FormStateInterface $form_state, ?NetworkInterface $network = NULL): array {
    + /** @var \Drupal\social_auth\Plugin\Network\NetworkInterface $network */
    + $network = $this->networkManager->createInstance('social_auth_twitter');
    + $form = parent::buildForm($form, $form_state, $network);
    +
    $config = $this->config('social_auth_twitter.settings');

    $form['twitter_settings'] = [
    @@ -65,7 +69,7 @@ public function buildForm(array $form, FormStateInterface $form_state, ?NetworkI
    '#default_value' => Url::fromRoute('social_auth_twitter.callback')->setAbsolute()->toString(),
    ];

    - return parent::buildForm($form, $form_state);
    + return $form;
    }

    /**
    diff --git a/social_auth_twitter/src/Plugin/Network/TwitterAuth.php b/social_auth_twitter/src/Plugin/Network/TwitterAuth.php
    index d442d9154..ccd99787b 100644
    --- a/social_auth_twitter/src/Plugin/Network/TwitterAuth.php
    +++ b/social_auth_twitter/src/Plugin/Network/TwitterAuth.php
    @@ -6,6 +6,7 @@
    use Drupal\social_api\SocialApiException;
    use Drupal\social_auth\Plugin\Network\NetworkBase;
    use Abraham\TwitterOAuth\TwitterOAuth;
    +use Drupal\social_auth\Settings\SettingsInterface;
    use Drupal\social_auth_twitter\Settings\TwitterAuthSettingsInterface;

    /**
    @@ -28,7 +29,7 @@ class TwitterAuth extends NetworkBase implements TwitterAuthInterface {
    /**
    * {@inheritdoc}
    */
    - public function initSdk() {
    + public function initSdk(): mixed {
    $class_name = '\Abraham\TwitterOAuth\TwitterOAuth';

    if (!class_exists($class_name)) {
    @@ -88,7 +89,7 @@ public function getSdk2($oauth_token, $oauth_token_secret) {
    * True if module is configured.
    * False otherwise.
    */
    - protected function validateConfig(TwitterAuthSettingsInterface $settings) {
    + protected function validateConfig(SettingsInterface $settings): bool {
    $consumer_key = $settings->getConsumerKey();
    $consumer_secret = $settings->getConsumerSecret();
    if (!$consumer_key || !$consumer_secret) {

Production build 0.71.5 2024