Twitter Search Block is a module that displays twitter embedded timeline in a block.The module provides:

  • Easy Twitter OAuth Configuration with simple form
  • General Block that displays embedded timeline for given search query
  • Twitter Search Query as a Field Type that can be attached to content/node
  • Content specific Twitter Block to which twitter search query field is applied

Requirements

The module is dependent on two Drupal core modules:

  • Block
  • Field

OAuth Configuration

Twitter uses OAuth to provide authorized access to its API.
To get Twitter Access keys, you need to create Twitter Application which is mandatory to access Twitter.

  • Go to https://dev.twitter.com/apps/new and log in, if necessary
  • Enter your Application Name, Description and your website address. You can leave the callback URL empty.
  • Submit the form by clicking the Create your Twitter Application
  • Copy the consumer key (API key) and consumer secret from the screen into your application.Read More

Project link

https://drupal.org/sandbox/jyoti.singh/2742925

Git instructions

git clone --branch 8.x-1.x https://git.drupalcode.org/sandbox/jyoti.singh-2742925.git twitter_search_block

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jyoti.singh created an issue. See original summary.

PA robot’s picture

Issue summary: View changes
Status: Needs review » Needs work

There are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpsgitdrupalorgsandboxjyotisingh2742925git

Fixed the git clone URL in the issue summary for non-maintainer users.

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

jyoti.singh’s picture

jyoti.singh’s picture

Priority: Normal » Major
jyoti.singh’s picture

Issue summary: View changes
jyoti.singh’s picture

Issue summary: View changes
RavindraSingh’s picture

Use variable and make API url configurable

$url = 'https://api.twitter.com/1.1/search/tweets.json';

And Improve this in below mentioned way

API URL - https://api.twitter.com/
version - list (Supportive 1.1)

can be used for all the hardcoded API URLs

Comments can be improved in across the module.

Variable naming convention are not good. Try to make more meaningful variables

e.g $twitter1 to $twitter_output or $twitter_object

Move library in libraries directory. And then add a documentation and URLs to download the libraries in the realm file.

gisle’s picture

Priority: Major » Normal

Setting priority bak to "Normal".
Please read this to learn about how to use the priority field: https://www.drupal.org/node/539608

amankanoria’s picture

@JyotiS- Agree with @ravindrasingh. There are lots of commenting stuff that could be improved. Especially, after running a DrupalCoding standard check. Please find the reply below-

FILE: /twitter_search_block/src/Plugin/Block/TwitterAPIExchange.php
----------------------------------------------------------------------
FOUND 45 ERRORS AND 2 WARNINGS AFFECTING 45 LINES

jyoti.singh’s picture

I have removed all errors from code.Please review code : http://pareview.sh/pareview/httpsgitdrupalorgsandboxjyotisingh2742925git

zeeshan_khan’s picture

Hi @jyoti.singh,

I still see many warnings in the automated test result please fix those first, then I'll be happy to do manual review of your project.
Please also review couple of project in the issue queue to get Review Bonus, That will help in boosting your project review process :-)

Thanks

Automated Review

pareview.sh. https://git.drupal.org/sandbox/jyoti.singh/2742925.git

Review of the 8.x-1.x branch (commit 89ce6ef):

DrupalPractice has found some issues with your code, but could be false positives.
FILE: .../drupal-7-pareview/pareview_temp/src/Form/TwitterHashBlockConfig.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 12 WARNINGS AFFECTING 12 LINES
--------------------------------------------------------------------------
26 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
29 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
32 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
36 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
39 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
45 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
46 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
47 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
49 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
51 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
55 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
72 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

FILE: ...var/www/drupal-7-pareview/pareview_temp/src/Form/TwitterAuthForm.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 14 WARNINGS AFFECTING 14 LINES
--------------------------------------------------------------------------
26 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
29 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
32 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
36 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
39 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
43 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
46 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
50 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
53 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
57 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
59 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
61 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
65 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
82 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

FILE: .../www/drupal-7-pareview/pareview_temp/src/Plugin/Block/TweetBlock.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 3 WARNINGS AFFECTING 3 LINES
--------------------------------------------------------------------------
26 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
29 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
30 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

