jenkins-bot has submitted this change and it was merged.
Change subject: extract2.php: Clean up old code.
......................................................................
extract2.php: Clean up old code.
- The _portals are no longer used. Some of them still exist
on meta.wikimedia.org but only with content like
"This is no longer used" or "{{Historical}}" etc.
extract2.php was still parsing these on every request and doing
a pointless string search/replace.
- The text/plain header is broken, PHP outputs text/html instead
because it somehow called header() with the value as second
argument, which is an incorrect invokation.
- Secure.wikimedia.org should no longer be exposed.
- Whitespace, single quotes, commented out code.
Bug: 38167
Change-Id: Ib77f5312e7667ce2ebc074172a12ad3c5efb3a13
---
M extract2.php
1 file changed, 21 insertions(+), 47 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extract2.php b/extract2.php
index 6ad6e12..5d18dfa 100644
--- a/extract2.php
+++ b/extract2.php
@@ -1,61 +1,35 @@
<?php
-header("Content-Type: text/html; charset=utf-8");
-$lang = "meta";
+$lang = 'meta';
putenv( "MW_LANG={$lang}" ); // notify MWMultiVersion
-define( "MEDIAWIKI", true );
-#include_once("CommonSettings.php");
-#include_once("/apache/common/wmf-deployment/includes/ProfileStub.php" );
-#include_once("/apache/common/wmf-deployment/includes/Defines.php" );
-#include_once("/apache/common/wmf-deployment/wmf-config/CommonSettings.php");
-#include_once("/apache/common/wmf-deployment/includes/Setup.php");
+define( 'MEDIAWIKI', true );
-#include_once("/apache/common/wmf-deployment/includes/WebStart.php");
+include '/apache/common/live-1.5/MWVersion.php';
+include getMediaWiki( 'includes/WebStart.php' );
-include "/apache/common/live-1.5/MWVersion.php";
-include getMediaWiki("includes/WebStart.php");
-
-$allowed_portals = array(
- "Www.wikipedia.org_portal",
- "Www.wikinews.org_portal",
- "Www.wiktionary.org_portal",
- "Www.wikiquote.org_portal",
- "Www.wikimedia.org_portal",
- "Www.wikiversity.org_portal",
- "Www.wikibooks.org_portal",
- "Secure.wikimedia.org_portal",
- "Www.wikivoyage.org_portal",
-);
$allowed_templates = array(
- "Www.wikipedia.org_template",
- "Www.wikinews.org_template",
- "Www.wiktionary.org_template",
- "Www.wikiquote.org_template",
- "Www.wikimedia.org_template",
- "Www.wikiversity.org_template",
- "Www.wikibooks.org_template",
- "Secure.wikimedia.org_template",
- "Www.wikivoyage.org_template",
+ 'Www.wikimedia.org_template',
+ 'Www.wikipedia.org_template',
+ 'Www.wikinews.org_template',
+ 'Www.wiktionary.org_template',
+ 'Www.wikiquote.org_template',
+ 'Www.wikiversity.org_template',
+ 'Www.wikibooks.org_template',
+ 'Www.wikivoyage.org_template',
);
-$useportal = $wgRequest->getText( 'title', 'Www.wikipedia.org_portal' );
-$usetemplate = $wgRequest->getText( 'template', 'Www.wikipedia.org_template' );
-if (!in_array($useportal, $allowed_portals) || !in_array($usetemplate,
$allowed_templates)) {
- header("Content-Type", "text/plain; charset=US-ASCII");
- echo "sorry...";
+$template = $wgRequest->getText( 'template', 'Www.wikipedia.org_template' );
+if ( !in_array( $template, $allowed_templates ) ) {
+ header( 'Content-Type: text/plain; charset=utf-8' );
+ echo 'Invalid parameters...';
exit;
}
-$wgTitle = Title::newFromText( $useportal );
+$wgTitle = Title::newFromText( $template );
$wgArticle = new Article( $wgTitle );
-$mainText = $wgOut->parse( $wgArticle->getContent( false ) );
+$rawHtml = $wgArticle->getContent( false );
-$templateTitle = Title::newFromText( $usetemplate );
-$templateArticle = new Article( $templateTitle );
-$templateText = $templateArticle->getContent( false );
-$text = str_replace( '$1', $mainText, $templateText );
-
-$lastmod = gmdate( 'D, j M Y H:i:s', wfTimestamp(TS_UNIX, max(
$wgArticle->getTouched(), $templateArticle->getTouched() ) ) ) . ' GMT';
+$lastmod = gmdate( 'D, j M Y H:i:s', wfTimestamp( TS_UNIX,
$wgArticle->getTouched() ) ) . ' GMT';
+header( 'Content-Type: text/html; charset=utf-8' );
header( 'Cache-Control: s-maxage=3600, must-revalidate, max-age=0' );
header( "Last-modified: $lastmod" );
-echo $text;
-
+echo $rawHtml;
--
To view, visit https://gerrit.wikimedia.org/r/54645
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib77f5312e7667ce2ebc074172a12ad3c5efb3a13
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Krinkle <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits