OJS 3.1 Problems with some Admin pages after upgrade from 3.0.2 (Failed loading /js/build.js & ReferenceError: pkp is not defined)

Hi all,

We upgraded our 3.0.2 instance to 3.1 last week and unfortunately we have some blank pages in some of the admin pages. I scoured through the PHP logs and the only errors (not warnings) were ones like this:

Clicking on Submissions:

[Mon Oct 30 10:01:38.112897 2017] [:error] [pid 69009] [client 172.16.120.200:10338] ojs2: 404 Not Found, referer: http://playground.journals.ed.ac.uk/nibjournal/submissions

Clicking on Issues → Back Issues:

[Mon Oct 30 10:39:50.175469 2017] [:error] [pid 69009] [client 172.16.120.199:10516] ojs2: 404 Not Found, referer: http://playground.journals.ed.ac.uk/languageandpsychoanalysis/manageIssues

And clicking on Users → Users:

[Mon Oct 30 10:43:28.178761 2017] [:error] [pid 73602] [client 172.16.120.199:11011] ojs2: 404 Not Found, referer: http://playground.journals.ed.ac.uk/ScottishStudies/management/settings/access

I then thought I’d try and see if there were any issues in the browser console and there are indeed! For all of the above, there is a similar error:

Clicking on Submissions:
ReferenceError: pkp is not defined submissions (line 153, col 6)
ReferenceError: pkp is not defined submissions (line 166, col 7)
ReferenceError: pkp is not defined submissions (line 179, col 7)
ReferenceError: pkp is not defined submissions (line 192, col 6)

Clicking on Issues → Back Issues:
ReferenceError: pkp is not defined pkp.min.js (line 128, col 142)

And clicking on Users → Users:

ReferenceError: pkp is not defined pkp.min.js (line 128, col 142)

We didn’t get these errors in 3.0.2. Is there an include missing somewhere that wasn’t missing in 3.0.2? Not sure where to go from here.

Please can you help with this?

Thanks so much in advance.

Looking at the console this morning on these admin pages that don’t work, there’s a build.js not found error first!

"NetworkError: 404 Not Found - http://playground.journals.ed.ac.uk/js/build.js"

Is build.js where pkp would be defined? Searching for ‘build.js’ in the whole ojs directory, I found this in RELEASE:

6. Build the OJS package and patch files:

WARNING: If working on a stable branch, the latest `js/build.js` file will be
compiled when `tools/buildpkg.sh` is run. Remove js/build.js from the .gitignore
file and commit it to the new stable branch.

    sh tools/buildpkg.sh <VERSION> <TAG>-<BRANCH> <PATCH_DIR>

    (<PATCH_DIR> is the path to a directory containing previous OJS release
     packages against which to build patches)

I can’t find build.js anywhere. Did the above step happen? Is it something I need to do? (I hope not!)

Please help, I’m horribly confused and stuck until I get these admin pages to work.

Thanks so much in advance.

Hi!
What browser do you use? We have some problems with Chrome + OJS 3.1.

Hey :slight_smile:

This is in Firefox. I haven’t actually tried with a different browser!

Just tried on Chrome and have the same problems:

In the console (for the Submissions page):

GET http://playground.journals.ed.ac.uk/js/build.js 
submissions:10 GET http://playground.journals.ed.ac.uk/styles/build.css 
submissions:11 GET http://playground.journals.ed.ac.uk/js/build.js 
submissions:153 Uncaught ReferenceError: pkp is not defined
    at submissions:153
(anonymous) @ submissions:153
submissions:166 Uncaught ReferenceError: pkp is not defined
    at submissions:166
(anonymous) @ submissions:166
submissions:179 Uncaught ReferenceError: pkp is not defined
    at submissions:179
(anonymous) @ submissions:179
submissions:192 Uncaught ReferenceError: pkp is not defined
    at submissions:192

We had some issues with javascript processing in Chrome (in Settings → Website some tabs could not be opened).
It could not be reproduced in FF. And now it has just disappeared by itself :slight_smile:

1 Like

I’m glad it has disappeared! Wish the same thing would happen here!!!

In lib/pkp/classes/template/PKPTemplateManager.inc.php, line 636:

	// Load new component library bundle
	$this->addJavaScript(
		'pkpApp',
		$baseUrl . '/js/build.js',
		array(
			'priority' => STYLE_SEQUENCE_LATE,
			'contexts' => array('backend')
		)
	);

In lib/pkp/templates/common/headerHead.tpl, on line 17:

{load_script context="backend"}

So in the header of the page, there is:

<script src="http://playground.journals.ed.ac.uk/js/build.js" type="text/javascript">

But this file can’t be found :frowning:

So…

Looking at a 3.0.2 install, there is no call to /js/build.js in header.

I downloaded the prepackaged OJS 3.1.0 (ojs-3.1.0.tar.gz) which does have a js/build.js file! I copied this across to my OJS installation and this has solved the problem - the admin pages are now working, pkp is no longer undefined.

I installed from github following the instructions to update submodules and using composer to install dependencies.

Is there a step I missed that would have generated the build.js file? (and the styles/build.css which I have also copied across now).

Thanks so much in advance.

Hi @ianthe,

When working with a git checkout, OJS 3.1 will require some Node build tools to generate build.js. This is done automatically during the build process for the .tar.gz distribution.

@NateWr, I notice that this aspect isn’t documented in our wiki page for working with git checkouts – could you add a few notes to https://pkp.sfu.ca/wiki/index.php?title=Github_Documentation_for_PKP_Contributors#Install_Composer_dependencies?

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

Thanks @asmecher!

Wow, I thought it was “install or update dependencies” via Composer OR NPM! I didn’t realise it was both. Whoops. Well that makes more sense now. Sorry to have been daft.

We’ll need to get Node and sudo rights for it installed on our journals servers.

1 Like

Hi @ianthe,

The confusion is entirely justified! Composer manages PHP dependencies (but has a bunch of commonly used client-side JS libraries available as packages); NPM manages server-side builds of client-side JS resources. Prior to OJS 3.1.0 we only had Composer dependencies, but starting with 3.1.0 we’ve had NPM as well (as we’re starting to use vue.js).

Regards,
Alec Smecher
Public Knowledge Project Team

Do we havo to install or update dependecies (Composer and NPM) everytime we change version with git checkout?

Hi @Israel87,

It’s only strictly necessary when lib/pkp/composer.json changes and when the Vue components are modified, respectively. On a developer machine you can run npm run dev rather than npm build dev in order to have Node watch for changes and recompile automatically, if you like.

Regards,
Alec Smecher
Public Knowledge Project Team