Prevent Warning unknown modifier in pathauto.inc by alerting on module conflicts

TravieMo9 - June 30, 2008 - 20:14
Project:Pathauto
Version:6.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:greggles
Status:closed
Description

When I use Pathauto I get this warning message in red repeated about 25 times after the page refresh:

warning: preg_replace(): Unknown modifier 'p' in /home/content/t/r/a/travnich40/html/mchurch/sites/all/modules/pathauto/pathauto.inc on line 185.

This happens regardless of what I choose as a replacement pattern from the list. It happens on different content types. I have a node override I'm using for blog page and thought it might be related, but it does it on a default page type also. The path alias happens despite the warning, although it might not include all the tiers of the path that I have chosen.

I have a test site at "localhost" at home and nothing like this happens. I'm running php5 at home but php4 on my hosting account.

#1

greggles - July 1, 2008 - 16:15
Title:Warning unknown modifier in pathauto.inc» Prevent Warning unknown modifier in pathauto.inc by alerting on module conflicts
Version:5.x-2.3» 6.x-2.x-dev
Category:bug report» feature request

From the pathauto homepage:

  • WYSIWYG Conflict FCKEditor, TinyMCE, etc. If you use a WYSIWYG editor, please disable it for the Pathauto admin page. Failure to do so may cause errors about "preg_replace" problems due to the <p> tag being added to the "strings to replace". See this issue for more details.

I believe that issue will provide you with a solution to your problem.

To be more proactive, though, I'd like to change this to a feature request for the dev version of Pathauto:

We should do a "module_exists('fckeditor') || module_exists('tinymce')" etc. and if any of them exist give a warning on the admin page...

#2

TravieMo9 - July 1, 2008 - 18:24

I found a solution by upgrading php on my Hosting from 4.3 to 5.2. That included a necessary library PCRE, which solved the problem. Found it in a post - sorry. I'm new to much of this. Great module once I got everything straight.

Greg

#3

greggles - July 3, 2008 - 23:35
Status:active» patch (code needs review)

And here's a patch.

It catches all of these editors: 'tinymce', 'fckeditor', 'bueditor', 'htmlarea', 'whizzywig', 'widgeditor', 'wymeditor', 'wysiwyg', 'xstandard', 'yui_editor', 'htmlbox'.

If you have one of those installed it will display a red error box.

It recommends users read the README.txt file.

It then sets a variable so that it will never show the error again.

Thoughts?

AttachmentSize
276910_better_help_to_prevent_wysiwyg_issues.patch1.57 KB

#4

Freso - July 4, 2008 - 20:30
Status:patch (code needs review)» patch (code needs work)

Is there a reason the blank line between _pathauto_warn_wysiwygs(); and _pathauto_include();?
There's no need for a double newline before function _pathauto_warn_wysiwygs() { at least.
There's a double space in the warning string.

Also, perhaps something like the following would be nicer than the current array?

<?php
    $wysiwygs
= array(
     
'tinymce', 'fckeditor', 'bueditor', 'htmlarea', 'whizzywig', 'widgeditor',
     
'wymeditor', 'wysiwyg', 'xstandard', 'yui_editor', 'htmlbox',
    );
?>

Also, since we're setting a system variable, perhaps it would be a good thing to use watchdog() instead of just a drupal_set_message() which will quickly disappear. A watchdog() call will be accessible in the logs and not just disappear once the message has been shown once.

Also also, having the changes to the README.txt in the same patch would be nice, so we know the entirety of what we're reviewing. :)

#5

greggles - July 4, 2008 - 23:05

Thanks for the review. I'll certainly do the cleanups you mention.

I mostly like the watchdog idea. My reason to show this once and not again is that people can configure most WYSIWYG editors to not cause problems with Pathauto. So, there's no need to warn (or watchdog) all the time for something that might not be a problem. Right?

I don't have any changes to README related to this - there's already a note in there about the WYSIWYG conflicts.

I'm also not 100% sure that we need this. I haven't seen any reports of this issue in a long time, but if we add this feature then we could remove the warning from the front page.

We could also add a warning in this system about the category module for the same reasons.

#6

Freso - July 5, 2008 - 11:25

I just meant that drupal_set_message() should be replaced with watchdog() but leave the rest of the logic as it is. This means that the watchdog() call would only happen once, while pathauto_wysiwyg_warned isn't TRUE.

We could also add a warning in this system about the category module for the same reasons.

Restate?

#7

greggles - July 7, 2008 - 12:48

Restated: the category module also has known problems with Pathauto. So, as long as we are going to warn people about module conflicts we should warn about that one too (and add it to README.txt).

At least for me, I tend to ignore the watchdog until I've got a problem. At the point people notice this problem with Pathauto the watchdog message may be deleted from the log. I'd rather give the message at the time the error is introduced and when the user is in a place to do something about it.

#8

Freso - July 7, 2008 - 14:44

Isn't the watchdog message shown? Hohum. As a compromise, perhaps do both? Or perhaps dump the system variable and (conditionally) add the warning "directly" to the affected box? So that it is always shown. (Like we're currently doing when explaining why transliteration isn't enable-able.)

#9

greggles - July 7, 2008 - 15:36
Status:patch (code needs work)» patch (code needs review)

Oooh - now that's an idea I really like!

The field already had a warning about WYSIWYGs which I've removed it in favor of this conditional one.

AttachmentSize
276910_better_help_to_prevent_wysiwyg_issues_9.patch2.36 KB

#10

Freso - July 7, 2008 - 16:03
Status:patch (code needs review)» patch (code needs work)

There's still a double space in the warning text. :) (Between "page." and "Please".)
Also, the $wysiwygs array's last item should be followed by a comma. Also, perhaps the array could/should be sorted alphabetically instead of, eh, randomly?

Looks good otherwise. Not tested.

#11

greggles - July 7, 2008 - 16:31
Status:patch (code needs work)» patch (code needs review)

It was sorted by popularity (more or less, not officially) but alphabetically seems like a better idea for long term maintenance.

Both suggested changes implemented in this patch (hopefully one day I'll start doing one space by habit...).

AttachmentSize
276910_better_help_to_prevent_wysiwyg_issues_11.patch2.41 KB

#12

Freso - July 7, 2008 - 18:15
Status:patch (code needs review)» patch (code needs work)

Just noticed one more string thing! Please the move the space ("t(' You[...]") to before the '<em>'. The space in the translatable string will invariably lead to translations without it - and it is both easier and less error prone in the long run, to simply move the leading space out of the string. :)

#13

greggles - July 15, 2008 - 23:40
Status:patch (code needs work)» patch (code needs review)

Alrighty...I changed to "strong" instead of "em" since we use "strong" on the transliteration info text.

I guess this is close to ready now.

AttachmentSize
276910_better_help_to_prevent_wysiwyg_issues_13.patch2.53 KB

#14

Freso - July 28, 2008 - 09:38

Code looks good to me. Not tested, but it doesn't seem to be dangerous code. If it works for you, do commit. :)

#15

greggles - August 4, 2008 - 16:07
Assigned to:Anonymous» greggles
Status:patch (code needs review)» fixed

Great, thanks for the nudge. I committed it - http://drupal.org/cvs?commit=131508

#16

Anonymous (not verified) - August 18, 2008 - 16:16
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.