Bug 8160 - Call to a member function getRouter() on a non-object
Call to a member function getRouter() on a non-object
Status: RESOLVED FIXED
Product: OJS
Classification: Unclassified
Component: Framework
2.4.3
All All
: P3 normal
Assigned To: PKP Support
Depends on:
Blocks:
  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:


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

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 {
                                $this->download(
                                        array($galley->getArticleId(), $galley->getId()),
                                        $request
                                );
+                               exit;
                        }
                }

                $templateMgr =& TemplateManager::getManager();
                $templateMgr->addJavaScript('js/relatedItems.js');
Comment 4 Alec Smecher 2013-03-15 12:50:03 PDT
Fix TemplateManager::getManager call
https://github.com/pkp/ojs/commit/7a10e4b1d15b95fd0fb422bc70099c00193cc12c
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
https://github.com/pkp/ojs/commit/ea3cf543cf14a03e27f894bd2fc073505b0d545f
Comment 8 Alec Smecher 2013-03-15 15:00:02 PDT
Fix error log for non-HTML non-PDF galleys
https://github.com/pkp/ojs/commit/a6a090a9cf51c2c3b16cce4ed9967a694c36a59b
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
https://github.com/pkp/ojs/commit/6ce688565ad88edc4d429c6f5641f8945b17dc98