[OJS3.2.0.2] »ojs2: 404 Not Found« in php.log

@asmecher

After our upgrade from OJS2.4.8 to 3.2.0.2 I’ve spotted the following line in the php.log:

[timestamp] ojs2: 404 Not Found

What’s triggering this and how can I fix it?

Thanks,
Tobias

Hi @twa,

That’s not enough information to be able to tell, but you can correlate the timestamp against your Apache access log to see what the request URL was.

Regards,
Alec Smecher
Public Knowledge Project Team

As the main thread about this subject was closed for new posts I decided to answer here. I have some new information that may help to track the source of similar “ojs2: 404 Not Found” errors in the log-file.
I added one line to the file /lib/pkp/classes/handler/PKPHandler.inc.php to log the request that caused 404-error.
To do it I found this (almost in the end of the file):
if (!$context) $request->getDispatcher()->handle404();
and added one more line right after it:
if (!$context) error_log("Request caused 404 error: '" . $requestedPath . "'");
it helped to see, that in my case 404-error is connected with request “mappng” - I have no idea WHAT is it (my database doesn’t have such word - I searched and NO files contain such word) - a bit confusing. Maybe you know what this “mappng” is about and where does it come from to make this 404-error appear in the log at every page loading ?

A bit later I understood, what was that mysterious “mappng” in the 404-error request. In my case it was “map.png” (it seems the system removes dots from request string, that’s why I saw just “mappng” in the log) - searching through files showed that there was a broken link to this png-image in one of the customized templates and it solved my problem. So I can really suggest you adding the same code-line as I did (see my previous post) to locate the source of your 404-error in error_log file.

Thanks @Dip for sharing this! Sadly in my case it changes the error message from

ojs2: 404 Not Found

to

ojs2: Could not convert selected objects.

Do you have another idea on how to get a grip on fixing this unknown error?

Thanks,
Tobias

It seems that the variable you put as an argument in error_log function is not a string (some object) - try to use json_encode() function to “convert” it to string - I use such trick when I need to see more information in the site log.
error_log("Maybe this info will help: '" . json_encode($someObjectVar) . "'");
Of course use your real var name instead of “$someObjectVar”
Be careful - some objects may contain a lot of elements ! You may get a huge useless log instead :slight_smile: