Metatag Replace is used to either search or replace Meta tags on your site.
It uses batch API to search Meta tags and perform operations on them.
Module supports 4 fields which are provided by Metatag module https://www.drupal.org/project/metatag

*This module provides a form for user to search and replace Meta tags.
*There are options to select particular Content types .
*Whether we want case sensitive search or not.
*We can Match Exact Word or not.
*User can choose to select to perform operation Individual Meta Fields or All
*This Modules Creates Revision of each page it changes

Manual reviews of other projects

  1. https://www.drupal.org/node/2677382#comment-10910318
  2. https://www.drupal.org/node/2645832#comment-10890468
  3. https://www.drupal.org/node/2668062#comment-10885972
  4. https://www.drupal.org/node/2730511#comment-11254917
  5. https://www.drupal.org/node/2692493#comment-11256231
  6. https://www.drupal.org/node/2719763#comment-11227969

Project Page
https://www.drupal.org/sandbox/namit.garg92/2623618

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/namit.garg92/2623618.git metatag_replace

Comments

namit.garg created an issue. See original summary.

PA robot’s picture

Status: Active » Needs work

Git clone command for the sandbox is missing in the issue summary, please add it.

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.

namit.garg’s picture

Title: Metatag Replace » [D7]Metatag Replace
namit.garg’s picture

Issue summary: View changes
Status: Needs work » Needs review
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/httpgitdrupalorgsandboxnamitgarg922623618git

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

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

namit.garg’s picture

There were no Errors found in pareview.sh

namit.garg’s picture

Status: Needs work » Needs review
bren001’s picture

Hi @namit.garg,

Automated Review

No issues reported by preview.sh

Manual Review

 
Individual user account

 

Yes: Follows the guidelines for individual user accounts.

 

No duplication

 

Yes: Does not cause module duplication and/or fragmentation.

 

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

 

No: Does not follow the guidelines for in-project documentation and/or the README Template. I think a little more introduction is needed, in particular, you need to address this concern from the Module Documentation Guidelines: “It should always start with a synopsis, telling users what the project does, what problem it solves and the intended audience is”. I would also suggest formatting the project page html correctly, with heading level tags and correct list tags.

The README file doesn’t quite follow the README template as laid out on drupal.org: README template.

Implement hook_help(), see Help text standard for more info.

.

 

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. * I don't believe you have implemented hook_menu correctly. The admin page is not appearing in the 'Search and Metadata' section.
  2. * Your note in 'Limitation' that "Attempting to in two separate windows can lead to unknown errors." needs to be addressed.
  3. * Running a search consistently produced the following errors:

    Notice: Undefined index: opn in metatag_replace_finish_batch_search() (line 511 of /home/r00e0/www/sites/default/modules/2623618/metatag_replace_admin.inc).

    Notice: Undefined index: search-word in metatag_replace_finish_batch_search() (line 512 of /home/r00e0/www/sites/default/modules/2623618/metatag_replace_admin.inc).

    Notice: Undefined index: replace-word in metatag_replace_finish_batch_search() (line 513 of /home/r00e0/www/sites/default/modules/2623618/metatag_replace_admin.inc).

   

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.

bren001’s picture

Status: Needs review » Needs work
pankajsachdeva’s picture

Automated Review

No issue reported by preview.sh

Manual Review

Individual user account
[Yes: Follows] the guidelines for individual user accounts.
No duplication
[Yes: Does not cause] module duplication and/or fragmentation.
Master Branch
[Yes: follow] 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. / No: List of security issues identified.]
Coding style & Drupal API usage
Following errors observed when I searched for decription meta tag:

Notice: Undefined index: field_result in include() (line 31 of /Applications/MAMP/htdocs/fresh-drupal/sites/all/modules/metatag_replace/metatag_replace.tpl.php).
Notice: Undefined index: matches in include() (line 37 of /Applications/MAMP/htdocs/fresh-drupal/sites/all/modules/metatag_replace/metatag_replace.tpl.php).
Notice: Undefined index: node_title in include() (line 38 of /Applications/MAMP/htdocs/fresh-drupal/sites/all/modules/metatag_replace/metatag_replace.tpl.php).
Notice: Undefined index: nid in include() (line 39 of /Applications/MAMP/htdocs/fresh-drupal/sites/all/modules/metatag_replace/metatag_replace.tpl.php).
Warning: Invalid argument supplied for foreach() in include() (line 40 of /Applications/MAMP/htdocs/fresh- drupal/sites/all/modules/metatag_replace/metatag_replace.tpl.php).

pankajsachdeva’s picture

Needs work.

namit.garg’s picture

hi
@bren001,pankajsachdeva
Thanks for spending time to review my module
You were seeing the error because i had not added dependency on Metatag module. Now i have Added the dependency
For the module to work we would need to install Metatag Module.
1> After installalling Metatag Module you would be able to see the link in Menu.

