Since upgrading to the alpha2 version, I've been unable to edit stories due to a path error. Here's the error:

include(sites/all/modules/extractor/libraries/.inc) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /XXX/sites/all/modules/extractor/extractor.module on line 105.

As a workaround, I edited the line to hard-code the necessary file:

Original: include drupal_get_path('module', 'extractor') .'/libraries/'. $name .'.inc';

Edited: include drupal_get_path('module', 'extractor') .'/libraries/extractor_simple.inc';

Unfortunately, I'm not savvy enough to determine where the error arises--but thought I'd share the quick and dirty fix while better minds locate the problem.

Cynthia

Comments

eugenmayer’s picture

Priority: Normal » Critical

@maintainer
Please add this code to the extractor.module.

function extractor_extract($text, $library = 'extractor_simple', $config = array()) {
  if(count($config) == 0) {
    $config['extractors'] = 'extractor_simple';
  }

  if($config['extractors'] != NULL) {
    extractor_include($config['extractors']);
  }

We need the != NULL special case, so the caller can include his library himself, not using the extractor include-method...as its only limitted to the extrac/librarie path.

@organizedhome :
use this patch and it will work.
use the call this way

alex_b’s picture

#1 This would mean that if $config['extractors'] is set we should assume that the library in use is not one available in extractor/libraries/ - I'd like to avoid that as $config is specifically for the configuration of the library in use - hence not information about which library to use.

What about adding a file_exists() into extractor_include() ?

Why is this bug critical? Doesn't seem to be even a regression, right?

eugenmayer’s picture

Not sure about you comment alex, could you rephrase?

We have 2 needs:

1. $congfig enables to include a lib in extractor/libraries. While i have no clue why you dont use the ctools plugin api, the current implementation in extractor is pretty bad and not plugable at all.
In addition, the normal case where you use extractor with one param, the whole this will give you an error is $config is an empty array..therefor includes .inc instead of the simple_extractor.

2. We need a way to extend extractors libs wihout hacking the module. Thats exactly what the NULL case is for "done care about libs, i did so".

alex_b’s picture

Sorry, I misread. My bad. I actually don't like how the library name is being pulled from the $config array at all. $config should be reserved for the inner configuration of the extract function, while $library should be sufficient for detecting the library and the extraction function:

function extractor_extract($text, $library = 'extractor_simple', $config = array()) {
  extractor_include($library); // Instead of 
  $extract = "{$library}_extract";
  return $extract($text, $config);
}

Further, if we check whether the library file is present before including it there is no need to make extractor_extract() explicitly aware of the location of an include file:

/**
 * Include from libraries.
 */
function extractor_include($name) {
  static $included;
  if (!$included[$name]) {
    $file = './'. drupal_get_path('module', 'extractor') .'/libraries/'. $name .'.inc';
    if (is_file($file)) {
      include $file;
    }
    $included[$name] = TRUE;
  }
}
eugenmayer’s picture

Hi Alex,

sounds good, while file-exists is pretty "costy" in the cases, where i exactly know, it wont be there. Anyway iam fine with the solution, its simpler, therefor better :)

Thanks!

alex_b’s picture

Status: Active » Needs work

"while file-exists is pretty "costy" in the cases, where i exactly know, it wont be there"

Right. I was thinking about that too. It will only happen once during page load though (see static cache) and therefore I am fine with the trade off.

alex_b’s picture

Title: Path Error ? at line 150 » Provide way to extend extractors libs wihout hacking the module
Category: bug » feature
Priority: Critical » Normal

#731448: Fatal error: Call to undefined function extractor_simple_extract() Fixes the bug originally reported. I will leave this issue open for #3) 2.