wiki.techinc.nl/opensearch_desc.php

46 lines
1.7 KiB
PHP
Raw Normal View History

2006-08-20 03:45:47 +00:00
<?php
/**
* The web entry point for generating an OpenSearch description document.
*
* See <http://www.opensearch.org/> for the specification of the OpenSearch
* "description" document. In a nut shell, this tells browsers how and where
* to submit submit search queries to get a search results page back,
* as well as how to get typeahead suggestions (see ApiOpenSearch).
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
* @ingroup entrypoint
2006-08-20 03:45:47 +00:00
*/
// This endpoint is supposed to be independent of request cookies and other
// details of the session. Enforce this constraint with respect to session use.
define( 'MW_NO_SESSION', 1 );
define( 'MW_ENTRY_POINT', 'opensearch_desc' );
require_once __DIR__ . '/includes/WebStart.php';
2006-10-16 02:31:28 +00:00
Replace direct use of $wgRestPath with wfScript() Follows-up Idb5b0d21adc6. Avoid hardcoded references to REST internal configuration variables, which create awkward "APIs" in the long run. These are hard to deprecate or detect use of, and even harder to normalize/support once variations exist. E.g. in T189966 and T233886, I've been working to remove the concept of dynamic config in favour of the uncomputed values being only valid as configuration for the component that owns the variable, instead of using Config as public API to read non-normalized information that belongs to a different component. By making the recipient responsible for any dynamic computation, it also becomes clear that these are in fact not normalized or validated, which can expose any number of unpredictable behaviours if used directly. Consider special values like `false` or `null` and the responsibility for interpreting that. Accessing these from a stable function also gives a natural place for deprecation to happen. The alternative, is for dynamic computation to happen in Setup.php for all variabls, and only ever grow and become an append-only dumping ground for every thing that we feel at some point needs validation, normalization or expansion, which doesn't scale well, hence I reversed this trend in T189966/T233886. As it happens, RestPath actually is already computed, albeit very trivially. This patch opens the way for someone to remove that in favour of PathRouter accept `false` directly and expanding (and testing) that code there instead. As for REST API, the only stable and universally supported entrypoint is /w/rest.php. Unlike some older entry points, we don't support moving or removing the rest.php file. We do support routing/aliasing additional paths to it. Change-Id: I589a8aed8db3b8e7b72e4505749bb7ef25a755d9
2024-05-21 21:04:08 +00:00
$url = wfScript( 'rest' ) . '/v1/search';
$ctype = $wgRequest->getRawVal( 'ctype' );
if ( $ctype !== null ) {
$url = wfAppendQuery( $url, [ 'ctype' => $ctype ] );
}
$wgRequest->response()->header( 'Location: ' . $url, true, 308 );
$wgRequest->response()->header( 'Cache-control: max-age=600' );