We are moving to Git Issues for bug tracking in future releases. During transition, content will be in both tools. If you'd like to file a new bug, please create an issue.

Bug 8160 - Call to a member function getRouter() on a non-object
Call to a member function getRouter() on a non-object
Product: OJS
Classification: Unclassified
Component: Framework
All All
: P3 normal
Assigned To: PKP Support
Depends on:
  Show dependency treegraph
Reported: 2013-03-14 15:22 PDT by Shubhash Wasti
Modified: 2013-07-25 13:26 PDT (History)
2 users (show)

See Also:
Version Reported In:
Also Affects:

Error Trace (1.83 KB, text/plain)
2013-03-15 11:42 PDT, Shubhash Wasti

Note You need to log in before you can comment on or make changes to this bug.
Description Shubhash Wasti 2013-03-14 15:22:19 PDT
This bug applies to OJS versions 2.3.x and 2.4.x

It seems that OJS galley supports only HTML and PDF files. If any other file types are uploaded to the galley, the following error is recorded in PHP error log when a user accesses those files.

PHP Fatal error:  Call to a member function getRouter() on a non-object in <ojs-directory>/lib/pkp/classes/template/PKPTemplateManager.inc.php

For example, one of our journals allows readers to download mp3 and epub files.
Any time a reader clicks on those files, a PHP error similar to above is generated without fail.

Note that the user will be able to download the files without any problem and won't notice anything unusual. The only problem is that the error log on the server fills up quickly with those error messages.
Comment 1 Alec Smecher 2013-03-14 16:35:04 PDT
Shubhash, could you turn on the show_stacktrace setting in config.inc.php and submit the full error trace here?
Comment 2 Shubhash Wasti 2013-03-15 11:42:53 PDT
Created attachment 3921 [details]
Error Trace
Comment 3 Shubhash Wasti 2013-03-15 11:48:19 PDT
I had made the following change a few months ago to get rid of the getRouter errors and have not seen any ill side-effects yet. Not sure if it a proper fix, but seems to work.

--- a/pages/article/ArticleHandler.inc.php
+++ b/pages/article/ArticleHandler.inc.php
@@ -101,10 +101,11 @@
                        } else {
                                        array($galley->getArticleId(), $galley->getId()),
+                               exit;

                $templateMgr =& TemplateManager::getManager();
Comment 4 Alec Smecher 2013-03-15 12:50:03 PDT
Fix TemplateManager::getManager call
Comment 5 Alec Smecher 2013-03-15 13:02:14 PDT
Shubhash, can you check if the patch linked in comment #4 fixes the problem? (You'll have to revert your modification first.)
Comment 6 Shubhash Wasti 2013-03-15 13:16:58 PDT
Alec, after applying the patch, a new error came up:

PHP Fatal error:  Call to a member function getNameKey() on a non-object in ojsdir/lib/pkp/classes/template/PKPTemplateManager.inc.php on line 123

That's all I get even with show_stacktrace enabled.
Comment 7 Alec Smecher 2013-03-15 14:55:02 PDT
Fix error log for non-HTML non-PDF galleys
Comment 8 Alec Smecher 2013-03-15 15:00:02 PDT
Fix error log for non-HTML non-PDF galleys
Comment 9 Alec Smecher 2013-03-15 15:00:57 PDT
Shubhash, found it -- it's similar to your fix but gets one additional case. See comment #7. (The patch in comment #4 is harmless; it'll be in future releases but doesn't cause/fix errors.)
Comment 10 Alec Smecher 2013-07-25 13:26:01 PDT
Fix error log for non-HTML non-PDF galleys