Parcourir la source

fixing saving of usernames

logicp il y a 7 ans
Parent
commit
934eb704e2
1 fichiers modifiés avec 4 ajouts et 3 suppressions
  1. 4 3
      src/StatusTwitter.php

+ 4 - 3
src/StatusTwitter.php

@@ -252,15 +252,16 @@ class StatusTwitter {
         $terms->tags[] = array_values($term)[0];
       }
     }
+    $term = null;
     foreach($data->entities->user_mentions as $u) {
       $terms->users[] = $u->screen_name;
-      $term = \Drupal::entityQuery('taxonomy_term')->condition('name', $h->text)->execute();
+      $term = \Drupal::entityQuery('taxonomy_term')->condition('name', $u->text)->execute();
       if (count($term) < 1) {
-        $term = Term::create(['name' => $h->text, 'vid' => 'twitter_user']);
+        $term = Term::create(['name' => $u->screen_name, 'vid' => 'twitter_user']);
         if ($term->save()) {
           $terms->users[] = $term->id();
         } else {
-          \Drupal::logger('StatusTwitter')->warning('Could not save term with name %name', array('%name' => $h->text));
+          \Drupal::logger('StatusTwitter')->warning('Could not save term with name %name', array('%name' => $u->screen_name));
         }
       } else {
         $terms->users[] = array_values($term)[0];