Error on readdir() on HelpTopicDAO.inc.php

Sometimes, I don’t know how, OJS gets something wrong and because it never checks if the return of opendir() is boolean it gets passed and I get this error:

[Wed Oct 14 13:16:11.227545 2015] [:error] [pid 26915] [client 143.107.8.25:31735] ojs2 has produced an error\n  Message: WARNING: readdir() expects parameter 1 to be resource, boolean given\n  In file: /usr/home/seer/public_html/lib/pkp/classes/help/HelpTopicDAO.inc.php\n  At line: 136\n  Stacktrace: \n  Server info:\n   OS: FreeBSD\n   PHP Version: 5.6.13\n   Apache Version: Apache/2.4.16 (FreeBSD) PHP/5.6.13\n   DB Driver: mysql\n   DB server version: 5.1.66, referer: http://seer.fclar.unesp.br/lettres/help/view/editorial/topic/000032

The problem is that I don’t get one error, but my httpd-error.log is flooded with tens of thousand of the same error in a matter of seconds. I don’t know why it happens, but it happens at least once or twice a month. In some of these instances my error log grow so big that the whole system was ground to a halt.

I think that this is the same problem mentioned here: http://pkp.sfu.ca/support/forum/viewtopic.php?f=8&t=8792

Any tips on how to solve it? Maybe add a check before it (I’m not so PHP savvy, so I’m not sure what are the expected function returns).

If you add:

			if (!$dir) {
				trigger_error('opendir('.$searchPath.') failed');
				continue;
			}

between

			$dir = opendir($searchPath);

and

				while (($file = readdir($dir)) !== false) {

what gets output into the log at the next error?

This would be logged on httpd-error.log?
I will make the change, but I will have to wait until it happens again. Like I said, it is not common.

Yes, this will be logged in the same place you found the original error message.