miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Specific miniBB Support Forums / Specific /  
 

PM keeps saying that I have a new message

 
 
Page  Page 1 of 3:  1  2  3  Next »

Author Rider
Partaker
#1 | Posted: 8 May 2018 15:15 
We have the problem that on the main screen (Active topics) in the top menu bar it keeps saying for example "Private messages NEW: 1 / 2", even after having read the new message. Logging out and back in, still the same. Then, after having deleted the message, it says "Private messages [2]" on the main screen, which is not true because there is only one message left. What's going on?

I'm on 3.1. I'm not aware that I changed or updated anyting lately. Latest update was the PHP update on the server few months ago.

Author Paul
Lead Developer 
#2 | Posted: 8 May 2018 22:24 
Do you have steps to repeat this problem, like for example, could you guide to repeat it on minibb.org demo?

Does it come only for your account, or for the other accounts, too?

Also, do you have files-based mode for storing PMs, or mySQL-based?

Author Rider
Partaker
#3 | Posted: 8 May 2018 23:32 
Hi Paul,

5 or 6 users made me aware of the issue today. Some say they saw the bold number on top but didn't see a new private message, others say no bold number but yes message. And me, I see now it says 2 (not bold) while there are actually 3 messages in inbox. It seems like the system has lost count. Something is messed up. We have files-based system. It used to work fine. Maybe a server rights issue? Although inbox.php and settings.php are being updated, where inbox.php contains the truth, but settings.php doesn't.

I could try to reproduce in your demo environment, but that will be tomorrow.

Author Rider
Partaker
#4 | Posted: 9 May 2018 10:16 
Here is a detailed description how to reproduce in my own environment, I noticed that it seems that settings.php (in the users pmail folder) isn't updated on every moment when it should be.

