Since I've been having too many issues with this module, I've been searching high and low for answers.
I ran into this called Coder - a Code Review Module .. I just installed it and it gave me this information for Membership Entity. It's not an answer to the database issues I've been having, but hopefully it will get me in the right direction.

Anyhoo... mods of this module can take a looksy at the info below:

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.MODULE
membership_entity.module

severity: normalreview: sql_limitLine 1184: Use db_query_range() instead of the SQL LIMIT clause (Drupal Docs) [sql_limit]
$result = db_query('SELECT name FROM {users} WHERE uid = :uid LIMIT 1', array(':uid' => $uid))->fetchField();

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/MEMBERSHIP_ENTITY_TERM.MODULE
membership_entity_term.module

severity: normalreview: style_string_spacingLine 662: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms [style_string_spacing]
drupal_add_css(drupal_get_path('module', 'membership_entity_term') .'/css/membership_entity_term.css');
severity: normalreview: sql_limitLine 776: Use db_query_range() instead of the SQL LIMIT clause (Drupal Docs) [sql_limit]
if ($id = db_query('SELECT id FROM {membership_entity_term} t WHERE mid = :mid AND (start <= :now AND end >= :now) LIMIT 1', array(

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Kebz’s picture

Title: Code Review » Code Review: Membership Entity - Normal & Critical reports
Priority: Normal » Critical

I was just about to uninstall this module so that I can re-install it again for the 5 millionth time.. SMH.. lol
Anyhoo.. having this Coder module is very helpful... "Code Review" is now one of the options along with the help/configuration/permissions links found in the modules list.

So I clicked on it again, and it gave me a longer list of things it found... and hopefully will be the answer to many issues.

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.MODULE
membership_entity.module

severity: normalreview: sql_limitLine 1184: Use db_query_range() instead of the SQL LIMIT clause (Drupal Docs) [sql_limit]
$result = db_query('SELECT name FROM {users} WHERE uid = :uid LIMIT 1', array(':uid' => $uid))->fetchField();

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.DEVEL.INC
membership_entity.devel.inc

severity: criticalreview: security_3Line 193: Potential problem: drupal_set_message() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar. (Drupal Docs) [security_3]
drupal_set_message(t('!num generated.', array(

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.PAGES.INC
membership_entity.pages.inc

  • severity: criticalreview: security_3Line 249: Potential problem: drupal_set_message() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar. (Drupal Docs) [security_3]
  • drupal_set_message(t('Missing configuration settings for membership type %type. Please visit the settings page to configure the membership type.', array(

  • severity: criticalreview: security_7Line 656: Potential problem: confirm_form() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar. (Drupal Docs) [security_7]
    return confirm_form($form, t('Are you sure you want to delete this membership?'), 'membership/' . $membership->mid, t('This action cannot be undone.'), t('Delete'), t('Cancel'));

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/MEMBERSHIP_ENTITY_TERM.PAGES.INC
membership_entity_term.pages.inc

severity: normalreview: i18n_11Line 726: The $string argument to t() should not begin or end with a space. (Drupal Docs) [i18n_11]
$form['actions']['submit']['#value'] .= t(' (disabled)');

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/VIEWS/VIEWS_HANDLER_FIELD_MEMBERSHIP_TERM_DATETIME.INC
views_handler_field_membership_term_datetime.inc

severity: criticalreview: sql_curlyLine 51: table names should be enclosed in {curly_brackets} [sql_curly]
$type = db_query("SELECT type FROM membership_entity WHERE mid = :mid", array(':mid' => $mid))->fetchColumn();

SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/VIEWS/VIEWS_HANDLER_RELATIONSHIP_TERM_GROUPWISE_MAX.INC
views_handler_relationship_term_groupwise_max.inc

  • severity: normalreview: style_string_spacingLine 87: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms [style_string_spacing]
    $temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : '_INNER';
  • severity: normalreview: style_string_spacingLine 88: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms [style_string_spacing]
    $this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : 'INNER';
  • SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TYPE/MEMBERSHIP_ENTITY_TYPE.PAGES.INC
    membership_entity_type.pages.inc

    severity: criticalreview: sql_curlyLine 41: table names should be enclosed in {curly_brackets} [sql_curly]
    $results = db_query('SELECT mid, type FROM membership_entity WHERE uid = :uid', array(

    SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TYPE/MEMBERSHIP_ENTITY_TYPE.UI.INC
    membership_entity_type.ui.inc

    severity: criticalreview: security_comfirm_form_456Line 161: Potential problem: confirm_form() only accepts filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized. (Drupal Docs) [security_comfirm_form_456]
    return confirm_form($form, $message, 'admin/memberships/types', $caption, t('Delete'));

    Kebz’s picture

    6-days later ... Where are the maintainers for this mod?? There are errors and warnings found in the code... please review... thanks! =)

    Coder provides helpful hints trying to minimize false positives, but offers no guarantees. You are the final arbitrar. If in doubt, please read the Drupal documentation (see review links below and api.drupal.org).


    Code Review for Membership Entity
    Code Review for Membership Entity

    1) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.MODULE
    membership_entity.module

        $result = db_query('SELECT name FROM {users} WHERE uid = :uid LIMIT 1', array(':uid' => $uid))->fetchField();

    2) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.DEVEL.INC
    membership_entity.devel.inc

      drupal_set_message(t('!num generated.', array(

    3) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MEMBERSHIP_ENTITY.PAGES.INC
    membership_entity.pages.inc

        drupal_set_message(t('Missing configuration settings for membership type %type. Please visit the <a href="!url">settings page</a> to configure the membership type.', array(
  • Line 656: Potential problem: confirm_form() only accepts filtered text, be sure all !placeholders for $variables in t() are fully sanitized using check_plain(), filter_xss() or similar. (Drupal Docs) [security_7]
  •   return confirm_form($form, t('Are you sure you want to delete this membership?'), 'membership/' . $membership->mid, t('This action cannot be undone.'), t('Delete'), t('Cancel'));

    4) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/MEMBERSHIP_ENTITY_TERM.PAGES.INC
    membership_entity_term.pages.inc

    • Line 726: The $string argument to t() should not begin or end with a space. (Drupal Docs) [i18n_11]
        $form['actions']['submit']['#value'] .= t(' (disabled)');

    5) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/VIEWS/VIEWS_HANDLER_FIELD_MEMBERSHIP_TERM_DATETIME.INC
    views_handler_field_membership_term_datetime.inc

    • Line 51: table names should be enclosed in {curly_brackets} [sql_curly]
          $type = db_query("SELECT type FROM membership_entity WHERE mid = :mid", array(':mid' => $mid))->fetchColumn();

    6) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/VIEWS/VIEWS_HANDLER_RELATIONSHIP_TERM_GROUPWISE_MAX.INC
    views_handler_relationship_term_groupwise_max.inc

    • Line 87: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms [style_string_spacing]
        $temp_view->namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : '_INNER';
  • Line 88: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms [style_string_spacing]
  •     $this->subquery_namespace = (!empty($options['subquery_namespace'])) ? '_'. $options['subquery_namespace'] : 'INNER';

    7) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TYPE/MEMBERSHIP_ENTITY_TYPE.PAGES.INC
    membership_entity_type.pages.inc

    • Line 41: table names should be enclosed in {curly_brackets} [sql_curly]
      $results = db_query('SELECT mid, type FROM membership_entity WHERE uid = :uid', array(

    8) SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TYPE/MEMBERSHIP_ENTITY_TYPE.UI.INC
    membership_entity_type.ui.inc

      return confirm_form($form, $message, 'admin/memberships/types', $caption, t('Delete'));
    Kebz’s picture

    SITES/ALL/MODULES/MEMBERSHIP_ENTITY/MODULES/MEMBERSHIP_ENTITY_TERM/MEMBERSHIP_ENTITY_TERM.MODULE
    membership_entity_term.module

    • Line 662: String concatenation should be formatted with a space separating the operators (dot .) and the surrounding terms [style_string_spacing]
    drupal_add_css(drupal_get_path('module', 'membership_entity_term') .'/css/membership_entity_term.css');

  • Line 776: Use db_query_range() instead of the SQL LIMIT clause (Drupal Docs) [sql_limit]
  • if ($id = db_query('SELECT id FROM {membership_entity_term} t WHERE mid = :mid AND (start <= :now AND end >= :now) LIMIT 1', array(
    draenen’s picture

    Assigned: Unassigned » draenen
    lhridley’s picture

    Assigned: draenen » lhridley

    Reassigning, as our team has already started working on the coding standards issues, we're over halfway complete with this.

    lhridley’s picture

    FYI -- we are using Coder 8.2.12, PHP_Codesniffer 2.0, and PHP 7.2 for coding standards checks.

    I have forked the repository to github, our team will be generating PRs to the main branch, and we will be integrating Travis CI to run checks on all PRs before we merge into the mainline branch. Once we have the coding standards work complete, we'll generate a patch and post it here.

    It will be a large patch; we are adding inline documentation as we address the coding standards.

    The github repo is public: https://github.com/promet/membership_entity

    If you're interested in helping or in working in the github repo, let me know, I'll add you to the contributors.

    lhridley’s picture

    Patch attached, please review

    lhridley’s picture

    Status: Active » Needs review
    lhridley’s picture

    Assigned: lhridley » Unassigned

    • draenen committed 8e3ace4 on 7.x-1.x authored by lhridley
      Issue #2452841 by lhridley: Code Review:  Membership Entity - Normal...
    draenen’s picture

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

    Committed, thanks! There are still a few reported issues from https://pareview.sh I'd like to work through. Latest report at https://pareview.sh/pareview/https-git.drupal.org-project-membership_ent...

    lhridley’s picture

    Assigned: Unassigned » lhridley

    Reassigning to me for additional work

    lhridley’s picture

    Adding additional patch to address issues in https://pareview.sh/pareview/https-git.drupal.org-project-membership_ent....

    Please review and let me know if there are any other coding standards issues to address.

    lhridley’s picture

    Status: Needs work » Needs review
    lhridley’s picture

    Assigned: lhridley » Unassigned