OAI baseURL does not corresponding with URL

Hello everybody,

I am having a problem with OAI report. happens that baseURL in OAI is bad-formed, I dont know when and where at process upgrading, I gues that I modified some file and it affected my system, follwing pic show the problem:

Is possible fix it?

Thanks in advanced

Hola Juan.
¿Qué versión de OJS usáis?

¿Puede describir el proceso completo para enviar los datos a OAI?

¿Qué archivos modificó?
Gracias

Hi @juanito , I am replying to you in english because this mistake should have other people. I’ve installed OJS 3.1.1.4 version. I generated the OAi report via: https://revistas.javerianacali.edu.co/index.php/pensamientopsicologico/oai?verb=ListRecords&metadataPrefix=oai_dc

thanks in advanced

Hi Dear @asmecher,

could you help me with this problem?

Thanks so much!

Quizás/Perhaps

egrep -iR 'request' *
rfc1807/OAIMetadataFormat_RFC1807.inc.php:		$url = Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId()));

Hi @juanito the problem that I am facing is that baseURL is ommiting https: into URL, as I showed at first image.

Hi everybody,

I found the solution. The problem is when your OJS instance is behind an APACHE server. When if it is your case then you should change the PKPRequest.inc.php file as next:

 function getBaseUrl($allowProtocolRelative = **true**) 
{

                $_this =& PKPRequest::_checkThis();
                $serverHost = $_this->getServerHost(false);

                if ($serverHost !== false) {
                        // Auto-detection worked.
                        if ($allowProtocolRelative) {
                                $baseUrl = '//' . $_this->getServerHost() . $_this->getBasePath();
                        } else {
                                $baseUrl = $_this->getProtocol() . '://' . $_this->getServerHost() . $_this->getBasePath();
                        }
                } else {
                        // Auto-detection didn't work (e.g. this is a command-line call); use configuration param
                        $baseUrl = Config::getVar('general', 'base_url');
                }
                HookRegistry::call('Request::getBaseUrl', array(&$baseUrl));
                return $baseUrl;
        }

The problem is because allowProtocolRelative is now true, and $baseUrl = '//' . $_this->getServerHost() . $_this->getBasePath();

The solution is simple, just add “https:” to $baseUrl inside IF conditional, like this:

$baseUrl = ‘https://’ . $_this->getServerHost() . $_this->getBasePath();

Now, my OJS system can generates URL correctly.

1 Like

Hi @Juan_Pablo_Giron_Rui,

Would you be willing to open this change proposal as a pull request in github? It would be a change to this file/repository: https://github.com/pkp/pkp-lib/blob/master/classes/core/PKPRequest.inc.php [updated link]

Regards,
Alec Smecher
Public Knowledge Project Team

Dan,
Can you take me through the process to implement the solution? I’d like to take part in fixing our OJS 3.1.2.1 system.

@asmecher, I’m confused by the link you offered. Did you mean to point at this CrossRef thread, or a perhaps a GitHub link?

@Juan_Pablo_Giron_Rui, for my own clarity, can you confirm my reading? You earlier modified Request::getBaseUrl to default the $allowProtocolRelative parameter from false to true as part of setting up an Apache reverse proxy in front of OJS. This forced protocol-relative links everywhere, including in things like OAI, where the protocol should be explicit, so you effectively forced everything to https: with a second local change. Is that correct?

(Just popping in to say: yes, @ctgraham, that link was definitely the wrong one! Updated.)

Dear @ctgraham, that is right. When OJS is behind of Apache, it is necessary set up $allowProtocolRelative parameter to true, otherwise the system will not load propertly. On the other hand, IT department, at my university, recommend to use secure protocols like HTTPS. In my case, the digital certified is implemented over a server that serves all request, but not into self application server, e.g. where OJS is installed. Aforementioned, $baseUrl should be adjusted for generates propertly all URL, like shown in OAI report or e-mails templates.

Hi @Jesse_Coats,

do you have the same problem?

cheers,

To get this to work without any code modifications, I would place an SSL certificate on the Apache proxy, and place an SSL certificate (could be self-signed and no cost) on the OJS webserver, and configure an “https://” base-url in config.inc.php.

Holà @Juan_Pablo_Giron_Rui

I was glad to find your post. Your solution works well and we adopted it to use with our reverse proxy with SSL.

My question is : apart from URLs within emails and Resource identifier in OAI-PMH (that now display correct URLs with the “https://” protocol part),
does this change affect other parts/functionalities in OJS I should test and/or look at closely ?

Thanks you,

Marie-Hélène

Hello @Marie-Helene, I am happy for that solution could help you. This solution does not affect other parts or functionalities. I’ve tested for one long month and all is ok.

regards,
Juan Pablo

Glad to hear! Thank you for your answer.