This is an administrative helper module to allow users to apply comment settings to all nodes of a certain type when editing the settings for that content type.

This is an alternate, and simpler, solution to the one often found online (D.O and Drupal Answers) to use the Views Bulk Operations module, which is quite a lot of work, especially for an administrator editing multiple content types

Sandbox project page

git clone --branch 7.x-1.x http://git.drupal.org/sandbox/TomCLopez/2331441.git bulk_apply_comment_settings

Reviews of other projects:
https://www.drupal.org/node/2333151
https://www.drupal.org/node/2333347
https://www.drupal.org/node/2331299

Comments

t-lo’s picture

Issue summary: View changes
darrenwh’s picture

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.

ashley george’s picture

I installed the module from Git link above, turned it on, went to the comment section for an existing content type, checked the 'Bulk Apply Comment settings', hit Save. I received the following error:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'name' in 'where clause': UPDATE {node} SET comment=:db_update_placeholder_0 WHERE (type = :db_condition_placeholder_0) AND (name = :db_condition_placeholder_1) ; Array ( [:db_update_placeholder_0] => 2 [:db_condition_placeholder_0] => feed_importer [:db_condition_placeholder_1] => bulk_apply_comment_settings ) in bulk_apply_comment_settings_form_node_type_form_submit() (line 30 of /var/www/mysite.ash/html/modules/bulk_apply_comment_settings/bulk_apply_comment_settings.module).

Additionally, the same thing happens with all content types on my test site.

t-lo’s picture

Thanks @darrenwh, I've gone through and sorted all the issues picked up by http://pareview.sh/
http://pareview.sh/pareview/httpgitdrupalorgsandboxtomclopez2331441git

@Ashley George I can't replicate that issue on the current version. I think it was intorduced and fixed by the work I was doing on the previous issue, sorry about that!

ashley george’s picture

I have re-installed and am not getting the error. Great job @T-Lo!

markpavlitski’s picture

@T-lo this module looks really great!

Just one suggestion, I'd recommend using the batch API to process the comment changes. So that you won't run into issues when scaling to large numbers of nodes.

https://www.drupal.org/node/180528
https://api.drupal.org/api/drupal/includes!form.inc/group/batch/7

t-lo’s picture

Status: Needs review » Needs work

Thanks for the suggestion Mark, I'll make that change now.

I'm also switching from using db_updates to node_load and node_save so as to trigger any cache or other drupal hooks.

t-lo’s picture

Thanks for the suggestion Mark, I'll make that change now.

I'm also switching from using db_updates to node_load and node_save so as to trigger any cache or other drupal hooks.

t-lo’s picture

Status: Needs work » Needs review

the change to use the Batch API is done

pushpinderchauhan’s picture

Status: Needs review » Needs work
Issue tags: +PAreview: single application approval

@T-lo, thankyou for your contribution!

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. None. Good Work

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
No: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
Yes/No: Follows the guidelines for in-project documentation and the README Template.
Code long/complex enough for review
No: Follows the guidelines for project length and complexity. WIll proceed with single project promotion.
Secure code
Yes. If "no", list security issues identified.
Coding style & Drupal API usage
  1. (*) bulk_apply_comment_settings_form_node_type_form_submit(): In following code you have used the batch api, that's not the best way to use BatchAPI. You should only add the operation once, and let the operation iterate over a set number of results, using the sandbox to mark how far it got each time.
    foreach ($nodes as $node) {
          $node->comment = $form_state['values']['comment'];
          $batch['operations'][] = array('node_save', array($node));
        }
    
  2. hook_help() is missing in your module.
  3. bulk_apply_comment_settings_install(): do not juggle with module weights as this is not reliable. Is it really required in your case, please add your comment on this.

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.

First point looks blocker to me, preventing RTBC. Other than this module looks good to me, appreciate your module idea.

As I am not a git administrator, so I would recommend you, please help to review other project applications to get a review bonus. This will put you on the high priority list, then git administrators will take a look at your project right away :-)

Thanks Again!

t-lo’s picture

Status: Needs work » Needs review

Hi er.pushpinderrana,