FILE: ...pal-7-pareview/pareview_temp/src/Plugin/Block/TwitterAPIExchange.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
122 | WARNING | Unused variable $key.
--------------------------------------------------------------------------

FILE: ...al-7-pareview/pareview_temp/src/Plugin/Block/TwitterBlockGeneral.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
26 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

jyoti.singh’s picture

Hi @zeeshan_khan,

"FormBase" class already uses "StringTranslationTrait" class for dependency injection.PHPCS does not throw any warning on my local setup.There is some issue with pareview.sh.Can you please check this at your end.

abhishek-anand’s picture

Looks like this is a problem with preview.sh. Any form that extends FormBase need not inject StringTranslationInterface as its already available.

jyoti.singh’s picture

Status: Needs work » Needs review
abhishek-anand’s picture

Status: Needs review » Needs work

In modules/2742925/src/Form/TwitterHashBlockConfig.php

/**
 * Provides configuration options for TWitter API.
 */
class TwitterHashBlockConfig extends FormBase {

This is a configuration form, so it should extend ConfigFormBase not FormBase.

      '#description' => t('Number of embedded tweets thet gets displayed inside the Block'),

Use $this->t()

  public function submitForm(array &$form, FormStateInterface $form_state) {

    $config = \Drupal::service('config.factory')->getEditable('twitter_search_block.settings');

Use $this->config not \Drupal::service('config.factory')

jyoti.singh’s picture

Resolved all the above issue :

  • Extended ConfigFormBase class in the file
  • Used $this->t() in the file.
  • Use $this->config
jyoti.singh’s picture

Status: Needs work » Needs review
zeeshan_khan’s picture

Status: Needs review » Needs work

Hi @jyoti.singh,
Please check and fix all the warnings came across from Drupal best practices. http://pareview.sh/pareview/httpsgitdrupalorgsandboxjyotisingh2742925git

Manual Review:

In modules/2742925/src/Form/TwitterHashBlockConfig.php line:84

    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => $this->t('Submit'),
    );
    // Return $form;.
    return parent::buildForm($form, $form_state);

Please remove commented code.

In modules/2742925/src/Form/TwitterHashBlockConfig.php line:91

public function validateForm(array &$form, FormStateInterface $form_state) {

  }

This function is blank please remove if it has no use.

In modules/2742925/src/Form/TwitterAuthForm.php line:27

public function buildForm(array $form, FormStateInterface $form_state) {

    $config = \Drupal::config('twitter_search_block.settings');
    $form['descriptions'] = [];

You are not using $form['descriptions'] any where. Please remove.

In modules/2742925/src/Form/TwitterAuthForm.php line:74

public function validateForm(array &$form, FormStateInterface $form_state) {

}

This function is blank please remove if it has no use.

In modules/2742925/src/Form/TwitterAuthForm.php line:83

$config = \Drupal::service('config.factory')->getEditable('twitter_search_block.settings');

Use $this->config instead \Drupal::service('config.factory').

Best,
Zeeshan

jyoti.singh’s picture

@zeeshan_khan : Removed dependency injection warning from the module : http://pareview.sh/pareview/httpsgitdrupalorgsandboxjyotisingh2742925git.

It gives one warning for node load.Is the usage correct : \Drupal::request()->attributes->get('node');

jyoti.singh’s picture

Status: Needs work » Needs review
ARUN AK’s picture

Status: Needs review » Needs work

Hi jyoti.singh,

Please see my comments below:

  1. Give a human readable name for your module in twitter_search_block.info.yml.
  2. Instead of 'Custom', categorize your module on the basis of functionality.
  3. I installed and configured module in local.
    (*) After install and assign Twitter Block:General sidebar region, getting error "The website encountered an unexpected error. Please try again later.".
    In watchdog it showing

    Exception: Failed to connect to api.twitter.com port 443: Connection refused in Drupal\twitter_search_block\Plugin\Block\TwitterAPIExchange->performRequest() (line 308 of C:\wamp\www\www_d8test1_com\modules\twitter_search_block\src\Plugin\Block\TwitterAPIExchange.php).

  4. Use httpClient(Guzzle) instead of curl to make http requests. Found use of curl() in TwitterAPIExchange.php.

Thanks,
ARUN AK

jyoti.singh’s picture

Issue summary: View changes
jyoti.singh’s picture

Thank you Arun AK.
Corrected the name and package for the Module.
Usually this error is one that's caused by a firewall on your server.The curl is used by Twitter Library itself.Can you please check once disabling the firewall.
Thank you.

amankanoria’s picture

Hi @jyoti.singh,

Could you check the Node block if it is working properly? The field does get called in the managed field but it displays the data as plain text. Apart from it, If I modify the values of the field after adding contents it is allowing me to make changes to field settings page which should not be the case as well. The General Block is working fine for me. I could not replicate @Arun AK issue. Please ignore my comments if the node functionality is still in progress. If yes, I would suggest to remove it for the time being and get it incurred after an initial release. I second with Arun AK for removing the Curl request instead use -httpClient(Guzzle) as recommended.

Thanks
Aman K

RavindraSingh’s picture

Following areas still needs to be improved -

1. Not in use "use Drupal\Core\Config\ConfigFactory;" from TweetBlock.php under Plugin/Block.
2. Why the "article" is hardcoded in $bundle_fields = $this->entityManager->getFieldDefinitions('node', 'article');
3. if ($bundle_fields[$field_name]->getType() == 'twitter_search_fieldtype') {
$field_data[] = $field_name;
}
4. Can't we use break if the the $field_name]->getType() == 'twitter_search_fieldtype' is going to attach once only.?

5. $url = 'https://api.twitter.com/1.1/search/tweets.json';
URL and API version can be configurable.

6. &hide_media=true&maxwidth=260&hide_thread=true';
All these parameter should be configurable and default set with mentioned one.

7. For replacing Guzzle please refer the link - http://docs.guzzlephp.org/en/latest/

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

jyoti.singh’s picture

@Ravindra : For Comment #25

1. Not in use "use Drupal\Core\Config\ConfigFactory;" from TweetBlock.php under Plugin/Block. - Fixed
2. Why the "article" is hardcoded in $bundle_fields = $this->entityManager->getFieldDefinitions('node', 'article'); -Fixed
3. if ($bundle_fields[$field_name]->getType() == 'twitter_search_fieldtype') {
$field_data[] = $field_name;
} -Fixed
4. Can't we use break if the the $field_name]->getType() == 'twitter_search_fieldtype' is going to attach once only.?-Fixed

5. $url = 'https://api.twitter.com/1.1/search/tweets.json';
URL and API version can be configurable. - Fixed

6. &hide_media=true&maxwidth=260&hide_thread=true';
All these parameter should be configurable and default set with mentioned one.

7. For replacing Guzzle please refer the link - http://docs.guzzlephp.org/en/latest/

For point 6 and 7 since we are using the extrenal library for Twitter I am keeping it intact as the library may upgrade with time so we may need to replace the library with the latest one.

jyoti.singh’s picture

Status: Closed (won't fix) » Needs review
zeeshan_khan’s picture

Status: Needs review » Needs work

Hi @jyoti.singh,

I steel see some code standard issues with your project in automated review. Please use coder and code sniffer to fix them up

Review of the 8.x-1.x branch (commit f85eaf8):

Coder Sniffer has found some issues with your code (please check the Drupal coding standards). See attachment.
DrupalPractice has found some issues with your code, but could be false positives.
FILE: /root/repos/pareviewsh/pareview_temp/src/Plugin/Block/TweetBlock.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
89 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

FILE: /root/repos/pareviewsh/pareview_temp/src/Form/TwitterAuthForm.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
103 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
--------------------------------------------------------------------------

Time: 54ms; Memory: 6Mb

No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.
This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

FILE: ...pos/pareviewsh/pareview_temp/src/Plugin/Block/TwitterAPIExchange.php
--------------------------------------------------------------------------
FOUND 5 ERRORS AFFECTING 5 LINES
--------------------------------------------------------------------------
1 | ERROR | [x] The PHP open tag must be followed by exactly one blank
| | line
2 | ERROR | [x] There must be one blank line after the namespace
| | declaration
273 | ERROR | [ ] Type hint "array" missing for $curlOptions
329 | ERROR | [ ] Type hint "array" missing for $params
386 | ERROR | [ ] Type hint "array" missing for $curlOptions
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: .../repos/pareviewsh/pareview_temp/src/Plugin/Block/TwitterAPIClass.php
--------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
--------------------------------------------------------------------------
3 | ERROR | [x] There must be one blank line after the namespace
| | declaration
22 | ERROR | [ ] Type hint "array" missing for $settings
32 | ERROR | [x] Object operator not indented correctly; expected 6
| | spaces but found 12
43 | ERROR | [x] Object operator not indented correctly; expected 8
| | spaces but found 16
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: /root/repos/pareviewsh/pareview_temp/src/Form/TwitterAuthForm.php
--------------------------------------------------------------------------
FOUND 7 ERRORS AND 1 WARNING AFFECTING 7 LINES
--------------------------------------------------------------------------
83 | ERROR | [x] Line indented incorrectly; expected 4 spaces, found 5
84 | ERROR | [x] Array indentation error, expected 7 spaces but found
| | 5
85 | ERROR | [x] Array indentation error, expected 7 spaces but found
| | 5
86 | ERROR | [x] Array indentation error, expected 7 spaces but found
| | 5
87 | ERROR | [x] Array indentation error, expected 7 spaces but found
| | 5
88 | ERROR | [x] Array indentation error, expected 7 spaces but found
| | 5
89 | ERROR | [x] Array indentation error, expected 7 spaces but found
| | 5
89 | WARNING | [ ] Translatable strings must not begin or end with white
| | spaces, use placeholders with t() for variables
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 7 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: /root/repos/pareviewsh/pareview_temp/twitter_search_block.info.yml
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
1 | WARNING | Remove "version" from the info file, it will be added by
| | drupal.org packaging automatically
--------------------------------------------------------------------------

Time: 193ms; Memory: 8Mb

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

jyoti.singh’s picture

Status: Closed (won't fix) » Needs review

All the above errors and warning from pareview fixed , except :

FILE: /root/repos/pareviewsh/pareview_temp/src/Plugin/Block/TweetBlock.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
89 | WARNING | \Drupal calls should be avoided in classes, use
| | dependency injection instead
----------------------------------

The error is due to using node load statement : $node = \Drupal::request()->attributes->get('node'); how can we load node with dependency injection.

jyoti.singh’s picture

All the Pareview warning are cleared for the module : https://pareview.sh/node/276

Shamsher_Alam’s picture

Status: Needs review » Reviewed & tested by the community

Hi Jyoti,

I have tested and reviewed your module. Every thing is going very smooth and code is also as per Drupal coding standard. Good work and thanks for contributions.

Please @all i think now nothing is pending in this and we should proceed it to for publishing state.

amankanoria’s picture

@Jyoti.singh The module is working fine and code is following coding standards as well. Great Stuff!

visabhishek’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +PAreview: security

1: Please implement proper permission for access admin configuration pages. Here any register user with "access content" can access admin configuration page.

twitter.Configuration.form:
  path: 'admin/config/services/configuration'
  defaults:
    _title: 'Twitter OAuth Configuration'
    _form: '\Drupal\twitter_search_block\Form\TwitterAuthForm'
  requirements:
    _permission: 'access content'
    
twitter.blockConfig.form:
  path: 'admin/config/services/block/configuration'
  defaults:
    _title: 'Twitter Block Configuration'
    _form: '\Drupal\twitter_search_block\Form\TwitterHashBlockConfig'
  requirements:
    _permission: 'access content'

2: All user facing text must run through t() for translation

throw new Exception('performRequest parameter must be true or false');
throw new Exception('You can only choose get OR post fields.');
throw new Exception('You need to install cURL, see: http://curl.haxx.se/docs/install.html');
jyoti.singh’s picture

Issue #35 : @visabhishek : The Listed Issue has been fixed now.Thank you.

jyoti.singh’s picture

Status: Needs work » Needs review
RavindraSingh’s picture

Few more things still needs improvement -

1- Version of twitter API is hardcoded $url = 'https://api.twitter.com/1.1/statuses/oembed.json';?
2- Can we use http_query_builder for making query string so incase websever encoding gets changed from UTF to ISO something vice-versa so it won't be a problem.
$getfield = '?id=' . $tweet_id . '&hide_media=true&maxwidth=260&hide_thread=true';

3- Can we check if API is successfully connected else it will always go in the loop even status code was not succeed.
$response = json_decode($api_response);

Thanks,
Ravindra

navneet0693’s picture

Status: Needs review » Needs work

Just gave a quick look to code and I have a few suggestions:

File: TwitterAPIExchange.php

* @return \TwitterAPIExchange
*   Instance of self for method chaining

It should be return TwitterAPIExchange \ refers to Global classes, if I am not wrong.

    $consumerKey              = $this->consumer_key;
    $consumerSecret           = $this->consumer_secret;
    $oauthAccessToken        = $this->oauth_access_token;
    $oauthAccessTokenSecret = $this->oauth_access_token_secret;

Just few alignment corrections needed.

File: twitter_search_block.info.yml

dependencies:
  - field
  - block

It should be:

dependencies:
  - drupal:field
  - drupal:block

Dependencies should be namespaced in the format: {project}:{module}, and in case of core modules {project} is drupal.

File: TwitterAuthForm.php

$config->set('oauth_access_token', $form_state->getValue('oauth_access_token'))
      ->set('oauth_access_token_secret', $form_state->getValue('oauth_access_token_secret'))
      ->set('consumer_key', $form_state->getValue('consumer_key'))
      ->set('consumer_secret', $form_state->getValue('consumer_secret'))
      ->set('api_version', $form_state->getValue('api_version'))

You can use $values = $form_state->getValues(); and then use $values as array for setting values which will help in reducing calls to getValue().

jyoti.singh’s picture

@RavindraSingh : Fixed the listed issued of #38:

  • Created configuration for oembed API URL
  • Used the class UrlHelper::buildQuery($requestQuery) in Drupal 8 to build the query
  • Added the logger for error when API not connected
jyoti.singh’s picture

@navneet0693 : Solution for listed issue #39 :

  • File: TwitterAPIExchange.php - Resolved
  • File: twitter_search_block.info.yml - Resolved
  • File: TwitterAuthForm.php - Resolved
jyoti.singh’s picture

Priority: Normal » Major
Status: Needs work » Needs review
jyoti.singh’s picture

Priority: Major » Critical
matthieuscarset’s picture

Hi @jyoti.singh

I've just tried your module and I haven't been able to show tweets on my site.

I've added a "Twitter Search Query" field to a node. I then created a node and enter a value in this field but nothing special shows up on front end. I just have my field displayed as a regular field (label + value).
I suppose that it is not the desired behavior, is it?

I've also added a Twitter Block:General and I've configured the Twitter Block configuration.
However on front-end, my block is empty.

This is the warning I see in my logs:
Warning: Invalid argument supplied for foreach() in Drupal\twitter_search_block\Plugin\Block\TwitterAPIClass::twitterApi() (line 51 of ...\drupal8\modules\custom\twitter_search_block\src\Plugin\Block\TwitterAPIClass.php) #0

On another hand, I would also suggest to add links to relevant Twitter doc pages in order for your users to easily find the correct API urls that this module is requesting (in admin/config/services/configuration):

  1. https://dev.twitter.com/rest/public/search
  2. https://dev.twitter.com/rest/reference/get/statuses/oembed

Finally, I found that there are still some small code format issues (detected by pareview.sh):
https://pareview.sh/node/276

klausi’s picture

Priority: Critical » Normal

@matthieuscarset: Looks like you forgot to change the status. Is this now RTBC after your review or are there application blockers left and this should be "needs work"?

matthieuscarset’s picture

Status: Needs review » Needs work

Hi @klausi, thank you for your comment.

I've tried to use this module again, without success.
So I would say this module needs work.

shaktik’s picture

Review of the 8.x-1.x branch (commit 26e155e):

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: ...iewsh/pareview_temp/config/install/twitter_search_block.settings.yml
    --------------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    --------------------------------------------------------------------------
     9 | ERROR | [x] Expected 1 newline at end of file; 0 found
    --------------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    --------------------------------------------------------------------------
    
    Time: 126ms; Memory: 8Mb
    
  • No automated test cases were found, did you consider writing Simpletests or PHPUnit tests? This is not a requirement but encouraged for professional software development.

This automated report was generated with PAReview.sh, your friendly project application review script. You can also use the online version to check your project. You have to get a review bonus to get a review from me.

jyoti.singh’s picture

@matthieuscarset - The correct API url for twitter are :

- Twitter API url : https://api.twitter.com/1.1/search/tweets.json
- Twitter Oembed url : https://api.twitter.com/1.1/statuses/oembed.json

I have added these url in the default value for the url configuration.The API used were incorrect thats why the module was not functional.

@shaktik - Cleared all the Pareview error : https://pareview.sh/node/276

jyoti.singh’s picture

Status: Needs work » Needs review
jyoti.singh’s picture

Priority: Normal » Critical
jyoti.singh’s picture

Assigned: Unassigned » jyoti.singh
Issue tags: -PAreview: security +twitter
visabhishek’s picture

Issue tags: +PAreview: security

1: Please don't remove the security tag, we keep that for statistics and to show examples.
2: Please do not assign ticket yourself. See the workflow https://www.drupal.org/node/532400

visabhishek’s picture

Assigned: jyoti.singh » Unassigned
teeyo’s picture

Hello Jyoti,

I did a quick automatic review and there's still some coding standard issues :

FILE: ...eviewsh/pareview_temp/src/Plugin/Field/FieldWidget/TwitterWidget.php
--------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
--------------------------------------------------------------------------
29 | WARNING | t() calls should be avoided in classes, use dependency
| | injection and $this->t() instead
--------------------------------------------------------------------------
FILE: ...eviewsh/pareview_temp/src/Plugin/Field/FieldWidget/TwitterWidget.php
--------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------
28 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: .../pareviewsh/pareview_temp/src/Plugin/Field/FieldType/TwitterItem.php
--------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------
27 | ERROR | [x] Short array syntax must be used to define arrays
28 | ERROR | [x] Short array syntax must be used to define arrays
29 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: ...h/pareview_temp/src/Plugin/Field/FieldFormatter/TwitterFormatter.php
--------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------
27 | ERROR | [x] Short array syntax must be used to define arrays
30 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: ...os/pareviewsh/pareview_temp/src/Plugin/Block/TwitterBlockGeneral.php
--------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------
58 | ERROR | [x] Short array syntax must be used to define arrays
66 | ERROR | [x] Short array syntax must be used to define arrays
68 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: /root/repos/pareviewsh/pareview_temp/src/Plugin/Block/TweetBlock.php
--------------------------------------------------------------------------
FOUND 3 ERRORS AFFECTING 3 LINES
--------------------------------------------------------------------------
102 | ERROR | [x] Short array syntax must be used to define arrays
112 | ERROR | [x] Short array syntax must be used to define arrays
114 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: ...pos/pareviewsh/pareview_temp/src/Plugin/Block/TwitterAPIExchange.php
--------------------------------------------------------------------------
FOUND 10 ERRORS AFFECTING 10 LINES
--------------------------------------------------------------------------
158 | ERROR | [x] Short array syntax must be used to define arrays
209 | ERROR | [x] Short array syntax must be used to define arrays
218 | ERROR | [x] Short array syntax must be used to define arrays
275 | ERROR | [x] Short array syntax must be used to define arrays
281 | ERROR | [x] Short array syntax must be used to define arrays
286 | ERROR | [x] Short array syntax must be used to define arrays
332 | ERROR | [x] Short array syntax must be used to define arrays
354 | ERROR | [x] Short array syntax must be used to define arrays
358 | ERROR | [x] Short array syntax must be used to define arrays
387 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 10 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: .../repos/pareviewsh/pareview_temp/src/Plugin/Block/TwitterAPIClass.php
--------------------------------------------------------------------------
FOUND 2 ERRORS AFFECTING 2 LINES
--------------------------------------------------------------------------
36 | ERROR | [x] Short array syntax must be used to define arrays
54 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 2 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

FILE: ...t/repos/pareviewsh/pareview_temp/src/Form/TwitterHashBlockConfig.php
--------------------------------------------------------------------------
FOUND 4 ERRORS AND 1 WARNING AFFECTING 5 LINES
--------------------------------------------------------------------------
21 | WARNING | [ ] Possible useless method overriding detected
54 | ERROR | [x] Short array syntax must be used to define arrays
61 | ERROR | [x] Short array syntax must be used to define arrays
68 | ERROR | [x] Short array syntax must be used to define arrays
80 | ERROR | [x] Short array syntax must be used to define arrays
--------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
--------------------------------------------------------------------------

Keep up the good work, good luck.

jayesh_makwana’s picture

Solution of short array syntax errors. We uploaded patch. Please check and apply it.

naveenvalecha’s picture

Include twitter-api-php(https://github.com/J7mbo/twitter-api-php) library as the dependency of the module instead of including it in the code directly.

Why not contribute this feature as a submodule for the twitter_block module? If you will collaborate, you could also get the git vetted access.
/me maintainer of the twitter_block and code review administrator.

//Naveen

jyoti.singh’s picture

apaderno’s picture

Issue summary: View changes
sleitner’s picture

Priority: Critical » Normal
Status: Needs review » Needs work

Automated Review

Review of the 8.x-1.x branch (commit a95e9a2):

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    
    FILE: .../drupal/pareviewsh/pareview_temp/src/Form/TwitterHashBlockConfig.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     21 | WARNING | Possible useless method overriding detected
    --------------------------------------------------------------------------
    
    Time: 1.42 secs; Memory: 6Mb
    
  • DrupalPractice has found some issues with your code, but could be false positives.
    
    FILE: ...eviewsh/pareview_temp/src/Plugin/Field/FieldWidget/TwitterWidget.php
    --------------------------------------------------------------------------
    FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
    --------------------------------------------------------------------------
     29 | WARNING | t() calls should be avoided in classes, use dependency
        |         | injection and $this->t() instead
    --------------------------------------------------------------------------
    
    Time: 733ms; Memory: 4Mb
    
  • No automated test cases were found, did you consider writing PHPUnit tests? This is not a requirement but encouraged for professional software development.

This automated report was generated with PAReview.sh, your friendly project application review script.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
No: Causes module duplication and/or fragmentation. Similar: twitter_block
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements.
3rd party assets/code
Yes: Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and/or the README Template.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes: Meets the security requirements.
Coding style & Drupal API usage
  1. (*) add hook_help(): https://www.drupal.org/docs/develop/documenting-your-project/module-docu...
  2. (*) remove __construct in TwitterHashBlockConfig.php (see pareview): useless method overriding

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

apaderno’s picture

Status: Needs work » Closed (won't fix)

If you are still working on this application, you should fix all known problems and set the status to Needs review. (See also the project application workflow.)
Please don't change status of this application if you aren't sure you have time to dedicate to this application, or it will be closed again as won't fix.

I am closing this application due to lack of activity.

jyoti.singh’s picture

Status: Closed (won't fix) » Active
jyoti.singh’s picture

Thank you for the review @sleitner

  • I have fixed the changes for drupal and drupalpractices standard as per code sniffer
  • I have added hook_help in the module
  • I have fixed method overriding issue in TwitterHashBlockConfig.php
jyoti.singh’s picture

Status: Active » Needs review
naveenvalecha’s picture

@jyoti.singh,
I would like to hear thoughts on #56
How this module is different from https://www.drupal.org/project/twitter_block

jyoti.singh’s picture

@naveenvalecha : The module https://www.drupal.org/project/twitter_block provides block for the tweets.In Twitter Search Block there is an additional functionality for a field in nodes of drupal where user can enter the tweet he wants to dispaly in each node.This means each node/content type/single nodes can have different tweets coming in the blocks of each page.

klausi’s picture

Issue summary: View changes
klausi’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for your contribution!

Review:
* Config schema is missing, see https://www.drupal.org/docs/8/api/configuration-api/configuration-schema...
* TwitterAPIClass should probably be a service and get the config injected?
* Do not use cURL, use Drupal's built in HTTP client. See https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/Drupa...

I don't see any security issues, looks good to me!

apaderno’s picture

Assigned: Unassigned » apaderno
Status: Reviewed & tested by the community » Fixed
Issue tags: -twitter

Thank you for your contribution! I am going to update your account.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

jyoti.singh’s picture

Thank you to all the reviewers and @klausi and @kiamlaluno for providing the approval.Thank you all

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

apaderno’s picture

Title: [D8]Twitter Search Block » [D8] Twitter Search Block