Use the Batch API for all replacement processing.

Original request

Hi,

this patch:
1) adds support for languages (ability to select which node language to use when searching for strings).
2) fixes the problem mentioned here: https://www.drupal.org/node/2616640
3) introduces the use of the batch API to prevent timeout problems on large replacement tasks

About the point 2, I think the problem mentioned in the bug is due the fact that the module assumes the field value language is always the same as the node language.
The path looks if the content of a field being replaced is actually using the node language or just 'und'.

Thanks

Giulio

CommentFileSizeAuthor
#7 scanner-2653840-7.patch19.81 KBfizk
#2 scanner-2653840.patch12.19 KBgtoffoli

Comments

gtoffoli created an issue. See original summary.

gtoffoli’s picture

StatusFileSize
new12.19 KB
gtoffoli’s picture

Issue summary: View changes
fizk’s picture

Status: Active » Needs work

Thanks gtoffoli! I'm going over the changes and noticed that this was removed:

> //      if (REQUEST_TIME >= ($start_time + $max_execution_time - 5)) {
> //        if (!$expanded) {
> //          if ($user->uid > 0) {
> //            $verbose = TRUE;
> //          }
> //          else {
> //            $verbose = FALSE;
> //          }
> //          if (_scanner_change_env('max_execution_time', '600', $verbose)) {
> //            drupal_set_message(t('Default max_execution_time too small and changed to 10 minutes.'), 'error');
> //            $max_execution_time = 600;
> //          }
> //          $expanded = TRUE;
> //        }
> //        // If expanded environment still running out of time, shutdown process.
> //        else {
> //          $shutting_down = TRUE;
> //          variable_set('scanner_partially_processed_' . $user->uid, $processed);
> //          variable_set('scanner_partial_undo_' . $user->uid, $undo_data);
> //          if ($searchtype == 'search') {
> //            drupal_set_message(t('Did not have enough time to complete search.'), 'error');
> //          }
> //          else {
> //            drupal_set_message(t('Did not have enough time to complete. Please re-submit replace'), 'error');
> //          }
> //          break 2;
> //        }
> //      }
973a1061

Why was this removed?

fizk’s picture

Sorry, I forgot that it was being replaced with the Batch API.

fizk’s picture

On line 777, we have:

  // Get process and undo data if saved from timeout.
  $processed = variable_get('scanner_partially_processed_' . $user->uid, array());
  $undo_data = variable_get('scanner_partial_undo_' . $user->uid, array());

$undo_data is no longer used, but $processed is used on line 1060, but after the patch, we never set or delete those variables.

fizk’s picture

StatusFileSize
new19.81 KB

Here's the patch with a few cosmetic changes.

damienmckenna’s picture

Component: Code » User interface
Status: Needs work » Needs review

The last submitted patch, 2: scanner-2653840.patch, failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 7: scanner-2653840-7.patch, failed testing. View results

damienmckenna’s picture

Lets move the language filter into a separate issue: #2973301: Add language filter

damienmckenna’s picture

Issue summary: View changes
smustgrave’s picture

Status: Needs work » Closed (outdated)

With D7 shutting down in a few weeks I'm triaging the D7 queue of scanner. Will leave bugs open for a bit longer and maybe, if the other committers want to, do a final D7 version release of scanner