Skip to content

Commit

Permalink
pkp/pkp-lib#8706 Clean up routing/contexts/URLs/path_info_disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Mar 8, 2023
1 parent 99c84fb commit c56693c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 81 deletions.
67 changes: 4 additions & 63 deletions classes/core/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,74 +19,25 @@

use APP\journal\Journal;
use PKP\core\PKPRequest;
use PKP\plugins\Hook;

class Request extends PKPRequest
{
/**
* Deprecated
*
* @see PKPPageRouter::getRequestedContextPath()
*/
public function getRequestedJournalPath()
{
static $journal;

if (!isset($journal)) {
$journal = $this->_delegateToRouter('getRequestedContextPath', 1);
Hook::call('Request::getRequestedJournalPath', [&$journal]);
}

return $journal;
}

/**
* @see PKPPageRouter::getContext()
*/
public function &getJournal()
public function getJournal(): ?Journal
{
$returner = $this->_delegateToRouter('getContext', 1);
return $returner;
}

/**
* Deprecated
*
* @see PKPPageRouter::getRequestedContextPath()
*
* @param null|mixed $contextLevel
*/
public function getRequestedContextPath($contextLevel = null)
{
// Emulate the old behavior of getRequestedContextPath for
// backwards compatibility.
if (is_null($contextLevel)) {
return $this->_delegateToRouter('getRequestedContextPaths');
} else {
return [$this->_delegateToRouter('getRequestedContextPath', $contextLevel)];
}
return $this->getContext();
}

/**
* Deprecated
*
* @see PKPPageRouter::getContext()
*/
public function &getContext($level = 1): ?Journal
{
$returner = $this->_delegateToRouter('getContext', $level);
return $returner;
}

/**
* Deprecated
*
* @see PKPPageRouter::getContextByName()
*/
public function &getContextByName($contextName)
public function getContext(): ?Journal
{
$returner = $this->_delegateToRouter('getContextByName', $contextName);
return $returner;
return parent::getContext();
}

/**
Expand Down Expand Up @@ -121,14 +72,4 @@ public function url(
$escape
);
}

/**
* Deprecated
*
* @see PageRouter::redirectHome()
*/
public function redirectHome()
{
return $this->_delegateToRouter('redirectHome');
}
}
10 changes: 0 additions & 10 deletions classes/oai/ojs/JournalOAI.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ public function __construct($config)
$this->dao->setOAI($this);
}

/**
* Return a list of ignorable GET parameters.
*
* @return array
*/
public function getNonPathInfoParams()
{
return ['journal', 'page'];
}

/**
* Convert article ID to OAI identifier.
*
Expand Down
5 changes: 0 additions & 5 deletions config.TEMPLATE.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@
datetime_format_long = "F j, Y - h:i A"
time_format = "h:i A"

; Use URL parameters instead of CGI PATH_INFO. This is useful for broken server
; setups that don't support the PATH_INFO environment variable.
; WARNING: This option is DEPRECATED and will be removed in the future.
disable_path_info = Off

; Use fopen(...) for URL-based reads. Modern versions of dspace
; will not accept requests using fopen, as it does not provide a
; User Agent, so this option is disabled by default. If this feature
Expand Down
2 changes: 1 addition & 1 deletion pages/oai/OAIHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function index($args, $request)
PluginRegistry::loadCategory('oaiMetadataFormats', true);

$oai = new JournalOAI(new OAIConfig($request->url(null, 'oai'), Config::getVar('oai', 'repository_id')));
if (!$request->getJournal() && $request->getRequestedJournalPath() != 'index') {
if (!$request->getJournal() && $request->getRouter()->getRequestedContextPath($request) != 'index') {
$dispatcher = $request->getDispatcher();
return $dispatcher->handle404();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ public function _handleOjsUrl($matchArray)
switch (strtolower_codesafe($urlParts[0])) {
case 'journal':
$url = $request->url(
$urlParts[1] ??
$request->getRequestedJournalPath(),
$urlParts[1] ?? $request->getRouter()->getRequestedContextPath($request),
null,
null,
null,
Expand Down

0 comments on commit c56693c

Please sign in to comment.