Title: Title::getSubpage should not lose the interwiki prefix
[lhc/web/wiklou.git] / includes / historyblob / HistoryBlobCurStub.php
1 <?php
2 /**
3 * Efficient concatenated text storage.
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 */
22
23 /**
24 * To speed up conversion from 1.4 to 1.5 schema, text rows can refer to the
25 * leftover cur table as the backend. This avoids expensively copying hundreds
26 * of megabytes of data during the conversion downtime.
27 *
28 * Serialized HistoryBlobCurStub objects will be inserted into the text table
29 * on conversion if $wgLegacySchemaConversion is set to true.
30 */
31 class HistoryBlobCurStub {
32 /** @var int */
33 public $mCurId;
34
35 /**
36 * @param int $curid The cur_id pointed to
37 */
38 function __construct( $curid = 0 ) {
39 $this->mCurId = $curid;
40 }
41
42 /**
43 * Sets the location (cur_id) of the main object to which this object
44 * points
45 *
46 * @param int $id
47 */
48 function setLocation( $id ) {
49 $this->mCurId = $id;
50 }
51
52 /**
53 * @return string|bool
54 */
55 function getText() {
56 $dbr = wfGetDB( DB_REPLICA );
57 $row = $dbr->selectRow( 'cur', [ 'cur_text' ], [ 'cur_id' => $this->mCurId ] );
58 if ( !$row ) {
59 return false;
60 }
61 return $row->cur_text;
62 }
63 }
64
65 // phpcs:ignore Generic.CodeAnalysis.UnconditionalIfStatement.Found
66 if ( false ) {
67 // Blobs generated by MediaWiki < 1.5 on PHP 4 were serialized with the
68 // class name coerced to lowercase. We can improve efficiency by adding
69 // autoload entries for the lowercase variants of these classes (T166759).
70 // The code below is never executed, but it is picked up by the AutoloadGenerator
71 // parser, which scans for class_alias() calls.
72 class_alias( HistoryBlobCurStub::class, 'historyblobcurstub' );
73 }