Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Found a minor coding standard issue
In file exclude_node_title.module
at line number 111
Boolean Value should be in uppercase "FALSE" found "false"
Comments
Comment #2
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commenteduploading patch file for review
Comment #3
drupalove CreditAttribution: drupalove as a volunteer commentedThere are other elseif expressions that don't meet Drupal's coding standards, I suggest also fixing them.
Comment #4
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedHi,
Yes i have fixed the other elseif as well as few more minor issues as well in the same patch. The separate issue which was being created earlier also by me is also fixed in this patch :)
Comment #5
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedComment #6
drupalove CreditAttribution: drupalove as a volunteer commentedHi @nikhilsukul, I noticed you have made several changes and they all look good to me.
I think there is room for further improving the comments which are not well written and don't end with a period. If you're willing to change them I can give suggestions and you add them into code.
Also, do you agree we should close the #2580193: Wrong standard for writing conditional statement (ElseIf)? If you will close it, please mark it as duplicate of this issue.
Could we have some input from a maintainer before making further change.
So far, this is RTBC.
Comment #7
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedSure.. I will work on the issue. Do suggest the changes. Yes i do agree for closing #2580193: Wrong standard for writing conditional statement (ElseIf)?
Comment #8
drupalove CreditAttribution: drupalove as a volunteer commentedThanks ikhilsukul, will make the suggestions in the next two days.
Comment #9
drupalove CreditAttribution: drupalove as a volunteer commentedWe need to correct the docblocks, improve the comments and remove the white-spaces. Here are some suggestions:
Line 47-56
/**
* Determines if node should be hidden and user
* has permission to have the title hidden.
* @param $node
* Can be a node object or integer value (nid)
* @param $view_mode
* View mode, e.g. 'full', 'teaser'...
* @return
* Returns boolean TRUE if should be hidden, FALSE when not
*/
I believe should be:
/**
* Determine whether a user has privilege and whether to exclude the node title.
*
* @param object $node
* The node object.
* @param string $view_mode
* The view mode, e.g. 'full' or 'teaser'.
*
* @return bool
* Returns TRUE if title should be hidden, otherwise returns FALSE.
*/
Line 82
Remove the inline comment. I think it is not needed.
Line 110
// Also remove the field from the form
Suggest:
// Prevent access to the title field on nodeform view mode.
Line 176
// make sure user have permissions correct
Suggest:
// Exclude the node title for privileged users.
Line 175-176
// --------------
// make sure user have permissions correct
Suggest:
// Prevent users without permission from accessing the node title settings.
Line 181-192
// don't bother to add form element if the content type isn't configured
// to be excluded by user...
Suggest:
// Add form element only for enabled content types.
Line 193
// get tnid
Suggest:
// Get the translation source node ID.
Line 229
// when deleting a content type, we make sure and clean our variable :)
Suggest:
// Remove variables when a content type is deleted.
Line 236-242
/**
* Tells if node should get hidden or not.
* @param $param
* Can be a node object or integer value (nid)
* @return
* Returns boolean TRUE if should be hidden, FALSE when not
*/
I believe should be:
**
* Determine whether the node title should be excluded.
*
* @param object $param
* Contains the node object.
* @param string $view_mode
* The view mode, e.g. 'full' or 'teaser'.
*
* @return bool
* Returns TRUE if the title should be hidden, otherwise returns FALSE.
*/
Line 271
// we look for the nid list
Suggest:
// Prepare a list of the node IDs to be excluded.
Line 276
// get tnid
Suggest:
// Get the translation source node ID.
Line 307-313
/**
* Helper function to _exclude_node_title() that extracts node information from $param.
* @param $param
* Can be a node object or integer value (nid)
* @return
* Returns an array with node id and node type, or FALSE if there were errors.
*/
I'll leave this one for you; please refer to the docblock comment standards.
Line 315
// we accept only integer and object
Suggest:
// Do not load nodes unless we have objects and integers.
Line 320
// if numeric, load the node with nid
Suggest:
// Load the node by its ID if we have numeric value.
Line 329
Remove the inline comment.
Line 332
// Check that the node exists
Suggest:
// Do not get node IDs for non-existing nodes.
Line 338
Remove the inline comment.
After I did some progress on this, I found out the $node and $param may not always be objects but can contain the nid. Please verify that and make necessary changes.
Also, remember to remove the white-spaces - there are several.
Thanks,
Yousif
Comment #10
drupalove CreditAttribution: drupalove as a volunteer commented@nikhilsukul, we should check the other files in the module.
exclude_node_title.info
Change the description to:
Allows exclusion of the title in preselected content type. Works with teaser and other view modes.
package = Access
I believe these line should be removed:
files[] = exclude_node_title.info
files[] = exclude_node_title.module
files[] = exclude_node_title.admin.inc
exclude_node_title.install
// attach default permission to use exclude node title
-->
// Insert in the database the permission to use exclude node title.
$res
-->
$role_ids
exclude_node_title.admin.inc
Add a period to end of the first two comments including the one in @file.
Add a comma to the end of '#disabled' => !module_exists('search')
Select if you wish to remove title from search pages. You need to have Search module !url.
-->
Enable title exclusion in search pages. The Search module must be installed: !url.
If you hide title from one node, it will automatically hide title for all the translated versions of that node. You need to have Content translation module !url.
-->
Enable title exclusion in translated versions of nodes. The Content Translation module must be installed: !url.
Add a comma to the end of '#disabled' => !module_exists('translation')
Exclude title by content-types
-->
Exclude the title by content type
Define title excluding settings for each content type.
-->
Select the content types for which the node title will be excluded.
Remove the t() from '#title' => t($title), as only literals should be passed to the t() function if possible.
Indentation is incorrect on line 75.
Comment #11
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedHi drupalove,
Based on your suggestions, i have updated the module file for now. I am attaching the patch for your review
Comment #12
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedHi drupalove,
I have created another patch, which covers modules as well as other files (info, install), with updated changes which you have suggested along with minor alignments and fixes as required.
If you want to patch entirely for all the files you can use this, otherwise if you want to patch only module file, then use the previous patch
Comment #13
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedComment #14
drupalove CreditAttribution: drupalove as a volunteer commentednikhilsukul excellent effort! Can we make further changes.
'#description' => t('Enable title exclusion in search pages. The Search module must be !enabled.', array('!enabled' => l(t('enabled'), 'admin/modules/list'))),
'#description' => t('Enable title exclusion in translated versions of nodes. The Content Translation module must be !enabled.', array('!enabled' => l(t('enabled'), 'admin/modules/list'))),
Please check if this works:
if (isset($node->exclude_node_title) && $node->exclude_node_title == TRUE) {
This function is missing a return statement at the end. For consistency I think we should return FALSE since it doesn't always validate.
This looks like a display suite function. Do we need a dependency to ds in the .info file. What do you think?
Comment #15
drupalove CreditAttribution: drupalove as a volunteer commentedI also noticed there is a duplicate #options attribute in exclude_node_title.admin.inc
After you remove the duplicate line, you may need to put each array element in one line to avoid the 80 character limit.
Comment #16
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedHi drupalove,
I have created the new patch with the changes as required (exclude_node_title-follow_drupal_coding_standard_-2580201-1-7.x-1.9-15.patch). Kindly review
Comment #17
fizk CreditAttribution: fizk commentedGreat work!
What is the Access package?
Why does ENT depend on DS?
Comment #18
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedHi fizk,
The above changes are done based as recommended by drupalove in comment #10 and comment #14 point-5 respectively.
Thanks,
NikhilSukul
Comment #19
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedComment #21
fizk CreditAttribution: fizk commentedThat function is only called if our hook_ds_fields_info_alter() is called, which happens if Display Suite is already installed.
Committed, thanks!
Comment #22
drupalove CreditAttribution: drupalove as a volunteer commentedHi Nikhil,
Things have been so hectic this last two weeks I haven’t taken the time I should have to review the patch and to thank you for the excellent work you have done.
Your work is very much appreciated…and for sure will make a difference to this module.
Thanks again.
Yousif
Comment #23
nikhilsukul CreditAttribution: nikhilsukul as a volunteer and at Faichi Solutions Pvt Ltd commentedThanks Yousif :)