We were having issues with the module where the index process was failing, our log files were showing that there were undefined variables:

Mar 18 16:26:10 srv-6889 cyw8pci7n4bve[26512]: https://x/batch?op=start&id=34651|1||Notice: Undefined variable: exclude in SearchApiAttachmentsEntityreferenceAlterSettings->alterItems() (line 53 of /mnt/www/html/cyw8pci7n4bve/docroot/sites/all/modules/contrib/search_api_attachments/contrib/search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc). request_id="v-8a8117a4-499a-11e9-9ae6-2f9fc32383e6"

Mar 18 16:26:10 srv-6889 cyw8pci7n4bve[26512]: https://x/batch?op=start&id=34651|1||Notice: Undefined variable: max_file_size in SearchApiAttachmentsEntityreferenceAlterSettings->alterItems() (line 53 of /mnt/www/html/cyw8pci7n4bve/docroot/sites/all/modules/contrib/search_api_attachments/contrib/search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc). request_id="v-8a8117a4-499a-11e9-9ae6-2f9fc32383e6"

It looks like the following code is missing from the alterItems method in search_api_attachments_entityreference/includes/callback_attachments_entityreference_settings.inc

    $exclude = explode(' ', $this->options['excluded_extensions']);
    $max_file_size = parse_size($this->options['max_file_size']);
  public function alterItems(array &$items) {
    // Get the entity reference fields.
    $entityreference_fields = $this->getEntityReferenceFields();

    // Get the file fields.
    $file_fields = $this->getFileFields();

    $exclude = explode(' ', $this->options['excluded_extensions']);
    $max_file_size = parse_size($this->options['max_file_size']);

    foreach ($items as &$item) {
      ....

Comments

mijpcw created an issue. See original summary.

izus’s picture

hi,
good catch

actually the complete snippet here is:

    // Extension restriction.
    $exclude = array();
    foreach (explode(' ', $this->options['excluded_extensions']) as $ext) {
      $exclude[$ext] = file_get_mimetype('dummy.' . $ext);
    }

    // File size restriction.
    if (isset($this->options['max_file_size'])) {
      $max_file_size = parse_size($this->options['max_file_size']);
    }
    else {
      $max_file_size = '0';
    }

i will add it

  • izus committed b7368c8 on 7.x-1.x
    Issue #3041775 by mijpcw, izus: Undefined variable in alterItems method
    
izus’s picture

Status: Active » Fixed

This is now merged
Thanks

mijpcw’s picture

Thank you.

Status: Fixed » Closed (fixed)

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