[JsonCodec] Use wikimedia/json-codec to implement JsonCodec
[mediawiki.git] / includes / MediaWiki.php
blob0cea396a9ea7fdc6e7169655a8e4ef72b51716ff
1 <?php
2 /**
3 * Helper class for the index.php entry point.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
23 use MediaWiki\Context\IContextSource;
24 use MediaWiki\Context\RequestContext;
25 use MediaWiki\EntryPointEnvironment;
26 use MediaWiki\MediaWikiEntryPoint;
27 use MediaWiki\MediaWikiServices;
29 /**
30 * Backwards compatibility shim for use by extensions that created a MediaWiki object just in order to call
31 * doPostOutputShutdown().
33 * @deprecated since 1.42, use MediaWikiEntryPoint instead
35 class MediaWiki extends MediaWikiEntryPoint {
37 public function __construct(
38 ?IContextSource $context = null,
39 ?EntryPointEnvironment $environment = null
40 ) {
41 $context ??= RequestContext::getMain();
42 $environment ??= new EntryPointEnvironment();
44 parent::__construct( $context, $environment, MediaWikiServices::getInstance() );
47 /**
48 * @return never
50 protected function execute() {
51 throw new LogicException(
52 'The backwards-compat MediaWiki class does not implement the execute() method'
56 /**
57 * Overwritten to make public, for backwards compatibility
59 * @deprecated since 1.42, extensions should have no need to call this.
60 * Subclasses of MediaWikiEntryPoint in core should generally
61 * call postOutputShutdown() instead.
63 public function restInPeace() {
64 parent::restInPeace();
67 /**
68 * Overwritten to make public, for backwards compatibility.
70 * @deprecated since 1.42, extensions should have no need to call this.
72 public function doPostOutputShutdown() {
73 parent::doPostOutputShutdown();
76 /**
77 * This function commits all DB and session changes as needed *before* the
78 * client can receive a response (in case DB commit fails) and thus also before
79 * the response can trigger a subsequent related request by the client.
81 * @param IContextSource $context
83 * @since 1.27
84 * @deprecated since 1.42, extensions should have no need to call this.
85 * Subclasses of MediaWikiEntryPoint in core should generally
86 * call prepareForOutput() instead.
88 public static function preOutputCommit( IContextSource $context ) {
89 $entryPoint = new static( $context );
90 $entryPoint->prepareForOutput();