Searching for duplicate nodes, according to some similarity limmit parcent.

Repository:
git clone --branch master devzero@git.drupal.org:sandbox/devzero/1445614.git

Platform:
Drupal 7

Sandbox:
http://drupal.org/sandbox/devzero/1445614

Comments

nick_vh’s picture

Please run coder to detect any errors :

alike_search.module

Line 4: Use an indent of 2 spaces, with no tabs

Line 4: There should be no trailing spaces

Line 5: Use an indent of 2 spaces, with no tabs
return array(
Line 6: Use an indent of 2 spaces, with no tabs
'admin/content/search_alike' => array(
Line 7: Use an indent of 2 spaces, with no tabs
'title' => t('Searching alike nodes'),
Line 7: Menu item titles and descriptions should NOT be enclosed within t(). (Drupal Docs)
'title' => t('Searching alike nodes'),
Line 8: Use an indent of 2 spaces, with no tabs
'page callback' => 'drupal_get_form',
Line 9: Use an indent of 2 spaces, with no tabs
'page arguments' => array( 'alike_search_form' ),
Line 10: Use an indent of 2 spaces, with no tabs
'access arguments' => array('search alike nodes'),
Line 10: There should be no trailing spaces
'access arguments' => array('search alike nodes'),
Line 11: Use an indent of 2 spaces, with no tabs
'type' => MENU_NORMAL_ITEM,
Line 12: Use an indent of 2 spaces, with no tabs
'file' => 'alike_search.admin.inc',
Line 13: Use an indent of 2 spaces, with no tabs
),
Line 14: Use an indent of 2 spaces, with no tabs
);
Line 15: Use an indent of 2 spaces, with no tabs

Line 15: There should be no trailing spaces