User A sends PM to user B.
User B already had 2 messages (read) in inbox but now has 3 messages (1 unread from user A). He also has a few messages in Sent items.
User B logs in but only sees "Private messages [2]" (that's wrong). He goes to Private Messages inbox page where he sees the new message in bold on top of the list and the 2 existing messages.
He DOESN'T open de new message. Instead he goes to the Sent items page. There he deletes a random message.
He returns to main page and BINGO!!! the menu bar now says "Private messages NEW: 1 / 2".
He goes back to the Private messages page and opens the bold message.
He returns to the main page but the menu bar still says "Private messages NEW: 1 / 2".
He has to delete a file from the Sent items as a workaround (like he did 4 steps back) to let on the main page show "Private messages [3]"

So far it looks like the settings.php file of user B isn't triggered or updated when it should (this would be at the moment when A sends PM to B, or when B logs in, I suppose)

Author Rider
Partaker
#5 | Posted: 9 May 2018 11:24 
Correction:
Where I said "Private messages NEW: 1 / 2" I meant 1 / 3 in stead of 1 / 2

Author Paul
Lead Developer 
#6 | Posted: 9 May 2018 21:16 
I have an extra question - you have a setting named $safe_mode_enabled - is it uncommented/set to TRUE, or you behave on the real files based mode (you could check your PM folder via FTP - then for each `user ID`-named folder where messages are stored in, you should see 'inbox', 'sent', 'remind' folders and the system files).

It's not easy to fix something or conclude what's wrong unless I have exact steps to repeat on my side and get a clue this is a constant problem. There could be a situation when your server has some filesystem issues and could not read this or that file, that's why the PM script could not update them in-time, this give an impression of wrong numbers. It could be file permissions problem as well. So may be you could start from that - manually and recursively change all files and folders so they belong to the www server's ownership, and make sure they really belong to it.

If it all worked smoothly before, and it doesn't work properly now, it only could mean that something has been updated on your server, which affects the file system, and most likely it's the OS update (btw what OS are you on?). I suppose, it doesn't depend on PHP or web-server updates. Also, if your website has been restored from a backup by the automated server's tools, this problem with file permissions could appear as well.

Right now on minibb.org demo I've set the PM system so it works in files-based mode, and it's not a Safe-Mode. If you could repeat steps of the problem on the demo so I could replicate them on my side, that would be perfect. But in general, if such issues began, may be it would be better to switch to mySQL-based mode. It's more stable. File-based mode for PM was introduced for really large forums, to remove the load from the active forums database, and this more supposes the very powerful server which runs with no filesystem issues.

One note - these message numbers are NOT updated if you log in or out. Login doesn't affect PM procedures. File update only happen when you send, delete, or read a message.

Author Rider
Partaker
#7 | Posted: 9 May 2018 22:19 
OK, I'll start checking some things.

I just tried your demo environment. It works fine there. So it's our own problem.

Our environment worked fine until about 2 weeks ago.

In our code lines $safe_mode_enabled is not set anywhere. There's no place to set to TRUE or FALSE. It's only present in addon_pmail_send.php where it says "if(isset($safe_mode_enabled) and $safe_mode_enabled) [...]". Anyway, through FTP I can see that we have 'inbox', 'sent', 'remind' folders and the system files.

I just checked the permissions in our environment. All folders from shared_files and deeper, and the system files, have the rights 0777 (rwx rwx rwx). The message-files themselves have 0666 (rw- rw- rw-)

The OS is CentOS (Linux), I don't know which version but it might be useful to ask server support which version and if there have been any changes lately.

PHP is 5.6.35.

I could switch to MySQL-based, but I suppose that users will lose their existing messages, or do you have some convert-tool available?

I am really doubting if I will ever find the cause of this problem. It just doesn't make sense at all. There is not even a small glimpse of what has happened.

Author Rider
Partaker
#8 | Posted: 9 May 2018 23:09 
Correction:
Never mind my remark about $safe_mode_enabled, my Finder search box couldn't find it, but I could :-(
It is greyed out in addon_pmail_options.php

Author Paul
Lead Developer 
#9 | Posted: 9 May 2018 23:58 
Ok, now let's clarify what version of the PM add-on you use, it's stated in addon_pmail.php -> Plugin version ?

Rider:
I could switch to MySQL-based, but I suppose that users will lose their existing messages, or do you have some convert-tool available?
In the recent versions of this add-on (and you could also see it on the demo site if you enter PM indox - right lower part of the screen) there are "Export" tools which allow to save all messages or delete them at once. So you could warn your users that they should export or save their messages on their own prior to making this switch. Currently, there is no tool to convert between two modes, so that's the only way so far.

But if you make the switch, all older structure will stay, so whatever happens and whatever is requested by someone, you could give out the PM files directly.

Rider:
I just checked the permissions in our environment. All folders from shared_files and deeper, and the system files, have the rights 0777 (rwx rwx rwx). The message-files themselves have 0666 (rw- rw- rw-)
It could be not just about the permissions, but the ownership of files. You could only see it from the command-line access or may be some other command-line tool, not sure how it's configured exactly on your server.

Rider:
It is greyed out in addon_pmail_options.php
It's fine so you're not in Safe Mode, but anyway, it doesn't make big sense, since the problem appears exactly in the modification processes of your files...

Author Rider
Partaker
#10 | Posted: 10 May 2018 11:56 
We have PM-version 2.4.5.

I found the ownership and group. They're the same in all folders and files throughout the entire website. So no problem there I guess.

I think I'd better install the latest version you have and uninstall the 2.4.5 version, but leave the pmail folder as is. Just to see if that solves the problem. After that I can choose whether I want to switch to mySQL-style.

Does the latest PM-version run on MiniBB 3.1?

Thanks a lot for thinking with me.

Author Paul
Lead Developer 
#11 | Posted: 10 May 2018 18:37 
Rider:
They're the same in all folders and files throughout the entire website.
Hmm... I'm not sure how it's possible, but they should not be the same for entire website :) i.e. something in shared_files/pmail should be allowed to write and execute only for the web-server ownership, not the other users. However your server could have some specific configuration, I couldn't be sure on it.

