When I try to use this module by inserting [[Title]] brackets into the body of a node I get WSOD.

PHP error log reads:

PHP Fatal error:  Cannot redeclare freelinking_drupalorgnid_callback() (previously declared in ../sites/all/modules/freelinking/plugins/freelinking_dev.inc:19) in ../sites/all/modules/freelinking/plugins/freelinking_dev.inc on line 43

I can fix the problem by commenting out:

$freelinking = freelinking_get_plugins();

in the freelinking.module in the freelinking_filter function around line 48

Running on Drupal 6.16 with a MAMP stack

Will test other functionality and report back if any other issues arise as a result, but okay so far!

Comments

davideads’s picture

I get the same error (with the path plugin), but looking at the module's own implementation of its 'freelinking' hook, I suspect something is very, very wrong...

davideads’s picture

StatusFileSize
new635 bytes

There error seems to be the use of the require vs. require_once in the event that freelinking_freelinking is called more than once.

Attached is a very simple patch, which resolves this behavior.

davideads’s picture

StatusFileSize
new542 bytes

Whoops, there were some extraneous lines the diff from a .swp file. Here's a new version of the same patch.

jaclayton’s picture

Applying the patch allows the site to continue loading but anywhere I put a [[NodeTitle]] link there's now "Plugin nodetitle Not Found" and 3 shiny error messages at the top of the screen:

warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\test\sites\all\modules\freelinking\freelinking.module on line 115.
warning: Missing argument 2 for l() in C:\xampp\htdocs\test\includes\common.inc on line 1585.
warning: Missing argument 2 for l() in C:\xampp\htdocs\test\includes\common.inc on line 1585.

Grayside’s picture

Yes, also discussed #807004: Add Instructions to Delete Previous Freelinking Alpha on Installation.

These bugs and some architectural issues in future implementation of support for node access needs some heavy reworking. That is in progress, in the course of work this should go away.

@davideads: Thank you very, very much for the patch. The depth of issues right now means the next Alpha will be a lot of new code, so the 3.x-dev is going to be unchanging for a couple more weeks as I get a new "slate" to work off of in place.

pje’s picture

The real issue here is that freelinking_freelinking() gets called multiple times, for reasons I didn't bother figuring out. require_once doesn't fix the other error messages, because then $freelinking is an empty variable and that causes the foreach() errors. The simplest fix is to make $freelinking static and exit early if it's already set:

--- freelinking.module  2010-05-04 12:19:02.000000000 -0400
+++ freelinking.module  2010-07-31 20:39:55.000000000 -0400
@@ -107,8 +107,10 @@ function freelinking_filter($op, $delta
  * Include plugins/*.inc plugins
  */
 function freelinking_freelinking() {
+  static $freelinking;
+  if ($freelinking) return $freelinking;
   $files = file_scan_directory(
-    drupal_get_path('module', 'freelinking') . '/plugins/', '.inc');
+    drupal_get_path('module', 'freelinking') . '/plugins', '.inc');
   foreach ($files as $absolute => $file) {
     require $absolute;
   }

(The other change shown removes an extraneous '/' from the included filenames.)

(FWIW, I do not have any leftover files from a previous version, at least AFAICT.)

Grayside’s picture

That's for the looksee PJE. I'm doing a major refactor on FL for the next Alpha, so this code will get a good re-examination.

discipolo’s picture

can confirm that the changes in #6 apparently achieve the desired outcome. (no more wsod)
thanks

Suitov’s picture

Thank you, @pje #6! This fix worked a treat for me.

smokris’s picture

Status: Active » Reviewed & tested by the community

The patch on #6 solves the problem for me, too. Grayside, can you commit this patch?

sepla’s picture

The patch at #6 works fine, thanks pje.

burningdog’s picture

Title: White Screen Of Death » WSOD due to redeclaring freelinking functions
StatusFileSize
new722 bytes

Any movement on this? I've re-rolled the patch at #6 using git diff and made 'require' into 'require_once'.

Grayside’s picture

Status: Reviewed & tested by the community » Fixed

So I finally made it back here. Very sorry about that. I just pushed a fix to the dev branch which should appear in the next nightly roll.

I adjusted the approach and the syntax of the patch for style and personal preference and resolved #4 which properly should have been a separate bug.

If the fix works I will tag a new alpha.

http://drupalcode.org/project/freelinking.git/commit/d1f88bb

Status: Fixed » Closed (fixed)

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