Comments

PA robot’s picture

Status: Needs review » Needs work

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

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.

pranit84’s picture

Title: Content Dependency [D7] » [D7] Content Dependency

Check this: http://ventral.org/pareview/httpgitdrupalorgsandboxerez1111868890git
And solve the reported errors/warnings.

pranit84’s picture

It appears you are working in the "master" branch in git. You should really be working in a version specific branch. The most direct documentation on this is Moving from a master branch to a version branch. For additional resources please see the documentation about release naming conventions and creating a branch in git.
See http://drupal.org/project/1976520/git-instructions
Make sure to set the correct default branch: http://drupal.org/node/1659588 . Then remove the master branch, see also step 6 and 7 in http://drupal.org/node/1127732

erez111’s picture

Status: Needs work » Needs review

Please review my module

erez111’s picture

Priority: Normal » Major
pranit84’s picture

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

First of all solve the suggested changes in #2 and #3.

erez111’s picture

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

Changes #2 + #3 done. Please review.

pranit84’s picture

Priority: Major » Normal
Status: Needs review » Needs work
StatusFileSize
new76.77 KB
new54.83 KB

I can still see the issues reported in #2 and #3, see the attached screenshot.

erez111’s picture

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

Thanks for fast review. Please recheck.

erez111’s picture

Issue tags: +PAreview: review bonus

Please review my project.

erez111’s picture

Issue summary: View changes

Minor changes

kimberlydb’s picture

Status: Needs review » Needs work

You still have some warnings: http://ventral.org/pareview/httpgitdrupalorgsandboxerez1111868890git

Review of the 7.x-1.x branch:

./README.txt: the byte order mark at the beginning of UTF-8 files is discouraged, you should remove it.
Coder Sniffer has found some issues with your code (please check the Drupal coding standards).

FILE: /var/www/drupal-7-pareview/pareview_temp/content_dependency.api.php
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 2 WARNING(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
14 | WARNING | Hook implementations should not duplicate @param documentation
26 | WARNING | Hook implementations should not duplicate @param documentation
--------------------------------------------------------------------------------

FILE: ...var/www/drupal-7-pareview/pareview_temp/includes/content_dependency.inc
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 2 WARNING(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
161 | WARNING | Only string literals should be passed to t() where possible
164 | WARNING | Only string literals should be passed to t() where possible

erez111’s picture

Status: Needs work » Needs review

Minor coding standard warning only is not an application blocker, please do a manual review.
README.txt file is ok.

kimberlydb’s picture

I installed the module and went to a piece of content that already existed, went to the content dependencies tab and the page was totally blank. I could still see the tabs/top menu but the content of the tab is all white. I created a new content type and new content to see if it would work but I get the same thing.

erez111’s picture

Hi Kimberly,

Thanks for your review.
I just uploaded a new version which display some message (instead of all-white content) when there are no dependencies.

Generally, if you refer (via entity reference or node reference) from some content (node, user, taxonomy, etc.) into current content, you would see the dependencies via "Content Dependency" tab.

Please check the updated version which I just uploaded and tell me your thoughts..

kimberlydb’s picture

I re-installed the module, and I appreciate the message instead, but it is not entirely clear to me how I actually set up a content dependency.

"That's it! Now, you can see what module does, just enter to your domain

path"/node/NUMBER/edit" and you see "Content Dependency" tab

(just verify you have some entity reference and/or node reference

that refer to this entity (node)."

In the README.txt is a tad confusing as I thought it implied the Content Dependency tab was where you configured the dependencies. I think you should make it a step to add a entity reference field (just to be clear).

--

In content_dependency.inc you have a lot of double, and triple nested foreach loops. I am wondering if there is away to simplify these, possibly through recursion or through changing data structures? Not a deal breaker, but when I see a bunch of nested loops I try and think about how I could optimize it.

--
content_dependency.class line 294 is this supposed to be $key2? On that note, perhaps you could sue a little more clear key/value names. What does value2 represent?

erez111’s picture

Kimberly,

I appreciate your feedbacks.

You viewed installation steps (which are quite simple), anyway, you should see documented example to discover what you want at "Content dependency images example", which explains how to see what "Content Dependency" does and see actual results.

In addition, I mentioned one of the advantages "You can install this module & start use it without need to perform any change in your content structure".
So, as wrote, no change need to be done especially for this module. However, if there are/will be dependencies, you will be able to see them.

About code issues -

I've used the best complexity I could for total loop iterations which is O(n) although it has 3 canonical foreach loops:
When there are 3 levels of foreach loop, external loop iterations is less than 10 (max number of entity types: nodes, user, taxonomy term, etc.)*middle iterations(categories number)*internal iterations = #of dependent entities.

Complexity of 3 foreach canonical loops is always the same complexity as using a singular foreach loop that is not categorized, but runs widely for all #of dependent entities.

content_dependency.class line 294:
Thank you, I had a bug: "$entity_array_temp as $value" fixed to => "$entity_array_temp as $key => $value"

What does value2 represent? - It represents all entities objects of specific entity types (e.g: a list of node objects).

I just uploaded a version with a bug fix you founded :)

Please tell me if there are more issues/questions, if not, I will appreciate if you can change this project status ;)

samvel’s picture

Status: Needs review » Needs work

Hi erez111,

define('CONTENT_DEPENDENCY_FIELD_ARRAY_NAME_KEY', 'name');
// Label of field_array name key.
define('CONTENT_DEPENDENCY_FIELD_ARRAY_TYPE_KEY', 'type');
// Label of field_array type key.
define('CONTENT_DEPENDENCY_NEW_CONTENT_ANCHOR_TARGET_TYPE', '_blank');
// Anchor target type of new content (_blank,_self,_window, etc.).
define('CONTENT_DEPENDENCY_NEW_CONTENT_ADD_NO_ENTITY_OUTPUT', TRUE);
/* Boolean. Define whether to show add new content link
    when no dependency content exists. */
define('CONTENT_DEPENDENCY_DISPLAY_NO_ENTITY_BLOCK', TRUE);
/* Boolean. Determine whether to display or not content dependency
    block when there are no entities. */
  1. Use comments above line of code
  2. Use inline comments
/**
 * Implements hook_init().
 */
function content_dependency_init() {
  drupal_add_js(array('arg' => arg()), 'setting');
  module_load_include('class', 'content_dependency', 'includes/content_dependency');
  module_load_include('inc', 'content_dependency', 'includes/content_dependency');
}

Why you include files in hook_init()? Use place below constants.

$value = "'" . $value . "'";
Use $value = (string) $value;

  if (CONTENT_DEPENDENCY_DISPLAY_NO_ENTITY_BLOCK === FALSE &&
    empty($entity_type_array_categories)) {

    return FALSE;
  }

What is it?:) Why you compare constant with FALSE?
Both static, result always the same.