I have also Changed ReadMe.txt and changed layout of Project page.
Also i have implement hook_help as per your advice
Thanks
Namit Garg

namit.garg’s picture

Status: Needs work » Needs review
namit.garg’s picture

Issue summary: View changes
Issue tags: +PAreview: review bonus
namit.garg’s picture

Issue summary: View changes
namit.garg’s picture

Issue summary: View changes
sandipauti’s picture

Hello,
Please look into following error which i have found :
1. Please check Drupal coding standard: https://www.drupal.org/coding-standards

FILE: /var/www/drupal-7-pareview/pareview_temp/metatag_replace.module
---------------------------------------------------------------------------
FOUND 0 ERRORS AND 1 WARNING AFFECTING 1 LINE
---------------------------------------------------------------------------
64 | WARNING | Open page callback found, please add a comment before the
| | line why there is no access restriction
---------------------------------------------------------------------------

2. Found some spelling errors in your code.

./metatag_replace_admin.inc:165: Dont ==> Don't
./metatag_replace_admin.inc:180: Dont ==> Don't

Overall thanks for your hard work.

Cheers,

namit.garg’s picture

Hi @sandipauti
I have fixed the issues by pareview and changed the open page callback
Thanks

sandipauti’s picture

@namit.garg, looks good for me.

namit.garg’s picture

Assigned: namit.garg » Unassigned
marabak’s picture

Hi,


When i performed a search i had this notices :

Notice: Undefined index: field_result in include() (line 31 of drupal/sites/all/modules/contrib/metatag_replace/metatag_replace.tpl.php).
Notice: Undefined index: matches in include() (line 37 of drupal/sites/all/modules/contrib/metatag_replace/metatag_replace.tpl.php).
Notice: Undefined index: node_title in include() (line 38 of drupal/sites/all/modules/contrib/metatag_replace/metatag_replace.tpl.php).
Notice: Undefined index: nid in include() (line 39 of drupal/sites/all/modules/contrib/metatag_replace/metatag_replace.tpl.php).
Warning: Invalid argument supplied for foreach() in include() (line 40 of drupal/sites/all/modules/contrib/metatag_replace/metatag_replace.tpl.php).



You should perform some checks, maybe for instance replace in metatag_replace.tpl.php on line 37 :

$meta_field = $list[0]['field_result'];

with:

if(isset($list[0]['field_result'])) {
  $meta_field = $list[0]['field_result'];
  ...
}
marabak’s picture

in fact the problem occurred in #21 when i click directly on "replace" button and my searched metatag is not found

marabak’s picture

I found an other problem. I dont think it's a good idea to use so general session variables:
$_SESSION['show-result']
you should probably prefix them with your module name.

marabak’s picture