Rider:
Does the latest PM-version run on MiniBB 3.1?
I couldn't be sure on it. From the updates history I see that the updates I've made, were also partially containing updated functions which strictly relate to newer miniBB versions and the Premoderation add-on. There are no changes made since 2.4.5 which would affect the files updates routine. So I doubt this update would help. I'm 99% sure the problem is somewhere else.

Actually, writeFile_settings function of addon_pmail_funcfl.php is the one which updates the settings.php file for each user, and then the data is taken from it to display in the header part and other places. It's met in addon_pmail.php, bb_plugins2.php code and addon_pmail_mass.php. Most likely some hiss happens in addon_pmail.php, when it calls that function. Or even addon_pmail_send.php (which first calls calculateMessages for each user - but then it calls writeFile_settings anyway).

So from your description, it seems like settings.php is not updated when a new message is being sent, and not when it's being read. But it's updated when some message is deleted. Not sure why it happens so... so far no clues.

Also, one step which I don't have on miniBB demo, is updating the "Email notifications" box - do you have it on your forum?

Author Rider
Partaker
#12 | Posted: 10 May 2018 21:04 
Paul:
in shared_files/pmail should be allowed to write and execute only for the web-server ownership, not the other users.
It's a Linux thing I think. Owner is almost always "psacln" and very sometimes "root" or "psaserv". I can't change them in Plesk.

I just tested what happens if I delete settings.php from user B's (the recepient) folder. When user A sends the message a new settings.php for B is created. So writeFile_settings works fine in itself. But the values are wrong. So I guess this basically means that there is something going wrong during determining the values in the function calculateMessages, i.e. in:

$fName=$GLOBALS['pmailDir']
.'/'.$user_id.$pref.'inbox.php';
$inboxtotal=0; $inboxunread=0;
if(file_exists($fName)) {
include($fName); $inboxtotal=sizeof($pmailMsgs);
foreach($pmailMsgs as $k=>$v) if($v['viewed']==0) $inboxunread++;
}


The file inbox.php contains the following code (edited for privacy purposes):
$pmailMsgs=array('123456789'=>array('userfrom'=>'2193','userfromnick'=>'John','subject'=>'test','time'=>'1525973532','viewed'=>'0','important'=>'0','replied'=>'0'),'987654321'=>array('userfrom'=>'2193','userfromnick'=>'John,'subject'=>'test','time'=>'1525973922','viewed'=>'0','important'=>'0','replied'=>'0'));


In our environment this results in the following values for the figures in settings.php:
$inboxtotal=1;
$inboxunread=1;




But since we think I have an environmental problem, wo won't find a cause of the problem in the above code:-((

Author Rider
Partaker
#13 | Posted: 10 May 2018 21:31 
Correction:
I deleted a quote too many in inbox.php during my privacy intervention;-) It looks like this:

$pmailMsgs=array('123456789'=>array('userfrom'=>'2193','userfromnick'=>'John','subject'=>'test','time'=>'1525973532','viewed'=>'0','important'=>'0','replied'=>'0'),'987654321'=>array('userfrom'=>'2193','userfromnick'=>'John','subject'=>'test','time'=>'1525973922','viewed'=>'0','important'=>'0','replied'=>'0'));

Author Paul
Lead Developer 
#14 | Posted: 10 May 2018 22:58 
Could you try the following? Create and run test.php with this code:

<?php

$pmailMsgs=array('123456789'=>array('userfrom'=>'2193','userfromnick'=>'John','subject'=>'test','time'=>'1525973532','viewed'=>'0','important'=>'0','replied'=>'0'),'987654321'=>array('userfrom'=>'2193','userfromnick'=>'John,'subject'=>'test','time'=>'1525973922','viewed'=>'0','important'=>'0','replied'=>'0'));

echo sizeof($pmailMsgs);

?>
what value will it output?

Author Rider
Partaker
#15 | Posted: 10 May 2018 23:00 
Ok I'm trying.

Page  Page 1 of 3:  1  2  3  Next » 
Specific miniBB Support Forums / Specific /
 PM keeps saying that I have a new message
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