[Solved] PDF download - PHP Fatal error - Application::getApplication() returns null

I am running an OJS installation (Version 2.4.7.1) on Linux (Red Hat Enterprise Linux Server release 6.7) in Apache 2.2.15.

I am seeing these lines in my error_log:
PHP Fatal error: Call to a member function getRequest() on a non-object in .../plugins/generic/usageStats/UsageStatsPlugin.inc.php on line 223

Doing some research I could narrow this down to the fact that
Application::getApplication()
returns null whenever a PDF is downloaded. The hookName is FileManager::downloadFileFinished
whenever that happens.

Is this a bug?
Is my installation somehow borked?

Greetings
Hermann

I took a deeper look and found that in FileManager::downloadFile() there is a call to Registry::clear() before the postDownload-Hooks get called.

Application::getApplication() calls Registry::get() which in this case can’t return anything as the registry is cleared…

So this is a bug!?
Or am I missing something?

Greetings
Hermann

I think this is reported in GitHub Issue 847, and fixed in 2.4.8. Can you try upgrading and confirm whether it resolves the problem?

1 Like

Thanks, Clinton!
Yes, upgrading to 2.4.8 fixed the problem. Article downloads are logged now and those “Fatal errors” are gone.
I searched this forum but forgot to search the github issues. Next time I will look there as well.
Greetings
Hermann

PS: What’s the best way to mark this question as solved?

There is no standard way to mark a discussion solve in the forum currently. Some things that may help future users find the right answer include:

  • “liking” a correct answer to increase it’s search relevance.
  • editing the subject line by prefixing it with “[Solved]” to increase viewer interest.
  • watching the boards yourself and linking future user’s questions to a prior answer you know to be correct.