content_dependency_execute_hook_filter_entities_edit_build()
and content_dependency_execute_hook_filter_entities_edit_alter()

May be use module_invoke_all?

erez111’s picture

Status: Needs work » Needs review

Hello,

Thanks for your review.

I modified comments as mentioned below:
1. I cancelled hook_init() and moved it's content to relevant page callback.
2. I did comments changes as you mentioned. thanks.

Few remarks:
1. $value = "'" . $value . "'" =/> $value = (string) $value;
2. "CONTENT_DEPENDENCY_DISPLAY_NO_ENTITY_BLOCK === FALSE"
What is it?:) Why you compare constant with FALSE? - this is exactly the reason why to use "define". Of course I can switch it to TRUE/FALSE values all over the code.
3. may be use module_invoke_all - Can't pass vars by reference with module_invoke_all().

I will be happy if you can promote this project status.

klausi’s picture

Priority: Major » Normal
Status: Needs review » Needs work
Issue tags: -PAreview: review bonus +PAreview: security

Issue priority is normal, see http://drupal.org/node/539608

Review of the 7.x-1.x branch:

  • ./README.txt: the byte order mark at the beginning of UTF-8 files is discouraged, you should remove it.

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. hook_content_dependency_filter_entities_edit_build(): doc block is wrong, the first line should describe the hook. See http://drupal.org/node/1354#functions and hook definitions.
  2. content_dependency.api.php: examples in the function bodies would be useful.
  3. content_dependency_permission(): permission keys are usually all lower case.
  4. content_dependency.info: if the dependencies are not needed you should remove those lines.
  5. content_dependency.class: please use the *.php or *.inc file extension.
  6. content_dependency_get_content_type_details(): do not concatenate variables directly into query strings, use placeholders with db_query() instead. Please read http://drupal.org/writing-secure-code again.
  7. The content dependency tab is vulnerable to XSS exploits. If I have a node with the title <script>alert('XSS');</script> which has a reference to another node, then I will get a nasty javascript popup. You need to sanitize user provided text before printing, please read http://drupal.org/node/28984 again. And please don't remove the security tag, we keep that for statistics and to show examples of security problems.
  8. content_dependency_get_entity_types_arrays_html(): The HTML layout should be rendered in a theme function, so that it can be overridden easily.
  9. content_dependency_filter_entity_id_array_edit_permission(): entity_access() is an Entity API function, so you need a dependency to the entity module.

Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

samvel’s picture

Seems it's my mistake, sorry:

Use inline comments

in 17#

erez111’s picture

Asik, I used inline comments. (some of comments, used above line, to not exceed 80 characters per line.

erez111’s picture

Priority: Normal » Major
Status: Needs work » Needs review
Issue tags: -PAreview: security

klausi,

Thank you for your review.

I uploaded a new version with following changes:

#1 - Done.
#2 - Done.
#3 - Done - I changed permission key string into lower case string.
#4 - Done.
#5 - Done.
#6 - Done.
#7 - Done. (Fixed for all output).
#8 - Done. I added a theme inc. tpl file "content_dependency_tab_wrapper.tpl.php".
#9 - Done. (dependency added).

README.txt fixed.

Waiting for a review.

erez111’s picture

Issue summary: View changes

Header fixes

erez111’s picture

Issue tags: +PAreview: review bonus

Please review my project or promote its status.

samvel’s picture

Priority: Major » Normal
Issue tags: -PAreview: review bonus

erez111,

1) why you set status review bonus each time? For this you must check another 3 projects!
2) why you set major status? please see http://drupal.org/node/539608

erez111’s picture

Issue tags: +PAreview: review bonus

Asik,
I already did 3 more new projects review and I replaced old links with new links. Please don't remove review tag next time without verifying details first.
About status, ok. thanks.

klausi’s picture

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

please don't remove the security tag, we keep that for statistics and to show examples of security problems. Please add all your reviews to the issue summary so that we can track them.

manual review:

  1. "Stable version14" is not a useful commit message, please read http://drupal.org//node/52287
  2. buildEntityIdQuery(): why do you have to build the query yourself and cannot use entity field query?
  3. "module_load_include('class', 'content_dependency', 'includes/content_dependency');": that file does not exist anymore? Also, why do need to include the fiel if you are already in the file?
  4. getMainContentHtml(): do not use jQuery(document).ready(), use Drupal.behaviors instead. See http://drupal.org/node/756722 . And put the JS in a dedicated file, then it is easier to read and maintain.
  5. "check_plain(mysql_real_escape_string($record->name));": what is this mysql_real_escape_string() function call used for? That output is never used in a query?
  6. content_dependency_get_entity_types_arrays_html(): there is still markup in this function. You should prepare and array of variables here, all HTML should in a theme function and/or template.
  7. content_dependency_get_entity_types_arrays_html(): do not create link markup yourself, use l() instead. And you could use theme('item_list', ...).
  8. "t('You can') . ' <a href="/node/' . $entity_id . '/edit">' . t('click here') . '</a> ' . t('to edit current') . ' ' . t($entity_type)": Do not concatenate parts of a sentence like that, use placeholders with t() instead. And the link markup will fail if Drupal is installed in a subdirectory, always use url() or l() to create links.

Although you should definitively fix those issue I don't think they are critical application blockers, so I would say RTBC. Removing review bonus tag, you can add it again if you have done another 3 reviews of other projects.

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

erez111’s picture

kalusi,

Thanks for your comments.

I uploaded a new version.

Everything done as following:
1. I will do it in next commits.
2. I'm not sure of performance issues of other solution, that why I build it myself.
3. Done. - thanks.
4. Done.
5. I rather that function filter sql injection issues, although it's not send to sql query for this version.
6. Done.
7. Done.
8. Done.

Waiting for chx review.

erez111’s picture

Issue summary: View changes

New review bonus links

erez111’s picture

Issue tags: +PAreview: review bonus

Added review bonus. Waiting for a review.

klausi’s picture

Status: Reviewed & tested by the community » Fixed

no objections for more than a week, so ...

Thanks for your contribution, erez111!

I updated your account to let you 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 get 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.

erez111’s picture

Assigned: chx » Unassigned
Status: Fixed » Closed (fixed)

Thank you very much klausi and all other reviewers who help to improve my module.

I uploaded a stable version at http://drupal.org/project/content_dependency

You're all welcome to use it.

klausi’s picture

Status: Closed (fixed) » Fixed

Just leave it at fixed, it will close automatically after 2 weeks.

chx’s picture

Sorry for not getting here earlier. I think a quick (==not really through) review is still useful. I usually dislike constants for the sake of having constants. Does CONTENT_DEPENDENCY_FIELD_ARRAY_NAME_KEY give you any value over 'name'? I doubt. Also, using CONTENT_DEPENDENCY_DISPLAY_NO_ENTITY_BLOCK as a ... what? variable? is simply broken, it's a constant, you shouldn't expect people to edit the module. Rather use variable_get('content_dependency_... and then it can be overridden from settings.php.

The class is unnecessarily verbose. For example, getEntityTypesArray should be just getEntityTypes. fullTargetEntityTypesField or content_dependency_execute_hook_filter_entities_edit_build is some Java-like naming. We do not need AbstractSingletonProxyFactoryBean kind of naming, do we :) ?

For getCurrentNodeContentType I highly recommend menu_get_object.

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

Anonymous’s picture

Issue summary: View changes

Add old & new bonus reviews