Contact form isn´t working when user is not logged in (General)

by Tommy Nilsson ⌂, (649 days ago)

I have just realized that the contact form isn´t working when a user isn´t logged into the forum - argh.
The page returns HTTP ERROR 500.
The form does work when a user is logged in.
captcha_email on/off makes no difference.
I have looked through contact.inc.php but can´t figure out what is wrong.
Forum is version 20220803.1. PHP version is 8.0.
Any help is appreciated.

/Tommy

Avatar

Contact form isn´t working when user is not logged in

by Auge ⌂, (649 days ago) @ Tommy Nilsson

I have just realized that the contact form isn´t working when a user isn´t logged into the forum - argh.
The page returns HTTP ERROR 500.

Hmm, this is the second report about a HTTP status 500 within a few weeks. The first was (initially) about not saving entries of registered users who are not moderators or administrators. After a first check of the code it is something with the spam check with Akismet or B8 (Bayes-based Filter). In both cases the error occurs with PHP 8.0.x or 8.1.x.

The form does work when a user is logged in.
captcha_email on/off makes no difference.
I have looked through contact.inc.php but can´t figure out what is wrong.
Forum is version 20220803.1. PHP version is 8.0.
Any help is appreciated.

I will look into the code myself. I suspect that there is something incompatible with PHP 8, we don't know. I am afraid that this will be a very elaborate analysis. :-(

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

Contact form isn´t working when user is not logged in

by Micha ⌂, (649 days ago) @ Auge

Hi,

In both cases the error occurs with PHP 8.0.x or 8.1.x.

FYI: I run the forum using PHP version 8.1 and it works. Today, I updated the template and checked the mail function. All mails were received, without an error. I also try PHP 8.2 and it works.

Maybe the error, i.e., not saving entries of registered users, is also related to the mail function (sending notification mail)?!

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Avatar

Contact form isn´t working when user is not logged in

by Auge ⌂, (649 days ago) @ Micha

Hello

In both cases the error occurs with PHP 8.0.x or 8.1.x.


FYI: I run the forum using PHP version 8.1 and it works. Today, I updated the template and checked the mail function. All mails were received, without an error. I also try PHP 8.2 and it works.

Thank you for sharing your experience. If one of the functions was removed from PHP with version 8.0 or 8.1 I would expect to have seen reports earlier than a half year after the release of the current version. Beside from that I would expect the script to fail silent instead causing the HTTP status 500.

Ahem, that said, I have one simple question to @Tommy and also to @Markus. Do you have access to the server logfiles? Normally, when the server replies with HTTP status 500 you should be able to see the cause of the underlying error in the access log or, if available, in the error log.

Maybe the error, i.e., not saving entries of registered users, is also related to the mail function (sending notification mail)?!

Let's taking this as given fact. If we assume the mail function to be broken, it should be broken in every case.

Thoughts about the scenario in the other thread: When a user has avtivated the mail about new entries in a thread, why saving an entry works in case of a posting made by an admin or mod but not in case of a posting made by a "normal" user? And why it is possible to post new entries for "normal" registered users since Markus deactivated the spam checks for entries that was made by those "normal" users?

The case in this thread is the broken mail function only for unregistered users. Why does the function work for registered users?

Beside from that, the only places I found in the code with a distiction between admins and mods as well as normal users (registered or not) is the spam check. To be fair, I searched only in includes/posting.inc.php but not in includes/contact.inc.php.

@Tommy: Do you have activated Akismet or B8 (Bayes-based filter) for the contact form? And if yes, which of the spam prevention methods is activated for the contact form and is it also activated for registered users or not?

@Micha: Do you have activated one of the spam prevention methods for other purposes than entries (I know you activated B8 for that purpose)?

Markus's configuration is now (after deactivating the checks for registered users) as follows.

B8 check entries is active
Stop Forum Spam is active (but irrelevant for this issue)
Bad Hehaviour is active (but IMHO also irrelevant for this issue)
Akismet check entries is active

Maybe the collection of spam prevention configurations in the different cases brings a clearer sight onto the problem.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

Contact form isn´t working when user is not logged in

by Micha ⌂, (649 days ago) @ Auge

Hello Auge,

@Micha: Do you have activated one of the spam prevention methods for other purposes than entries (I know you activated B8 for that purpose)?

Yes, I used B8 for SPAM protection as well as Bad Behavior. Currently, I don't use Stop Forum Spam and Akismet.

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences

Contact form isn´t working when user is not logged in

by Tommy Nilsson ⌂, (648 days ago) @ Tommy Nilsson

I don´t have access to the server log files. The One.com (my webhotel) chat support couldn´t see what wrong as it´s “custom code”. Their tech support will monitor my site and email me within 24 hours with a result.

Turning PHP errors on, I suddenly got this:

Fatal error: Uncaught Error: Call to a member function getResponse() on null in /customers/3/d/5/svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php:250 Stack trace: #0 /customers/3/d/5/svenska-lok.se/httpd.www/forum/includes/contact.inc.php(176): Akismet->isSpam() #1 /customers/3/d/5/svenska-lok.se/httpd.www/forum/index.php(149): include('/customers/3/d/...') #2 {main} thrown in /customers/3/d/5/svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php on line 250

