SOLVED OJS 3.2.1.2: problem to add new custom template, HTTP status code 302 Found

Hello,

We upgraded from OJS 3.1.2.4 to OJS 3.2.1.2, we encountered a problem with custom templates. It’s impossible to add new custom template.

We hosts severals journals whith their own domains names. We have rewrite rules in htacess file as follows:
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteRule ^api/v1(.)$ /index.php/journal1/api/v1$1 [R,L]
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.
)$ /index.php/journal1/$1 [QSA,L]

When we try to add a new custom template, we fill the 3 fields: Email Key, Subject and Body
We click on “Save” button. Window closes. This notification appears: The email template was added.
But the email template was not added!

I made an investigation.
There is nothing special in error log files.
I compared with our test platforme of OJS which not have own domains names and so no rewrite rules in htacess file.
And in this environment, adding new custom templates is working.

I put some trace in some files.

I noticed, that for our production plateform whith own domains names and rewrite rules the function “add(” from the file “/lib/pkp/api/v1/emailTemplates/PKPEmailTemplateHandler.inc.php” was not called.

I looked in the browser console. Response is different in both cases.

In our test platforme of OJS whitout own domains names and no rewrite rules there are:
POST
Scheme: http
Host: journalstest.u-bordeaux.fr
Filename: /index.php/journal1/api/v1/emailTemplates
Adress: XXX.XXX.XXX.XXX:80
State: 202 OK
No Location

In our production platforme of OJS whith own domains names and rewrite rules there are:
POST
Scheme:https
Host: journal-domain1.fr
Filename: /api/v1/emailTemplates
Adress: XXX.XXX.XXX.XXX:443
State: 302 Found
Location: https://journal-domain1.fr/index.php/journal1/api/v1/emailTemplates

With rewrite rules this URL is working:

https://journal-domain1.fr/api/v1/emailTemplates

and refers to this URL:

https://journal-domain1.fr/index.php/journal1/api/v1/emailTemplates

So the difference is there is an HTTP response with status code 302 Found instead of 202 OK.

And I read in online documentation that: “an HTTP response with status code 302 will additionally provide a URL in the header field Location. This is an invitation to the browser to make a second request to the new URL specified in the location field. The end result is a redirection to the new URL.”

Is my problem comes from rewrites rules and the URL redirection which provides a new request to the new URL specified causing an HTTP response with status code 302 ?

Thanks in advance for your answer.
Best regards.
Helene

Hi @drugurkocak, Hi all,

As we shared same problems with rewrite rules, I wanted to know if you encountered this problem.
With your htaccess config file, do you manage to add new custom template wihtout HTTP status code 302 Found ?

Thanks in advance for your answer.
Best regards.
Helene

Hi @hcl

Thank you very much for your suggestions and help… As I explained in detail in my previous post, this scenario was successful on multidomain installation. But no luck if there is one domain and a journal on that domain. At least one journal has to be published on its own domain. May be I am missing something because I am not a programmer.

I can install and enable themes (pragma, classic, healt sciences) or plugins from the Plugin Gallery, or using Upload a Plugin menu.
The scenario also works on OJS 3.3 too. You may look at that url:

Test Portal for OJS Journals (adlitip.net).
For OJS 3.2.1.3, you may log in as “manager”, using password 123456, and try the plugin gallery.
URL: https://www.cancer-research.net/
These are test portals.
If you need to see other settings, I may provide them via personal message.
Regards,

Hi again @drugurkocak,

In fact I was asking you a question.

Do you manage to add new custom template without HTTP status code 302 Found ?
In the backend: Settings → Workflow → Emails → Email Templates → Add Template

Thanks again for your answer.
Kind regards
Helene

Hi @hcl
Yes, I added a custom email template without any error code now. I thought you mean custom theme. You may also test it with no hesitation.
Regards

Hi,

I changed my rewrite rules with the same as @drugurkocak and everything was working after that.

My rewrite rules were as follows:

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteRule ^api/v1(.)$ /index.php/journal1/api/v1$1 [R,L]
RewriteCond %{SERVER_NAME} ^journal-domain1.fr
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.)$ /index.php/journal1/$1 [QSA,L]

And I changed them with the same as @drugurkocak as follows:

RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} ^(www.)?journal-domain1.fr
RewriteRule ^api/v1(.)$ index.php/journal1/api/v1$1 [L,R=307]
RewriteCond %{SERVER_NAME} ^(www.)?journal-domain1.fr
RewriteCond %{REQUEST_URI} !/journal1/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.
)$ index.php/journal1/$1 [L]

HTTP status 302 changed in HTTP status 307 and it participated to solve the problem.

Thanks again to @drugurkocak.
Best regards.
Helene

1 Like

Hi @hcl
I am glad to hear that your problem has been solved.

Let me express that this solution is from @KBodarwe and @klausru and some others.
Thanks to all.
Regards,

1 Like