Thanks for your detailed review.

I've sorted the following issues:
added hook_help
sorted out the batch API implementation

As for the changing module weight, this as to ensure that my hook ran after the comment modules hook.
If there's a better way to achieve that I'd be happy to change it!

t-lo’s picture

further to the above, I've been experimenting with using hook_module_implements_alter to change the order that the hook_form_FORM_ID_alter is called, but it doesn't seem to have any effect.
(I've been able to make similar changes to a hook_form_alter but not hook_form_FORM_ID_alter)

t-lo’s picture

Just spotted the following hint, so I'm trying again!
https://api.drupal.org/api/drupal/modules%21system%21system.api.php/func...

Note that hooks invoked using drupal_alter() can have multiple variations (such as hook_form_alter() and hook_form_FORM_ID_alter()). drupal_alter() will call all such variants defined by a single module in turn. For the purposes of hook_module_implements_alter(), these variants are treated as a single hook. Thus, to ensure that your implementation of hook_form_FORM_ID_alter() is called at the right time, you will have to change the order of hook_form_alter() implementation in hook_module_implements_alter().

t-lo’s picture

I've managed to get the hook_module_implements_alter working and have removed the weight change from the module.

t-lo’s picture

Issue summary: View changes
t-lo’s picture

Issue tags: +PAreview: review bonus

Added review bonus as I've reviewed 3 other modules

pushpinderchauhan’s picture

Assigned: Unassigned » pushpinderchauhan

Assigning to myself for next review.

pushpinderchauhan’s picture

Assigned: pushpinderchauhan » mpdonadio
Status: Needs review » Reviewed & tested by the community
Issue tags: -PAreview: single application approval

Automated Review

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

  • 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

My blocking issues from #11 have been addressed, batch api code looks good.

Correct admistrator spelling in Readme, also make it similar to README Template.

Else Project page and Doc/comments looks good to me. Good Work!

Nothing major jumped out at me, also removing single project promotion tag as now module having 5 functions and source code is 124 lines long that makes you eligible for "create full projects" permission :).

I am not seeing any blocking issues. Assigning to mpdonadio for a second look if he has time, in past he also posted resolution for same http://drupal.stackexchange.com/questions/26224/mass-node-update-e-g-dis....

mpdonadio’s picture

Assigned: mpdonadio » Unassigned

Automated Review

Best practice issues identified by pareview.sh / drupalcs / coder. Please don't copy/paste all of the results unless they are short. If there are a lot, then post a link to the automated review and mention that problems should be addressed.

Manual Review

Individual user account
Yes: Follows the guidelines for individual user accounts.
No duplication
Yes: Does not cause module duplication and fragmentation.
Master Branch
Yes: Follows the guidelines for master branch.
Licensing
Yes: Follows the licensing requirements
3rd party code
Yes: Follows the guidelines for 3rd party code.
README.txt/README.md
Yes: Follows the guidelines for in-project documentation and the README Template. Could be a little better, though.
Code long/complex enough for review
Yes: Follows the guidelines for project length and complexity.
Secure code
Yes. If "no", list security issues identified.
Coding style & Drupal API usage
bulk_apply_comment_settings_module_implements_alter() should have a comment why it is needed. Looks like you are just making sure it is the last one?

The limit in the batch should really be a variable, preferable exposed via a setting form.

The docblock for bulk_apply_comment_settings_batch_update_nodes() should mention that it is the batch callback.

bulk_apply_comment_settings_batch_update_nodes() only really needs to query for the nid, which will simplify this query and make it much quicker.

Since you don't need ->addTag('node_access) for these (this is an admin thing, so bypassing access control is OK), you can convert these to static db_query() calls.

This should also have an action associated with it for the admin/content page for people who don't have VBO installed.

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.

This module squeaks by the our recomendatins for full vetted access, but it looks like evrything is done properly, and the application shows understanding of multiple APIs.

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.

mpdonadio’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for your contribution, T-lo !

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.

t-lo’s picture

Hi mpdonadio,

Thanks for the review and the account update!

Status: Fixed » Closed (fixed)

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