Hi, I just had this error after updating the module to 7.X-1.3, could you help me to fix this, thank you.

Notice : Undefined offset: 2 dans _pathologic_replace() (line 118 in /home/vhosts/DomainName/www/sites/all/modules/contrib/pathologic/pathologic.module).

Notice : Undefined offset: 3 dans _pathologic_replace() (line 122 in /home/vhosts/DomainName/www/sites/all/modules/contrib/pathologic/pathologic.module).

Comments

SolomonGifford’s picture

Title: Please, I need help. » Undefined offset: 2 in _pathologic_replace()

I got this with a brand new install

Garrett Albright’s picture

Need a little bit more info. What text are you trying to filter? How have you configured the module?

thekevinday’s picture

StatusFileSize
new1.26 KB

This seems to happen to me during the following situation:
I am building a page that provides a table using drupals theme_table().

<?php
  ...
  
  foreach ($problems as $key => $problem){
    $row = array();

    $node = node_load($problem->nid, $problem->vid);
    $markup_format = 'full_html';

    $row['data'] = array($problem->id, l($node->title, 'node/' . $problem->nid . '/revisions/' . $problem->vid . '/view'), $problem->line, check_markup($problem->element, $markup_format));
    $problem_table['rows'][] = $row;
    $problem_description['total']++;
  }

  ...

  $form['problem_table'] = array(
    '#type' => 'markup',
    '#markup' => theme('table', $problem_table),
  );

  ...
?>

Random nodes will have the said problem.

I put a watchdog command inside of the _pathologic_replace() function and found that in all cases where the error appeared, the matches array had the following content:
Array ( [0] => href="/" [1] => href )

As a temporary workaround to at least silence the errors until a proper solution can be found, try the attached patch.

cobadger’s picture

I'm getting the same error using module 'html mail':

Notice: Undefined offset: 2 in _pathologic_replace() (line 118 of /[path to drupal root]/sites/all/modules/pathologic/pathologic.module).
Notice: Undefined offset: 3 in _pathologic_replace() (line 122 of /[path to drupal root]/sites/all/modules/pathologic/pathologic.module).
Notice: Undefined offset: 2 in _pathologic_replace() (line 118 of /[path to drupal root]/sites/all/modules/pathologic/pathologic.module).
Notice: Undefined offset: 3 in _pathologic_replace() (line 122 of /[path to drupal root]/sites/all/modules/pathologic/pathologic.module).
Notice: Undefined offset: 2 in _pathologic_replace() (line 118 of /[path to drupal root]/sites/all/modules/pathologic/pathologic.module).
Notice: Undefined offset: 3 in _pathologic_replace() (line 122 of /[path to drupal root]/sites/all/modules/pathologic/pathologic.module).

Using html mail configured with "Busy" theme, post-filtering set to "HTML mail" where "HTML mail" is a text format set up as shown here:

http://drupal.org/node/1130960

I do not get these errors with post-filtering set to 'unfiltered' (but resulting html email does not look like my website).

Garrett Albright’s picture

Assigned: slown » Unassigned
Status: Active » Closed (duplicate)

I never could replicate this, but I just made a new release which uses this patch created by Zombienaute. (Are you all using Windows hosts, by the way?) I encourage you all to give it a try. I'll close this issue for now; if it pops up again, feel free to re-open.

And slown, for future reference, please don't assign issues to yourself when you create them, unless you intend to provide a patch for the bug/feature/etc.

thekevinday’s picture

Version: 7.x-1.3 » 7.x-1.4
Status: Closed (duplicate) » Needs work

I was hoping this was resolved in 7.x-1.4, and then I noticed the error in my watchdog logs again.
For now, I am stuck with using my workaround patch from #3.

For the record, I am on a Redhat Linux host.

Garrett Albright’s picture

thekevinday: I don't see where Pathologic comes into play with regards to the code you posted. Could you maybe post the text that Pathologic is trying to work on which is causing the failure?

bensnyder’s picture

Getting this too

    Notice: Undefined offset: 2 in _pathologic_replace() (line 117 of /var/www/[site]/sites/all/modules/pathologic/pathologic.module).
    Notice: Undefined offset: 3 in _pathologic_replace() (line 121 of /var/www/[site]/sites/all/modules/pathologic/pathologic.module).

D 7.9
Pathologic 7.x-1.4

shane birley’s picture

I am seeing this error with the latest verison, 1.4 - but I am NOT on Windows.

netsensei’s picture

Seeing the same error.

How to reproduce:

1. Install Pathologic.
2. Create a block (or add a node) and enter this piece of content: Test
3. Notice how Pathologic fails

I have one block with this kind of code. As soon as I remove it, the errors are gone.

The patch in #3 is a good start.

To make matters more complex: my use case is a multilingual site so the patch only solves this partly.

1. It generates links like http://www.example.com/fr//
2. When you switch languages, it fetches the link which is stored in the cache. Unless you create a block which is language-agnostic and is shown on each language, it will show the link to the wrong language (i.e. http://www.example.com/fr// on the dutch version). One has to create a block per language... but with the same HTML code to make sure pathologic renders the correct links.

So, you can't solve this without solving #348421: Multilingual links with Pathologic first imho.

Garrett Albright’s picture

netsensei: The code you want me to test just renders itself as HTML, but I'm assuming it was something like <a href="/">Test</a>, right?

When I do something like that, I can replicate the error. Thanks. I think that paths consisting of just a slash should pass through Pathologic unaltered, since technically they begin with a slash.

I think the approach that I'm currently using with that Monster Regular Expression of Doom is starting to show its brittleness. Perhaps it's time for a new approach. And all these holidays coming up… hmm.

Is this also happening for anyone with paths other than just "/"?

netsensei’s picture

Yes. Correct. I noticed the HTML got mangled without the code tag here. I've only noticed this problem with / not with anything else. Might be worth, testing it with <a href="#">test</a> too. But that shouldn't raise a problem I think.

bryancasler’s picture

getting a bunch of these now after upgrading the module

bryancasler’s picture

Priority: Major » Normal

correcting the priority on this

amir simantov’s picture

Same here - these two errors. After reading this thread I still do not understand what should I suppose to do...

Any help? Thanks!

[Project: Aviram]

Garrett Albright’s picture

Hmm, these are probably unrelated to the original problem for which this issue was created months ago… Could you post a sample of text which is causing this error to appear after you run it through Pathologic, please?

amir simantov’s picture

Hi Garrett.

Thanks for your comment. Here is what I get:

Notice: Undefined offset: 2 in _pathologic_replace() (line 117 of [...]/sites/all/modules/pathologic/pathologic.module).
Notice: Undefined offset: 3 in _pathologic_replace() (line 121 of [...]/sites/all/modules/pathologic/pathologic.module).

Garrett Albright’s picture

Thanks, but what I meant is, could you give me some text you're trying to run through the filter which is causing this error?

Also, could you try updating to a 7.x-2.0 release and let me know if that helps you?

geek-merlin’s picture

i can confirm that
* 1.4 shows this notice
* and latext 2.x dev stops that.

samwillc’s picture

I can also confirm that I get no more undefined property errors using 2.x dev version.

Thanks for the update :)

Sam.

Garrett Albright’s picture

Status: Needs work » Closed (fixed)

With the full release of 7.x-2.0 (finally!), I'm closing this issue.