Update External Links

This module updates the external URLs present in the body content and change them to be opened in the new tab.

Project page link

    https://www.drupal.org/sandbox/jain_deepak/2424979

Git Clone command

    git clone --branch 7.x-1.x http://git.drupal.org/sandbox/jain_deepak/2424979.git update_external_links
    cd update_external_links

Automated Review

:
http://pareview.sh/pareview/httpgitdrupalorgsandboxjaindeepak2424979git

Features

  • Can updates the external URLs present in the node body content and change them to be opened in the new tab.

Documentation

Goals

Comments

PA robot’s picture

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.

naveenvalecha’s picture

Issue summary: View changes

Updated git command and added automated review link.

jain_deepak’s picture

Thanks Naveen Valecha.

kala4ek’s picture

Status: Needs review » Needs work

Hi, some manually code review:

update_external_links.module

  • 98 - it's recommended to declare global vars at top of function;
  • 103, 104 - unused local vars;
  • 117, 118 - seems extra newline here?
  • 135 - typo in 'finsh';
  • 150/155 - broken tabulation;
  • 165 - why do you need this session var?

external_links.admin.inc

  • 26 - missing t() for localisation;
  • 75/77 - wrong tabulation;
  • 80 - looks like yoy should use fetchCol() here.

Common: I think you should use more empty lines into functions for separate independent sections of code. This will increase the readability of the code.

jain_deepak’s picture

Status: Needs work » Active
jain_deepak’s picture

Status: Active » Needs review

Hi kala4ek,

Thanks for your feedback. I have worked on the points listed above.

naveenvalecha’s picture

Issue summary: View changes

Updated issue summary.

naveenvalecha’s picture

Issue summary: View changes
aneek’s picture

Hello @jain_deepak, below are my reviews.

Automated Review

3 Warnings found: http://pareview.sh/pareview/httpgitdrupalorgsandboxjaindeepak2424979git

Manual Review

Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[No: Causes] module duplication and/or fragmentation.
2 modules are existing.
External New Tab & External Links. Please update this if this module acts differently.
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.
Manual Reviews
  1. $context['sandbox']['progress'] ++; this unary operator doesn't need an extra space.
  2. drupal_set_message(t('An error occurred while processing @operation with arguments : @args', array('@operation' => $error_operation[0], '@args' => print_r($error_operation[0], TRUE),)));
    Array spans more than 80 characters so break in smaller parts.

This review uses the Project Application Review Template.

jain_deepak’s picture

Hi @ aneek

I have updated the code as per your review.

NO Duplication

This module works differently than the other two External New Tab and External Links both these module uses jQuery to open link in new tab, and these script are run everytime node is loaded. In my module, I have used DOMDocument() and added the target="_ blank" attribute to each external URL, and then node is saved again. So, in this way this module run only once, unlike External New Tab and External Links, where script is loaded each time.

narendrar’s picture

Status: Needs review » Needs work

Hi Deepak,

Nice module. I have some suggestions:

1. In function update_external_links_selected_nid you can refine the resultset based on node status, field_data_body has value or not.
This will reduce further processing of unwanted nid's.
2. Instead of using node_load in function update_external_links_process_1, you can use 'EntityFieldQuery'.
3. Line 98 in update_external_links.module, URL protocol is hard coded.

jain_deepak’s picture

Status: Needs work » Needs review

Hi @NarendraR,

Thanks For your feedback.

1- I have updated the query to check body field is not empty but i did not check the node status as external links should be updated in published or unpublished node.

2- Now i use field_attach_update function to update the body field rather than the node_save() function. Please suggest how can I use field EntityFieldQuery as I go through it and find that i have to load node after getting nid through EntityFieldQuery .

3- Done.

narendrar’s picture

Status: Needs review » Needs work

Hi Deepak,

For Point 2, you should use field_attach_presave before field_attach_update.
I think node_load is OK to go with if you want, as you are loading single node each time. EntityFieldQuery can be used to load multiple nodes using entity_load.

Also, one more suggestion, In function update_external_links_input_form_submit, two if's can be changed to if-else
[if (empty($node_ids)) and if (!empty($node_ids))]

jain_deepak’s picture

Status: Needs work » Needs review

Hi @NarendraR,

I have updated the code as per your review.

jain_deepak’s picture

Any updates?

klausi’s picture

Assigned: Unassigned » heddn
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: review bonus

Git errors:

Review of the 7.x-1.x branch (commit ddc37d3):

  • Coder Sniffer has found some issues with your code (please check the Drupal coding standards).
    FILE: /home/klausi/pareview_temp/includes/external_links.admin.inc
    ----------------------------------------------------------------------
    FOUND 1 ERROR AFFECTING 1 LINE
    ----------------------------------------------------------------------
     61 | ERROR | [x] Expected 1 space after ELSE keyword; 0 found
    ----------------------------------------------------------------------
    PHPCBF CAN FIX THE 1 MARKED SNIFF VIOLATIONS AUTOMATICALLY
    ----------------------------------------------------------------------
    
  • 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.

manual review:

  1. what are the differences to existing projects like https://www.drupal.org/project/external and https://www.drupal.org/project/extlink ? Module duplication and fragmentation is a huge problem on drupal.org and we prefer collaboration over competition. Please add the differences to the project page. It seems like a much more sensible approach to process the links when they are displayed instead of overwriting content in the database?
  2. you are repeating "initial changes" as git commit message all the time. Make sure to provide something more useful, see https://www.drupal.org/node/52287
  3. update_external_links_url(): why does this function return? Please add @return docs, see https://www.drupal.org/coding-standards/docs#return
  4. update_external_links_input_form(): looks like you want to use "checkboxes" for #type here? See https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h... . Then you can also make that element #required, so that you don't need update_external_links_input_form_validate().
  5. update_external_links_process_1): you should not call the field_attach_*() functions here but rather node_save(), so that really all hooks are invoked when a node is changed.
  6. update_external_links_url(): could you add some inline comments explaining what you are doing here? It seems like you only update links pointing to external sites, correct?
  7. update_external_links_input_form(): HTML tags should be outside of t() where possible, like the "p" tags here.

But that are not critical application blockers, otherwise looks RTBC to me. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

Assigning to heddn as he might have time to take a final look at this.

jain_deepak’s picture

Hi @klausi,

Thanks For your feedback.

1- I have added the Differences in the project page.
2- Okay Sure.
3- Done
4- Actually I want end user to decide either to select single content type or multiple. If i use #required it will make all the checkboxes to be selected.
5- Done
6- Done
7- Done

heddn’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, jain_deepak!

I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, 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.

Thanks to the dedicated reviewer(s) as well.

Status: Fixed » Closed (fixed)

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