I enable the module and wanted to test what it would do with the 5 star rating on a comment but even with the boxed checked it will not print comments. I have some custom changes to the comment module but am unsure if this is causing the problem.

EX.

http://www.adoptionagencyratings.com/print/adoption-partners.htm

CommentFileSizeAuthor
#11 print_comments.patch783 bytesjcnventura

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Hi,

I have just tried printing comments and using the fivestar module, and it works.. My guess is that the reason that it no longer works is because of your customizations.. Just so that you know, the fivestar rating is reduced to a number.. :)

Since it is working for me, I can't help you anymore.. I tried to look into your example's source code and I can't find a smoking gun.. Try looking into all the print.module code, and comment out all the preg_replace calls.

Try also to use var_dump($comments); right after the $comments = comment_render($node, $cid); line.
If you can, PM me, the output of this var_dump.

Thanks,

João Ventura

jcnventura’s picture

Hi,

Thanks for the info you in your PM. I imported the contents of the dump into my test site, and using the current code, the comments were correctly output. Have you modified the print module in any way, except for adding the var_dump?

João

joe4’s picture

No I have not modified the print module.

jcnventura’s picture

Have you tried commenting out all the preg_replace functions around line 760?

With the var_dump contents as they are now.. It MUST be for sure one of those lines that's preventing the comments from being output.

João

joe4’s picture

I commented all the preg_replace function now I get this.

Parse error: syntax error, unexpected $end in /adoptionagencyratings.com/modules/print/print.module on line 874

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Active

I wish I could help you more, but something is strange in your setup and I can't understand your problem..

sgdev’s picture

Version: 5.x-3.3 » 5.x-3.4

Have a similar problem ... we have a custom design for our comments layout and they are not printing using 5.x-3.4.

I added the var_dump($comments) after $comments = comment_render($node, $cid);, and I did receive a dump of the comments. I then proceeded to comment out each of the preg_replace functions around 760.

If I comment the first function for removing the form tag, everything is good. If I comment out the second function for 'Post new comment' title, I get the same error message as joe4: Parse error: syntax error, unexpected $end in /web/sites/all/modules/print/print.module on line 894.

If I comment out any combination of any of the preg_replace functions *other than* only commenting out the first one for the form tag, I get the error message. Any suggestions?

jcnventura’s picture

Status: Active » Needs review

Thanks for resurrecting this.

I think that I have found the culprit. Regarding the 'unexpected $end' error, it's actually due to an obscure PHP bug that if you use // in a line containing '?>', the comment will stop there ('?> is the end of PHP marker). To successfully comment out those lines you have to use /*... */.

With that in mind, the real source of the problem revealed itself later...

Can you try to apply the following patch and tell me if it works for you?

--- print-5.x/print.module 2008-04-03 15:45:47.000000000 +0200
+++ print.module      2008-04-21 13:25:41.000000000 +0200
@@ -778,7 +778,10 @@
     //Remove the comment title hyperlink
     $comments = preg_replace("/(<h3.*?>)(<a.*?>)(.*?)<\/a>(<\/h3>)/", "$1$3$4", $comments);
     //Remove the comment author link
-    $comments = preg_replace("/(<span class=\"submitted\">)(.*?)<a.*?>(.*?)<\/a>(<\/span>)/sim", "$1$2$3$4", $comments);
+    $pattern = "/(<span class=\"submitted\">)(.*?)<a.*?>(.*?)<\/a>(<\/span>)/sim";
+    if (preg_match($pattern, $comments)) {
+      $comments = preg_replace($pattern , "$1$2$3$4", $comments);
+    }
     //Remove the comment links
     $comments = preg_replace("/\s*<ul class=\"links\">.*?<\/ul>/sim", "", $comments);
     if ($cid != NULL) {

Thanks,

João

sgdev’s picture

I tried applying the patch ... it did not like that. :) Commenting out the line for "comment author link" causes me to receive Parse error: syntax error, unexpected $end in /web/sites/all/modules/print/print.module on line 894 all the time. In fact I can't even load a Drupal page without receiving the error.

I'm not sure but commenting out any of the preg_replace functions other than the first one for the form immediately causes the parse error message.

sgdev’s picture

Status: Needs review » Needs work

Meant to update the status too ... sorry about that.

jcnventura’s picture

Status: Needs work » Needs review
StatusFileSize
new783 bytes

What exactly was your problem in applying the patch? Try downloading the attached file, and then inside the print module directory, call patch < print_comments.patch.

As to the commenting out of the line, as I explained before, you can't comment it with //. It's a PHP bug and doing it will basically stop all PHP scripts (i.e. Drupal). If you want to comment it, you must use /* at the start of the line and */ at the end of the line.

João

sgdev’s picture

Status: Needs review » Reviewed & tested by the community

Sorry about that, I applied the patch incorrectly at first since I wanted to comment out and used // rather than /*. Once I applied the patch the comments are displayed! This does seem to fix the problem ... nice work.

jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

Hi,

I applied the patch to dev version in April 22. it will be in the (forthcoming) 3.5 version.

João

Anonymous’s picture

Status: Fixed » Closed (fixed)

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