I then turned akismet_mail_check off and bingo! The form now works even when you´re not logged in.

b8_mail_check is off.

I hope this helps. :-)

/Tommy

Avatar

Contact form isn´t working when user is not logged in

by Auge ⌂, (648 days ago) @ Tommy Nilsson

Hello

Turning PHP errors on, I suddenly got this:

Fatal error: Uncaught Error: Call to a member function getResponse() on null in .../svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php:250 Stack trace: #0 .../svenska-lok.se/httpd.www/forum/includes/contact.inc.php(176): Akismet->isSpam() #1 .../svenska-lok.se/httpd.www/forum/index.php(149): include('...') #2 {main} thrown in .../svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php on line 250

I then turned akismet_mail_check off and bingo! The form now works even when you´re not logged in.

b8_mail_check is off.

I hope this helps. :-)

Of course, it does.

At the moment I am not sure, how to analyse and to solve it, but this is a message we can work with. I expect this to be also the cause of the error, reported in the neighbouring thread. Thank you very much.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

Contact form isn´t working when user is not logged in

by Auge ⌂, (648 days ago) @ Tommy Nilsson

Hello

Fatal error: Uncaught Error: Call to a member function getResponse() on null in .../svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php:250 …

Following the trace of the error messages, my first check was to validate my key to exclude that Akismet possibly is classifying the forum software as a non-personal use (this is the condition for free use of Akismet). The Akismet-API provides a method to do this and even without coding the check one can perform it with a tool like Insomnia or Postman (to name an open source project and a commercial product). At least my API-key is valid.

In the second step I searched for the source of the plugin, that we use. Our plugin is meanwhile very old (from the comment box: "Akismet PHP4 class"). The version information, provided in the comment box of the plugin script file is v0.3.4, created in the year 2008. The link to the project page is dead, even the page, the project page is forwarded to, is dead.

I found an Akismet-plugin for "OJS/OMP" (Open Journal System for scientific journals), written in PHP (licence GPL 2 or later) with the latest commit in february 2022. I have no clue if it would be worth the effort to port it to our needs.

The search for "Akismet" on Github (selected language: PHP, ordered descending by the latest commit) provides several possibilities.

But also the API documentation provides code examples, written in PHP (in example for checking comments/entries) (but also simple examples for other interesting purposes like checking for (not) reaching a monthly usage limit).

Generally I found many similarities between the code in our repository and the example code in the API-documentation. The API seems to be very stable over the years. But the error message, provided by Tommy, states clearly, that there is an error in line 250 of the Akismet class file.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

Avatar

Contact form isn´t working when user is not logged in

by Auge ⌂, (496 days ago) @ Tommy Nilsson

Hello

After replying in your new report about another case of HTTP-status 500 and re-reading this thread, I want to come back to your error message.


Fatal error: Uncaught Error:

Call to a member function getResponse() on null in /customers/3/d/5/svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php:250

Stack trace: #0 /customers/3/d/5/svenska-lok.se/httpd.www/forum/includes/contact.inc.php(176):

Akismet->isSpam() #1 /customers/3/d/5/svenska-lok.se/httpd.www/forum/index.php(149):

include('/customers/3/d/...') #2 {main} thrown in /customers/3/d/5/svenska-lok.se/httpd.www/forum/modules/akismet/akismet.class.php on line 250

This ($response = $this->…) is line #250 of the namely file.

 /**
  * Query the Akismet and determine if the comment is spam or not
  * 
  * @return boolean
  */
 function isSpam() {
  $response = $this->http->getResponse($this->_getQueryString(), 'comment-check'); //<== line #250
 
  return ($response == "true");
 }

I am not familar with the code of the Akismet class, but does "Call to a member function getResponse() on null" mean, that there is perhaps an unhandled NULL value? In the line #250 the code calls the method getResponse() which is calling the method $this->_getQueryString() for its first parameter $request (See lines #136 ff. for the method getResponse() itself and lines #366 ff. for the method _getQueryString()). The second parameter cannot be NULL because it's the string "comment-check". So it can only be the first parameter (_getQueryString()), that could be a NULL-value.

That's the code of _getQueryString().

 
 /**
  * Build a query string for use with HTTP requests
  *
  * @access Protected
  * @return String
  */
 function _getQueryString() {
  foreach($_SERVER as $key => $value) {
   if(!in_array($key, $this->ignore)) {
    if($key == 'REMOTE_ADDR') {
     $this->comment[$key] = $this->comment['user_ip'];
    } else {
     $this->comment[$key] = $value;
    }
   }
  }
 
  $query_string = '';
 
  foreach($this->comment as $key => $data) {
   $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
  }
 
  return $query_string;
 }
 

Could it be possible, that the code returns NULL? I mean, $_SERVER is one of PHP's own, native superglobal arrays. I would expect this array never ever to be empty.

I hope this helps. :-)

I also hope so. :-)

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!

RSS Feed of thread