Need to upgrade from 2.4.8-1 to any stable version of 3

We have a client that is currently using OJS 2.4.8-1, which we setup a few years ago. This production site is operating with PHP 5.4, but my development environments are now PHP 7. I attempted to upgrade directly from 2.4.8-1 to a farily current version (I chose 3.I.2.1), but there seem to be significant problems (e.g., the admin environment seemed to loose it’s theming, uploading of the defaultManascript theme failed, and lots of trapped errors - main PHP deprecated errors, and warnings to Declaration of CustomBlockPlugin::getBlockContext() should be compatible with BlockPlugin::getBlockContext)

I know that 2.4.8-5 upgrades 2.4.8-1 to use PHP 7 (which I have done locally). However, comparing the production site (PHP 5.4) to my local upgraded 2.4.8-5 I am still seeing many trapped errors (e.g. I see lots of declaration warnings such as Declaration of CustomBlockPlugin::manage($verb, $args) should be compatible with PKPPlugin::manage and some PHP Deprecation error such as PHP Deprecated: Non-static method PKPApplication::getExposedConstants() should not be called statically in /var/www/currents_ojs-to-update/lib/pkp/classes/core/PKPApplication.inc.php on line 513, when I navigate to the Admin pages).

Am I doing something wrong here? I’ve referenced your upgrade documentation (and have some experience doing version 2 upgrades before). My gut tells me that this is a PHP issue. Running php --version on my local environment yields:

PHP 7.0.33-0ubuntu0.16.04.5 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.33-0ubuntu0.16.04.5, Copyright (c) 1999-2017, by Zend Technologies

Any help would be greatly appreciated. If you have any questions, please let me know and I’ll answer them as best I can.

Hi @wklyons,

Depending on your version of PHP there may be lots of warnings, but they are generally cosmetic and can be ignored. (PHP has become pickier about code in recent releases, and we are gradually working revise our code accordingly, but the code will run all the same.) Do you see anything marked as an Error ?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi Alec

Thanks for your response. In my development environment (where I have upgraded to 2.4.8-5), I can see two basic types of error messages. These are coming from the apache logs, so they will follow their conventions as to the classification of the severity. Most of the logged lines look like:

[Mon Jul 15 10:40:27.474978 2019] [:error] [pid 4263] [client 127.0.0.1:47082] ojs2 has produced an error\n Message: WARNING: Declaration of DOAJPlugin::display($args, $request) should be compatible with ImportExportPlugin::display(&$args, $request)\n In file: …/plugins/importexport/doaj/DOAJPlugin.inc.php\n At line: 0\n Stacktrace: \n Server info:\n OS: Linux\n PHP Version: 7.0.33-0ubuntu0.16.04.5\n Apache Version: Apache/2.4.18 (Ubuntu)\n DB Driver: mysqli\n DB server version: 5.7.26-0ubuntu0.16.04.1, referer: http://local.ojs-currents.com/index.php/currents/user

Even though apache classifies this as an “error”, I believe we would be agree that this is really only a warning. When I look at the Home page, I’m seeing 50+ of these, and when I look at an Admin page, I’m seeing amost 20. Something of note, a recurring theme for ALL of these is that they deal with and are referencing some sort of Plugin. Since the PHP level has been increased to v7, should I also be upgrading the Plugins as well? I didn’t see any sort of reference to that in the upgrade documentation (but maybe I simply overlooked it).

Each hit of the Home or Admin page also get these lines added to the the apache log:

[Mon Jul 15 10:42:57.313326 2019] [:error] [pid 4416] [client 127.0.0.1:47098] PHP Deprecated: Non-static method PKPApplication::defineExposedConstant() should not be called statically in …/lib/pkp/classes/core/PKPApplication.inc.php on line 545, referer: …/index.php/currents/index

I’m less confident that a PHP Deprecated error would be a cosmetic error. This is not a fatal error, which would cause the server to stop executing the code, but it could lead to unexpected results.

Your talking about the error levels and your attempts to work out the warnings, I completely understand. I’ve had similar experiences in upgrades that I’ve worked on. What I’m now thinking is that the upgrade I did from v2.4.8-1 to 3.1.2.1 may have gone better than I thought. However, I can see a fatal error shown the the error_log file in the ojs root directory. When trying to access an admin page I get this error, which surely must be the reason the that admin theme does not look correct (and is giving my themer signification trouble trying to work with that version). Here is the fatal error that I’m seeing:

[15-Jul-2019 10:53:18 America/Chicago] PHP Fatal error: Uncaught Less_Exception_Parser: File styles/structure/index.less not found. in index.less in …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Parser.php:2793
Stack trace:
#0 …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Parser.php(471): Less_Parser->Error(‘File `styles/st…’)
#1 …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Tree/Import.php(275): Less_Parser->parseFile(‘styles/structur…’, ‘styles/structur…’, true)
#2 …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Tree/Import.php(198): Less_Tree_Import->ParseImport(‘styles/structur…’, ‘styles/structur…’, Object(Less_Environment))
#3 …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(248): Less_Tree_Import->compile(Object(Less_Environment))
#4 …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Tree/Ruleset.php(235): Less_Tree_Ruleset->evalImports(Object(Less_Environment))
#5 … in …/lib/pkp/lib/vendor/oyejorge/less.php/lib/Less/Parser.php on line 2793