Line 19: Use an indent of 2 spaces, with no tabs
return array(
Line 21: There should be no trailing spaces
'title' => t('Search alike nodes'),
Line 35: Use an indent of 2 spaces, with no tabs
return array(
Line 38: Use an indent of 2 spaces, with no tabs
'file' => 'alike_search.admin.inc',
Line 40: Use an indent of 2 spaces, with no tabs
'alike_search_clear_field' => array(
Line 41: Use an indent of 2 spaces, with no tabs
'render element' => 'elements',
Line 42: Use an indent of 2 spaces, with no tabs
'file' => 'alike_search.admin.inc',
Line 43: Use an indent of 2 spaces, with no tabs
),
Line 44: Use an indent of 2 spaces, with no tabs
);
HIDESITES/ALL/MODULES/CONTRIB/ALIKE_SEARCH/ALIKE_SEARCH.ADMIN.INC
alike_search.admin.inc

Line -1: @file block missing (Drupal Docs)
Line 5: Use an indent of 2 spaces, with no tabs
$form = array();
Line 6: Use an indent of 2 spaces, with no tabs

Line 6: There should be no trailing spaces

Line 7: Use an indent of 2 spaces, with no tabs
if (isset($_SESSION['alike_search_compare_batch_results']) && $_SESSION['alike_search_compare_batch_results']) {
Line 8: Use an indent of 2 spaces, with no tabs

Line 8: There should be no trailing spaces

Line 9: Use an indent of 2 spaces, with no tabs
$table = array(
Line 10: Use an indent of 2 spaces, with no tabs
'#theme' => 'table',
Line 11: Use an indent of 2 spaces, with no tabs
'#header' => array(
Line 11: There should be no trailing spaces
'#header' => array(
Line 12: Use an indent of 2 spaces, with no tabs
'first' => t('First material'),
Line 12: There should be no trailing spaces
'first' => t('First material'),
Line 13: Use an indent of 2 spaces, with no tabs
'second' => t('Second material'),
Line 14: Use an indent of 2 spaces, with no tabs
'simil' => t('Similarity'),
Line 15: Use an indent of 2 spaces, with no tabs
),
Line 16: Use an indent of 2 spaces, with no tabs
'#rows' => array(),
Line 17: Use an indent of 2 spaces, with no tabs
);
Line 18: Use an indent of 2 spaces, with no tabs

Line 18: There should be no trailing spaces

Line 19: Use an indent of 2 spaces, with no tabs
foreach ($_SESSION['alike_search_compare_batch_results'] as $v) {
Line 20: Use an indent of 2 spaces, with no tabs

Line 20: There should be no trailing spaces

Line 21: Use an indent of 2 spaces, with no tabs
$node1 = node_load($v['nid1']);
Line 22: Use an indent of 2 spaces, with no tabs
$node2 = node_load($v['nid2']);
Line 23: Use an indent of 2 spaces, with no tabs

Line 23: There should be no trailing spaces

Line 24: Use an indent of 2 spaces, with no tabs
$table['#rows'][] = array(
Line 24: There should be no trailing spaces
$table['#rows'][] = array(
Line 25: Use an indent of 2 spaces, with no tabs
'first' => array(
Line 26: Use an indent of 2 spaces, with no tabs
'data' => array(
Line 27: Use an indent of 2 spaces, with no tabs
'#type' => 'link',
Line 28: Use an indent of 2 spaces, with no tabs
'#title' => $node1->title,
Line 28: Potential problem: FAPI elements '#title' and '#description' only accept filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
'#title' => $node1->title,
Line 29: Use an indent of 2 spaces, with no tabs
'#href' => "node/{$node1->nid}",
Line 30: Use an indent of 2 spaces, with no tabs
),
Line 31: Use an indent of 2 spaces, with no tabs
),
Line 32: Use an indent of 2 spaces, with no tabs
'second' => array(
Line 33: Use an indent of 2 spaces, with no tabs
'data' => array(
Line 34: Use an indent of 2 spaces, with no tabs
'#type' => 'link',
Line 35: Use an indent of 2 spaces, with no tabs
'#title' => $node2->title,
Line 35: Potential problem: FAPI elements '#title' and '#description' only accept filtered text, be sure to use check_plain(), filter_xss() or similar to ensure your $variable is fully sanitized.
'#title' => $node2->title,
Line 36: Use an indent of 2 spaces, with no tabs
'#href' => "node/{$node2->nid}",
Line 37: Use an indent of 2 spaces, with no tabs
),
Line 38: Use an indent of 2 spaces, with no tabs
),
Line 39: Use an indent of 2 spaces, with no tabs
'simil' => $v['parcent'] . '%',
Line 40: Use an indent of 2 spaces, with no tabs
);
Line 41: Use an indent of 2 spaces, with no tabs
}
Line 42: Use an indent of 2 spaces, with no tabs

Line 42: There should be no trailing spaces

Line 43: Use an indent of 2 spaces, with no tabs
$form['table'] = array(
Line 44: Use an indent of 2 spaces, with no tabs
'#markup' => render($table),
Line 45: Use an indent of 2 spaces, with no tabs
);
Line 46: Use an indent of 2 spaces, with no tabs
}
Line 47: Use an indent of 2 spaces, with no tabs

Line 47: There should be no trailing spaces

Line 48: Use an indent of 2 spaces, with no tabs
$form['action'] = array(
Line 49: Use an indent of 2 spaces, with no tabs
'#type' => 'fieldset',
Line 50: Use an indent of 2 spaces, with no tabs
'#title' => t('Search alikes'),
Line 51: Use an indent of 2 spaces, with no tabs
);
Line 52: Use an indent of 2 spaces, with no tabs

Line 52: There should be no trailing spaces

Line 53: Use an indent of 2 spaces, with no tabs
//TODO: make human names of type options in dialog
Line 54: Use an indent of 2 spaces, with no tabs
$node_types = db_select('node_type', 'nt')
Line 55: Use an indent of 2 spaces, with no tabs
->fields('nt', array('type', 'name'))
Line 56: Use an indent of 2 spaces, with no tabs
->execute()
Line 57: Use an indent of 2 spaces, with no tabs
->fetchAllKeyed();
Line 58: Use an indent of 2 spaces, with no tabs

Line 58: There should be no trailing spaces

Line 59: Use an indent of 2 spaces, with no tabs
$alike_settings = variable_get('alike_search_settings',
Line 59: There should be no trailing spaces
$alike_settings = variable_get('alike_search_settings',
Line 60: Use an indent of 2 spaces, with no tabs
array(
Line 61: Use an indent of 2 spaces, with no tabs
'parcent' => 80,
Line 62: Use an indent of 2 spaces, with no tabs
'same_type' => true,
Line 62: Use uppercase for PHP constants, e.g. NULL, TRUE, FALSE
'same_type' => true,
Line 63: Use an indent of 2 spaces, with no tabs
'types' => array_keys($node_types),
Line 64: Use an indent of 2 spaces, with no tabs
)
Line 65: Use an indent of 2 spaces, with no tabs
);
Line 66: Use an indent of 2 spaces, with no tabs

Line 66: There should be no trailing spaces

Line 67: Use an indent of 2 spaces, with no tabs
$form['action']['parcent'] = array(
Line 68: Use an indent of 2 spaces, with no tabs
'#type' => 'textfield',
Line 69: Use an indent of 2 spaces, with no tabs
'#title' => t('Min similarity parcent'),
Line 70: Use an indent of 2 spaces, with no tabs
'#default_value' => $alike_settings['parcent'],
Line 71: Use an indent of 2 spaces, with no tabs
);
Line 72: Use an indent of 2 spaces, with no tabs

Line 72: There should be no trailing spaces

Line 73: Use an indent of 2 spaces, with no tabs
$form['action']['same_type'] = array(
Line 74: Use an indent of 2 spaces, with no tabs
'#type' => 'checkbox',
Line 75: Use an indent of 2 spaces, with no tabs
'#title' => t('Compare only same type nodes'),
Line 76: Use an indent of 2 spaces, with no tabs
'#default_value' => $alike_settings['same_type'],
Line 77: Use an indent of 2 spaces, with no tabs
);
Line 78: Use an indent of 2 spaces, with no tabs

Line 78: There should be no trailing spaces

Line 79: Use an indent of 2 spaces, with no tabs
$form['action']['types'] = array(
Line 80: Use an indent of 2 spaces, with no tabs
'#type' => 'checkboxes',
Line 81: Use an indent of 2 spaces, with no tabs
'#options' => $node_types,
Line 82: Use an indent of 2 spaces, with no tabs
'#title' => t('Types of nodes to compare'),
Line 83: Use an indent of 2 spaces, with no tabs
'#default_value' => $alike_settings['types'],
Line 84: Use an indent of 2 spaces, with no tabs
);
Line 85: Use an indent of 2 spaces, with no tabs

Line 85: There should be no trailing spaces

Line 86: Use an indent of 2 spaces, with no tabs
$form['action']['submit'] = array(
Line 87: Use an indent of 2 spaces, with no tabs
'#type' => 'submit',
Line 88: Use an indent of 2 spaces, with no tabs
'#value' => t('Search'),
Line 89: Use an indent of 2 spaces, with no tabs
);
Line 90: Use an indent of 2 spaces, with no tabs

Line 90: There should be no trailing spaces

Line 91: Use an indent of 2 spaces, with no tabs
return $form;
Line 96: Use an indent of 2 spaces, with no tabs
//TODO: make it
Line 97: Use an indent of 2 spaces, with no tabs

Line 97: There should be no trailing spaces

Line 98: Use an indent of 2 spaces, with no tabs
$alike_settings = array();
Line 99: Use an indent of 2 spaces, with no tabs

Line 99: There should be no trailing spaces

Line 100: Use an indent of 2 spaces, with no tabs
foreach (array( 'parcent', 'same_type', 'types' ) as $v) {
Line 101: Use an indent of 2 spaces, with no tabs

Line 101: There should be no trailing spaces

Line 102: Use an indent of 2 spaces, with no tabs
$alike_settings[$v] = $form_state['values'][$v];
Line 103: Use an indent of 2 spaces, with no tabs

Line 103: There should be no trailing spaces

Line 104: Use an indent of 2 spaces, with no tabs
if (is_array($alike_settings[$v])) {
Line 105: Use an indent of 2 spaces, with no tabs
foreach ($alike_settings[$v] as $k2 => $v2)
Line 106: Use an indent of 2 spaces, with no tabs
if (!$v2)
Line 107: Use an indent of 2 spaces, with no tabs
unset($alike_settings[$v][$k2]);
Line 108: Use an indent of 2 spaces, with no tabs
}
Line 109: Use an indent of 2 spaces, with no tabs
}
Line 110: Use an indent of 2 spaces, with no tabs

Line 110: There should be no trailing spaces

Line 111: Use an indent of 2 spaces, with no tabs
variable_set('alike_search_settings', $alike_settings);
Line 112: Use an indent of 2 spaces, with no tabs

Line 112: There should be no trailing spaces

Line 113: Use an indent of 2 spaces, with no tabs
batch_set( get_find_duplicates_batch( $alike_settings ) );
Line 114: Use an indent of 2 spaces, with no tabs

Line 114: There should be no trailing spaces

Line 118: Use an indent of 2 spaces, with no tabs

Line 118: There should be no trailing spaces

Line 119: Use an indent of 2 spaces, with no tabs
$node_view1 = _clear_output($nid1);
Line 120: Use an indent of 2 spaces, with no tabs
$node_view2 = _clear_output($nid2);
Line 121: Use an indent of 2 spaces, with no tabs

Line 121: There should be no trailing spaces

Line 122: Use an indent of 2 spaces, with no tabs
if ($node_view1 && $node_view2) {
Line 123: Use an indent of 2 spaces, with no tabs
$parcent = 0;
Line 124: Use an indent of 2 spaces, with no tabs
similar_text($node_view1, $node_view2, $parcent);
Line 125: Use an indent of 2 spaces, with no tabs

Line 125: There should be no trailing spaces

Line 126: Use an indent of 2 spaces, with no tabs
if ( $parcent > $parcent_min )
Line 127: Use an indent of 2 spaces, with no tabs
$context['results'][] = array( 'nid1' => $nid1, 'nid2' => $nid2, 'parcent' => $parcent );
Line 128: Use an indent of 2 spaces, with no tabs
}
Line 129: Use an indent of 2 spaces, with no tabs

Line 129: There should be no trailing spaces

Line 134: Use an indent of 2 spaces, with no tabs
if ($success) {
Line 135: Use an indent of 2 spaces, with no tabs
$_SESSION['alike_search_compare_batch_results'] = $results;
Line 136: Use an indent of 2 spaces, with no tabs
}
Line 137: Use an indent of 2 spaces, with no tabs

Line 137: There should be no trailing spaces

Line 142: Use an indent of 2 spaces, with no tabs
$nodes = db_select('node', 'n')
Line 143: Use an indent of 2 spaces, with no tabs
->fields('n', array('nid', 'type'))
Line 144: Use an indent of 2 spaces, with no tabs
->execute()
Line 145: Use an indent of 2 spaces, with no tabs
->fetchAll();
Line 146: Use an indent of 2 spaces, with no tabs

Line 146: There should be no trailing spaces

Line 147: Use an indent of 2 spaces, with no tabs
$batch = array(
Line 157: Use an indent of 2 spaces, with no tabs
for ($i = 0; $i Line 158: Use an indent of 2 spaces, with no tabs
for ($q = $i+1; $q Line 159: Use an indent of 2 spaces, with no tabs
if ($settings['same_type'] && $nodes[$i]->type!=$nodes[$q]->type)
Line 160: Use an indent of 2 spaces, with no tabs
continue;
Line 161: Use an indent of 2 spaces, with no tabs

Line 161: There should be no trailing spaces

Line 162: Use an indent of 2 spaces, with no tabs
if (!in_array($nodes[$i]->type, $settings['types']) ||
Line 162: There should be no trailing spaces
if (!in_array($nodes[$i]->type, $settings['types']) ||
Line 163: Use an indent of 2 spaces, with no tabs
!in_array($nodes[$q]->type, $settings['types']))
Line 164: Use an indent of 2 spaces, with no tabs
continue;
Line 165: Use an indent of 2 spaces, with no tabs

Line 165: There should be no trailing spaces

Line 166: Use an indent of 2 spaces, with no tabs
$batch['operations'][] = array( 'compare_two_nodes', array($nodes[$i]->nid, $nodes[$q]->nid, $settings['parcent'] ) );
Line 167: Use an indent of 2 spaces, with no tabs
}
Line 168: Use an indent of 2 spaces, with no tabs

Line 168: There should be no trailing spaces

Line 169: Use an indent of 2 spaces, with no tabs
return $batch;
Line 170: Use an indent of 2 spaces, with no tabs

Line 170: There should be no trailing spaces

Line 175: Use an indent of 2 spaces, with no tabs
$output = '';
Line 186: Use an indent of 2 spaces, with no tabs

Line 186: There should be no trailing spaces

Line 188: Use an indent of 2 spaces, with no tabs

Line 188: There should be no trailing spaces

Line 192: Use an indent of 2 spaces, with no tabs

Line 192: There should be no trailing spaces

Line 193: Use an indent of 2 spaces, with no tabs
$output = $variables['elements']['#node']->title;
Line 194: Use an indent of 2 spaces, with no tabs

Line 194: There should be no trailing spaces

Line 195: Use an indent of 2 spaces, with no tabs
foreach (element_children($variables['elements']) as $key) {
Line 196: Use an indent of 2 spaces, with no tabs
$variables['elements'][$key]['#theme'] = 'alike_search_clear_field';
Line 197: Use an indent of 2 spaces, with no tabs
$output .= render($variables['elements'][$key]);
Line 198: Use an indent of 2 spaces, with no tabs
}
Line 199: Use an indent of 2 spaces, with no tabs

Line 199: There should be no trailing spaces

Line 200: Use an indent of 2 spaces, with no tabs
return $output;
Line 204: Use an indent of 2 spaces, with no tabs

Line 204: There should be no trailing spaces

Line 205: Use an indent of 2 spaces, with no tabs
$render_array = node_view(node_load($nid), 'comparison' );
Line 206: Use an indent of 2 spaces, with no tabs

Line 206: There should be no trailing spaces

Line 207: Use an indent of 2 spaces, with no tabs
$render_array['#theme'] = 'alike_search_clear_node';
Line 208: Use an indent of 2 spaces, with no tabs

Line 208: There should be no trailing spaces

Line 209: Use an indent of 2 spaces, with no tabs
return render($render_array);
Line 210: Use an indent of 2 spaces, with no tabs

Line 210: There should be no trailing spaces

nick_vh’s picture

Status: Needs review » Needs work
misc’s picture

@devzero, welcome with your application.

@Nick_vh Please do not paste the output of automatic tests as comments, attach as file or link to online version if they are more than a couple of lines.

Manual review

Project page
Please take a moment to make your project page follow tips for a great project page.
Similar?
Are there other modules out there that is similar to yours?
README.txt
Please take a moment to make your README.txt follow the guidelines for in-project documentation. You have a good start with the headings, just add the text that you think is needed.
Master Branch
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.
alike_search.info
Please provide the needed information in the info-file, you are missing some important stuff there, see: http://drupal.org/node/542202
alike_search.admin.inc
Please remove the Todos
alike_search.module
alike_search_menu() You do not need to use t() in menus, title and description is run through t() as default.
Coding standards
You have some coding standards issues, mostly indenting and white spaces, that you should have a look at (like stated in the automated code review above). Take a look at http://drupal.org/coding-standards if you have not done that.
devzero’s picture

Status: Needs work » Needs review

@MiSc, thanks for review, I've made changes, according to your recommendations.

maxtorete’s picture

Status: Needs review » Needs work

Hi devzero!

  • Please, check your coding style issues in this link.
  • You must include an uninstall file to unset all your created variables with variable_set.
  • You should prefix your module functions withe your module machine name.
  • Why are you using $_SESSION variables? The results should be processed and displayed on submit function as far as I know.
devzero’s picture

Status: Needs work » Needs review

@Maxtorete, thanks for review, I've made changes, according to your recommendations, but as for using $_SESSION - how am I sopposed to display results in submit function, while in submit we only start batch process, and results we get in 'finished' callback? I can't see the way to do that, and current solution I think is acceptable, so now I think there is no problem with project.

pgogy’s picture

Hello

  1. perhaps on line 36 of admin.inc look for an alias rather than '#href' => "node/{$node1->nid}",
  2. line 67 / 75 of admin.inc is "parcent" a typo
  3. I think 104-125 could be done via rebuilding a form via $form_state['storage'] and use if (isset($form_state['storage'])) rather than $_SESSION

hope this helps

Pat

soncco’s picture

@Nick_vh try to not paste ugly code here, attach a file with it

misc’s picture

@devzero, how is this status of this application, and the suggestions by @pgogy in comment #6?

a_thakur’s picture

@devzero: Please remove these automated coding standard issues:
http://ventral.org/pareview/httpgitdrupalorgsandboxdevzero1445614git-7x-1x

I am manually reviewing the code, would get back to you soon.

Also, the issue summary is a bit confusing for the reviewers. Specify a command to clone the specific branch, which in this case would be: git clone --recursive --branch 7.x-1.x http://git.drupal.org/sandbox/devzero/1445614.git alike_search. Normally users won't visit the version control of a module to clone the specific branch.

a_thakur’s picture

Hi,
Some manual review.
In the file alike_search.module
It would be good in case you follow the followed convention to comment while you implement any hook.
e.g.

/**
 * hook_menu implementation.
 */

Use

/**
 * Implement hook_menu().
 */

Line #13 in the alike_search.module

/**
 * hook_menu implementation.
 */
function alike_search_menu() {
  return array(
    'admin/content/search_alike' => array(
      'title' => 'Searching alike nodes',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('alike_search_form'),
      'access arguments' => array('search alike nodes'),
      'type' => MENU_NORMAL_ITEM,
      'file' => 'alike_search.admin.inc',
    ),
  );
}

It is best to avoid underscores in the menu links. Instead use "-". So change to

/**
 * Implement hook_menu().
 */
function alike_search_menu() {
  return array(
    'admin/content/search-alike' => array(
      'title' => 'Searching alike nodes',
      'page callback' => 'drupal_get_form',
      'page arguments' => array('alike_search_form'),
      'access arguments' => array('search alike nodes'),
      'type' => MENU_NORMAL_ITEM,
      'file' => 'alike_search.admin.inc',
    ),
  );
}

In the alike_search.admin.inc
Some of lines in the code are exceeding margin line of 80 characters: http://drupal.org/coding-standards#linelength.
Set your editor to show the magic print margin line of 80 characters. Keeping these short assists code readability among other things.

Line #21:

  'simil' => t('Similarity'),

Use a more clear index.
e.g.

  'similarity' => t('Similarity'),

Similarly on the line #26($v), #46('simi'), #108($v).

percent has been misspelled. Please change parcent to percent at following places.#46, #76, #108, #139, #143, #197.

The function. Line #10

function alike_search_form() {

}

which is an argument for drupal_get_form is not correct. Use in this manner.

function alike_search_form($form, &$form_state) {

}

which would help you to use $form_state['storage'] instead of $_SESSION which has been pointed out by pgogy in comment #7.

Line #113


/**
 * Searching form submit.
 */
function alike_search_form_submit($form, &$form_state) {

  $alike_settings = array();

  foreach (array('parcent', 'same_type', 'types') as $v) {

    $alike_settings[$v] = $form_state['values'][$v];

    if (is_array($alike_settings[$v])) {
      foreach ($alike_settings[$v] as $k2 => $v2) {
        if (!$v2) {
          unset($alike_settings[$v][$k2]);
        }
      }
    }
  }

  variable_set('alike_search_settings', $alike_settings);

  batch_set(_alike_search_get_find_duplicates_batch($alike_settings));

}

Please choose a more specific variable name.
The above function can be rewritten as


/**
 * Searching form submit.
 */
function alike_search_form_submit($form, &$form_state) {
  $alike_settings = array();
  foreach (array('percent', 'same_type', 'types') as $row) {
    $alike_settings[$row] = $form_state['values'][$row];
    if (is_array($alike_settings[$row])) {
      foreach ($alike_settings[$row] as $key => $value) {
        if (!$value) {
          unset($alike_settings[$row][$key]);
        }
      }
    }
  }
  variable_set('alike_search_settings', $alike_settings);
  batch_set(_alike_search_get_find_duplicates_batch($alike_settings));
}
a_thakur’s picture

Hi,
In the function function alike_search_form() in the alike_search.admin.inc. Line #60 to $64.

$node_types = db_select('node_type', 'nt')
  ->fields('nt', array('type', 'name'))
  ->execute()
  ->fetchAllKeyed();

You could do something like this:

$node_type = array();
foreach (node_type_get_types() as $key => $value) {
  $node_type[$key] = $value->name;
}

The function node_type_get_types is described here: http://api.drupal.org/api/drupal/modules!node!node.module/function/node_type_get_types/7

Line #192 to #198 in the same file

$batch['operations'][] = array(
  '_alike_search_compare_two_nodes',
    array(
      $nodes[$i]->nid,
      $nodes[$q]->nid,
      $settings['parcent'],
        ),
      );

Change it to.

$batch['operations'][] = array(
  '_alike_search_compare_two_nodes',
    array($nodes[$i]->nid, $nodes[$q]->nid, $settings['parcent']),
      );

Since the array is small so use it in inline format instead.
Thanks,
Ashish.

a_thakur’s picture

Hi,

Some more manual review of the code.
In the alike_search.admin.inc, the function alike_search_form() must have a validation function. The following code[Line #73 to #77]

$form['action']['parcent'] = array(
  '#type' => 'textfield',
  '#title' => t('Min similarity parcent'),
  '#default_value' => $alike_settings['parcent'],
 );

is to be validated against wrong input. In your case, you would need a validation function to specify that the input is a number between 0 to 100. Right now no such validation function exists and I used the module with "7vfcbvcx" as input to the text field which didn't throw any error. To know more about validation function refer here: http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/7#validate

Please correct these and above mentioned reviews in the comment #7 onwards. Revert back in case you face any problem.

a_thakur’s picture

Status: Needs review » Needs work

Changing the status.

gazoakley’s picture

Status: Needs work » Closed (won't fix)
Idle Application
This thread has been idle, in the 'needs work' state with no activity for several months. Therefore, I am assuming that you are no longer pursuing this application, and marking it as closed (won't fix).

If this is incorrect, and you are still pursuing this application, then please feel free to re-open the thread and set the issue status to "needs work" or "needs review", depending on the current status of your code.