you have too much logic i think in your metatag_replace.tpl.php file.
Maybe you should split it to parts, maybe one for search and an other for replace...
I saw you were printing directly

  • tags i think you should use theme functions so other modules can alter it
    see : https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_it...
  • shinde_kashmira’s picture

    Hi namit.garg,

    I was going through your code and found that, you have not followed naming convention standards for submit & replace buttons in the form.

    Please look into the below code line #130 in metatag_replace_admin.inc.
    metatag_replace_form_submit_one() function will confuse the user who is going to use this module in future.

    '#submit' => array('metatag_replace_form_submit_one'),
    

    Also for Replace button, please provide appropriate name for button and functions.

     $form['submit1'] = array(
        '#type' => 'submit',
        '#value' => 'Replace',
        '#submit' => array('metatag_replace_form_submit_two'),
        '#validate' => array('metatag_replace_form_validate_two'),
      );
    
    namit.garg’s picture

    Hi @ marabak,shinde_kashmira

    Thanks for taking time to review my module.I have implemented the changes you suggested
    1>I have prefix my module name in session variables
    2>I have fixed the "Notice: Undefined index"
    3>I Have now using theme function to print list items
    4>I have changes the name of my submit and validation handlers

    Please go through the module and see if it requires any other changes

    tomvv’s picture

    Status: Needs review » Needs work

    Pareview.sh is fine with your module.

    From manual checks I did find the following:
    - Your tpl files contain PHP logic that should be handled outside of these files, using only the data coming from functions within your module rather than the tpl itself.
    - Some code style issues, like mixing double quotes and single quotes, e.g. in the t() wrapper.
    - Not really an error, but do see a lot of repeating logic, like
    $replace_result = preg_replace("/\b$searchword\b/i", $replaceword, $meta_list);
    This cries for a helper function that can do the multiple preg_replace operations by handling an array.
    - Same applies to repeating if/else statements.

    namit.garg’s picture

    Status: Needs work » Needs review

    Hi @ tomvv
    Thanks for reviewing my module.it took me a time to incorporate the changes you mentioned
    1>I have reduced the logic in tpl files now only the data which is to be passes in theme function is written in those
    2> fixed double quotes issue
    3>I have reduced the repeating logic

    klausi’s picture

    Assigned: Unassigned » manjit.singh
    Status: Needs review » Needs work
    Issue tags: -PAreview: review bonus +PAreview: security

    manual review:

    1. metatag_replace_form(): why do you call drupal_session_start() here? That should not be necessary? Either remove it or add a comment why it is needed.
    2. "'description' => 'Description',": all user facing text must run through t() for translation. Please check all your #options strings.
    3. metatag_replace_form(): do not call theme() here. Just pass in the pager render array as variable to you theme functions. See https://api.drupal.org/api/drupal/modules!system!system.api.php/function...
    4. metatag_replace_form() instead of using $_SESSION here you could access the values in $form_state if they exist there, right?
    5. metatag_replace_operation_search.tpl.php: is not a template at all, so it should be just a theme function in your module file. Same for metatag_replace_operation_search.tpl.php.
    6. metatag_replace_perform_replace(): $var1 is bad variable name. What is it? $metatag_string or $description or somehting?
    7. metatag_replace_help(): doc block is wrong, this should be "Implements hook_help().". Please check all your hook doc blocks.

    There is a security issue in this module and as part of our git admin training I'm assigning this to Manjit so that he can take a look. If he does not get to it I will post the vulnerability details in one week. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

    manjit.singh’s picture

    Assigned: manjit.singh » Unassigned

    Thanks Klausi for assigning the issue.

    @Namit you have added some variables in template files that need to be sanitized before using.

     * $list[0] Stores the Following Data
     * $list[0]['search-word']=> Stores the search word.
     * $list[0]['replace-word']=> Stores the replace word.
     * $list[0]['opn']=> Stores operation performed ie Search,Replace,Complete.
     * $list[0]['field_result']=> Stores the Meta field you searched.
     * $list[0]['detail'] => Stores the nid and link of the Node.
     * $list[0][matches]=> Stores the the array for Metatags found.
    

    Rest of things are fine.
    @klausi Please correct me if there is anything else.

    namit.garg’s picture

    Hi @manjit
    Thanks for spending time to review my module.

    These variables in template file are sanitized already .
    User will enter $list[0]['search-word'] and $list[0]['replace-word'] only , for which i have used metatag_replace_xss_check() to check that they dont enter any invalid data.

    $list[0]['opn'], $list[0]['field_result'] ,$list[0]['detail'], $list[0][matches] are the variables which are formed during operation so they will contain only valid data

    namit.garg’s picture

    @klausi
    Thanks for reviewing my modules . i have fixed some issues reported by you.
    1> Removed drupal_session_start()
    2>All user facing text are going through t()
    3> Passed array instead of calling theme function
    5>Instead of template files i have used theme function in my module file
    6>metatag_replace_perform_replace() used a suitable varuiable name instead of $var1
    7>metatag_replace_help(): changed doc block for the hook and also for other hooks

    4> i am using $_SESSION as when user enters the field for search then if he see's the result and want any change in options or perform replace he did not need to fill entire form again, his previous filled options will be there
    Please also tell the security issue in this module

    Thanks

    namit.garg’s picture

    Status: Needs work » Needs review
    damienmckenna’s picture

    Status: Needs review » Needs work

    @namit.garg: Hey, thanks for building on top of Metatag, I'm very happy to see you do this :)

    I have one suggestion - add the same code check logic to the 'replace_box' field that you have for the 'search_box' field, and then I think it'd be a-ok. Also, I think the error message would be better as 'Do not enter any HTML or PHP code.'

    If you make this one change I'll be happy to mark it as RTBC.

    namit.garg’s picture

    Status: Needs work » Needs review

    @Damien McKenna
    Thanks for reviewing my module.

    There are 2 Validation functions
    1> metatag_replace_form_search_validate() -> for search operation thus it will only check for search_box as their is no use for replace_box field
    2>metatag_replace_form_replace_validate() -> This was missing call to metatag_replace_xss_check() for search_box which i have implemented now.

    3>Changed Error Message as per your suggestion

    namit.garg’s picture

    Issue summary: View changes
    namit.garg’s picture

    Issue tags: -PAreview: security +PAReview: security PAReview: review bonus
    namit.garg’s picture

    Issue tags: -PAReview: security PAReview: review bonus +PAreview: security, +PAreview: review bonus
    damienmckenna’s picture

    Status: Needs review » Reviewed & tested by the community

    Ok, the latest changes look good. Good work, namit.garg, that's an interesting module you've put together!

    damienmckenna’s picture

    Status: Reviewed & tested by the community » Fixed

    Thanks for your contribution, Namit!

    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.

    namit.garg’s picture

    Thanks DamienMcKenna for accepting this as a full project .

    I would read the documentation you provided tonight and will promote it to full project tomorrow.

    pankajsingh.lko33@gmail.com’s picture

    Thanks Namit Garg
    For your contribution to Drupal Community

    Status: Fixed » Closed (fixed)

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