So, I have these questions: 1) do I need to upgrade Plugins, 2) do you think that my 2 to 3 upgrade went well enough that we should focus our attention on that fatal error, and, of course, 3) how do I get around the index.less problem?

Hi @wklyons,

All of those warnings can be ignored – they’re just an irritant as you try to figure out what relevant errors are in the log amidst all the noise. We’ll continue to work on these in future releases (and the next one will already be considerably improved).

However, the LESS compilation error (PHP Fatal error: Uncaught Less_Exception_Parser: File styles/structure/index.less not found) is a problem. I suspect there’s simply a missing file that didn’t get unpacked from the .tar.gz file for some reason. Do you have anything in lib/pkp/styles/structure/index.less? If not, I’d suggest re-unpacking the download package just to make sure everything is present.

Regards,
Alec Smecher
Public Knowledge Project Team

WOW - what a fast response. Thanks for your careful attention.

/lib/pkp/styles/structure has four files (and no directories): body.less, foot.less, head.less and index.less (which is 519B in size)

and I’m seeing that the index.less simply does an @import on the three other files

Hi @wklyons,

Hmm, is it possible that file permissions are set there (either on the file or in the directory it’s in) so that the PHP interpreter can’t read it?

Regards,
Alec Smecher
Public Knowledge Project Team

file permission is 644

the directory is 755

Hi @wklyons,

Hmm, this might be a 2.4.8-5 bug. Try changing styles/index.less. Find the line that reads:

@import url("styles/structure/index.less");

Change it to:

@import url("lib/pkp/styles/structure/index.less");

Regards,
Alec Smecher
Public Knowledge Project Team

I know my response above was very long (and potentially confusing - my style of writing), so just to be clear, I am currently working in the 3.1.2.1 version. Does that matter to your reponse?

And, looking in lib/pkp/styles/index.php, the //Structure line already uses that path, but has a different format (namely the 3.1.2.1 version does not have the call to url(…). It simply reads:

@import “lib/pkp/styles/structure/index.less”;

Hmmm… interesting that the execution of styles/index.less completes 4 imports but then chokes on the 5th (namely Structure)

Hi @wklyons,

Is it possible that you have a mixture of OJS 2.x and 3.x code in the same directory? For example, this can happen if you unpack the 3.x code into the same directory that already contains 2.x code.

Regards,
Alec Smecher
Public Knowledge Project Team

I do not believe I would have that - following the upgrade instructions, I un-tared the 3.1.2.1 then copied in the appropriate directories and files.

the only place I would have copied files would be to public

all of my other files sit outside of the ojs structure (at the same level as the ojs root), and I reference them in the config file

Don’t know if you’re still around (maybe it’s your lunch hour). In the mean time, I copied down the 3.1.2.1 version from our staging environment (I hikacked this to use for what I was hopefully would be a quick upgrade process). I then did a KDiff3 with a freshly un-tared copy of 3.1.2.1. There are very few differences. This is what I’ve found:

  1. cache - of course
  2. lib/pkp/classes/file/FileManager.inc.php - something that I’m working on to prevent non-admins from uploading files that aren’t .doc, .docx, .jpg and .pdf files (but after testing it, I believe I’m making the change to the wrong php file). In the 2.4.8-1 version, I had made this change to classes/file/ArticleFileManager.inc.php
  3. plugins/themes - added defaultManuscript
  4. public - all of our journals and site files
  5. templates/common - added navbar.tpl from old 2.4.8-1 (we had customized the navigation bar using this, but I don’t believe adding that file, which I don’t believe is being used in any way, would hurt). I believe there is a simpler way to customize the navbar in v3, but haven’t looked into it yet.
  6. config.inc.php - many changes here (if there’s a way to upload a file, I can send this to you, if you wish, to see if these would cause the problem). I was only trying to keep as much of the 2.4.8-1 configuration without getting in the way of the upgrade.

Hi @wklyons,

Can you try the following on the command line from inside your OJS installation directory?

find . -name \*.less -exec fgrep -H "styles/structure/index.less" "{}" ";"

This will search for all .less files, search each for references to styles/structure/index.less, and display what was found. This will help find rogue references.

On my installation, I get (and you should also)…

./lib/pkp/styles/structure/index.less: * @file styles/structure/index.less
./lib/pkp/styles/index.less:@import "lib/pkp/styles/structure/index.less";

Regards,
Alec Smecher
Public Knowledge Project Team

Morning Alec.

When I do your search, I am finding an additional index.less in the styles directory (I’m thinking my themer must have put that there, because I have no memory of doing it myself). The specific output that I get is:

./styles/index.less:@import url(“styles/structure/index.less”);
./lib/pkp/styles/index.less:@import “lib/pkp/styles/structure/index.less”;
./lib/pkp/styles/structure/index.less: * @file styles/structure/index.less

Oh, and to make matters worse, I can see that there is no ./styles/structure directory.

So, I changed the index.less from the customized version to the one downloaded with 3.1.2.1 and the admin theme now looks correct.

Thanks for you help figuring this out.

1 Like