Issue Bug Closed

#44381indexed_search FE Plugin doesn't show external urls in TYPO3 4.7.7

Alexander Bohndorf 01/08/13, 14:49 updated 10/21/17, 17:45

Description

The FE plugin of indexed_search doesn’t show any external urls which start with http:// or https:// (or any other protocol).
These URLs have been added to the index correctly (via crawler).

The reason for that is in class.tx_indexedsearch.php in line 1247 ff. in function checkExistance($row).

The check is done for any paths with is_file() in line 1250. is_file() returns always 0 if used with urls like “http://google.de/”.

To solve this problem you can use this alternative checkExistance() implementation:

    function checkExistance($row) {
        $recordExists = TRUE;    // Always expect that page content exists
        if ($row['item_type']) {        // External media:
      if(preg_match('/^http(s)?:\/\//',$row['data_filename'])){
         $ch = curl_init($row['data_filename']);
         curl_setopt($ch, CURLOPT_NOBODY, true);
         curl_exec($ch);
         $recordExists = (curl_getinfo($ch, CURLINFO_HTTP_CODE)==200);
      }
      else {
              if (!is_file($row['data_filename']) || !file_exists($row['data_filename'])) {
                  $recordExists = FALSE;
              }
      }
        }
        return $recordExists;
    }

But this implementation is very slow because each external url of the search results will be checked with one http request.

I created an extension sms_indexedsearch_fixexternals to fix this bug. In this extension you can enable or disable the checking of http(s) URLs in the extension configuration.

Reviews 1