Hi all,
Update: I realized that in my local, the content-type response type is application/json for the tabs, while in staging is text/html. That could be the culprit, but even forcing nginx to send application json is not working. It might be that OJS send specifics content types via header() function, ehich overwrites the web server rule?
Some days ago we deployed OJS to a docker/kubernetes server. Everything went well except that, when going to Settings → Journal (Where Masthead, Contact & Sections tabs are), none of them loads, with the message in Chrome JS console VM4010:1 Uncaught SyntaxError: Unexpected end of JSON input.
The reason of that is that the jsonString variable passed to $.pkp.controllers.TabHandler.prototype.dataFilter method in TabHandler.js is empty (""), hence the error thrown in that method.
Debugging a bit, by following the execution of:
- JournalSettingsTabHandler and then
- ManagerSettingsTabHandler and finnaly in
- SettingsTabHandler::showTab($args, $request) method
Good, in this method is when the first problem arises: if ($this->_isValidTab()) { simply returns false, and instead of doing/acting accordingly, the method silently finishes without returning or logging anything, and then the JS error finishes the execution for good.
Going deeply into the code, var dumping methods:
function _isValidTab() {
var_dump($this->getCurrentTab());
var_dump($this->getPageTabs());
...}
Returns the following:
NULL
array(3) {
[“masthead”]=> string(51) “controllers.tab.settings.masthead.form.MastheadForm”
[“contact”]=> string(57) “lib.pkp.controllers.tab.settings.contact.form.ContactForm”
[“sections”]=> string(45) “controllers/tab/settings/journal/sections.tpl”
}
So, the issue that brings to this problem is that the current tab is not set.
Finally, the last debug step I could thought was to go to PKPRequest.inc.php, the base class where variables are set and debug $_this->_requestVars array to see if the :
NULL
array(1) { [“k”]=> string(1) “0” }
array(1) { [“k”]=> string(1) “0” }
array(1) { [“k”]=> string(1) “0” }
While in localhost the same variable correctly has:
array(2) {
[“tab”] => string(8) “masthead”
["_"] => string(13) “1558014894862”
}
After this, I have no idea why the tab variables are not loaded, nor where to continue my debug to see the reason. Any idea would be appreciated.
OJS Version: 3.1.1.4
PS: I read this https://forum.pkp.sfu.ca/t/error-unexpected-end-of-json-input-after-upgrade-to-3-0-3/29060 post but it didn’t help sadly, and besides that, I’d like to know the reason why that happened, rather than a full wipe out of the code
PS2: Sorry the long post, tried to be as detailed as possible.