Skip to content

Commit ab4ce71

Browse files
committed
forgot to commit modified files in last commit
1 parent adeead4 commit ab4ce71

File tree

10 files changed

+46
-29
lines changed

10 files changed

+46
-29
lines changed

Memento/Memento.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,41 @@ class Memento {
5555
public static function onArticleViewHeader(
5656
&$article, &$outputDone, &$pcache
5757
) {
58+
59+
echo "what did we do here?<br />";
60+
61+
echo "article->getTitle()->isKnown() = " . $article->getTitle()->isKnown() . "<br />";
62+
5863
// avoid processing Mementos for nonexistent pages
5964
// if we're an article, do memento processing, otherwise don't worry
6065
// if we're a diff page, Memento doesn't make sense
6166
if ( $article->getTitle()->isKnown() ) {
67+
68+
echo "we know the title<br />";
6269

6370
$revision = $article->getRevisionFetched();
6471

72+
echo "is_object(\$revision) = ". is_object( $revision ) . "<br />";
73+
6574
// avoid processing Mementos for bad revisions,
6675
// let MediaWiki handle that case instead
6776
if ( is_object( $revision ) ) {
6877

78+
echo "we have a revision!!!<br />";
79+
6980
$db = wfGetDB( DB_REPLICA );
7081
$oldID = $article->getOldID();
7182
$request = $article->getContext()->getRequest();
7283

84+
echo "oldID = " . $oldID . "<br />";
85+
7386
$mementoResource = MementoResource::mementoPageResourceFactory( $db, $article, $oldID );
7487

7588
$mementoResource->alterHeaders();
7689
}
7790
}
7891

92+
7993
return true;
8094
}
8195

Memento/extension.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@
5151
"MementoTimemapNumberOfMementos": {
5252
"value": 500
5353
},
54-
"MementoTimeNegotiationForThumbnails": {
55-
"value": false
56-
},
5754
"Memento": {
5855
"value": {}
5956
}

Memento/includes/MementoResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ public function generateRecommendedLinkHeaderRelations(
392392

393393
$entry = $this->constructTimeMapLinkHeaderWithBounds(
394394
$title, $first['timestamp'], $last['timestamp'] );
395+
395396
$linkRelations[] = $entry;
396397

397398
$firsturi = $titleObj->getFullURL( [ "oldid" => $first['id'] ] );
@@ -441,6 +442,7 @@ public static function mementoPageResourceFactory( IDatabase $db, $article, $old
441442
$resource = null;
442443

443444
if ( $oldID == 0 ) {
445+
444446
$resource = new OriginalResourceDirectlyAccessed( $db, $article );
445447

446448
} else {

Memento/includes/MementoResourceDirectlyAccessed.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ public function alterHeaders() {
4949
$response = $request->response();
5050
$titleObj = $this->article->getTitle();
5151

52-
$linkEntries = [];
53-
5452
// if we exclude this Namespace, don't show folks Memento relations
5553
if ( !in_array( $titleObj->getNamespace(), $wgMementoIncludeNamespaces ) ) {
5654
$entry = '<http://mementoweb.org/terms/donotnegotiate>; rel="type"';
57-
$linkEntries[] = $entry;
55+
$out->addLinkHeader($entry);
5856

5957
} else {
6058

@@ -71,11 +69,11 @@ public function alterHeaders() {
7169

7270
$entry = $this->constructLinkRelationHeader( $uri,
7371
'original latest-version' );
74-
$linkEntries[] = $entry;
72+
$out->addLinkHeader($entry);
7573

7674
$entry = $this->constructLinkRelationHeader( $tguri,
7775
'timegate' );
78-
$linkEntries[] = $entry;
76+
$out->addLinkHeader($entry);
7977

8078
$first = $this->getFirstMemento( $titleObj );
8179
$last = $this->getLastMemento( $titleObj );
@@ -87,14 +85,13 @@ public function alterHeaders() {
8785
$entries = $this->generateRecommendedLinkHeaderRelations(
8886
$titleObj, $first, $last );
8987

90-
$linkEntries = array_merge( $linkEntries, $entries );
88+
foreach ($entries as $value) {
89+
$out->addLinkHeader($value);
90+
}
9191

9292
$response->header( "Memento-Datetime: $mementoDatetime", true );
9393
}
9494

95-
$linkEntries = implode( ',', $linkEntries );
96-
97-
$response->header( "Link: $linkEntries", true );
9895
}
9996

10097
}

Memento/includes/OriginalResourceDirectlyAccessed.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ public function alterHeaders() {
5353

5454
$title = $this->getFullNamespacePageTitle( $titleObj );
5555

56-
$linkEntries = [];
57-
5856
// if we exclude this Namespace, don't show folks the Memento relations
5957
if ( !in_array( $titleObj->getNamespace(), $wgMementoIncludeNamespaces ) ) {
6058
$entry = '<http://mementoweb.org/terms/donotnegotiate>; rel="type"';
61-
$linkEntries[] = $entry;
59+
$out->addLinkHeader($entry);
6260

6361
} else {
6462

@@ -68,11 +66,11 @@ public function alterHeaders() {
6866

6967
$entry = $this->constructLinkRelationHeader( $uri,
7068
'original latest-version' );
71-
$linkEntries[] = $entry;
69+
$out->addLinkHeader($entry);
7270

7371
$entry = $this->constructLinkRelationHeader( $tguri,
7472
'timegate' );
75-
$linkEntries[] = $entry;
73+
$out->addLinkHeader($entry);
7674

7775
$first = $this->getFirstMemento( $titleObj );
7876
$last = $this->getLastMemento( $titleObj );
@@ -84,13 +82,12 @@ public function alterHeaders() {
8482
$entries = $this->generateRecommendedLinkHeaderRelations(
8583
$titleObj, $first, $last );
8684

87-
$linkEntries = array_merge( $linkEntries, $entries );
85+
foreach ($entries as $value) {
86+
$out->addLinkHeader($value);
87+
}
8888

8989
}
9090

91-
$linkEntries = implode( ',', $linkEntries );
92-
93-
$response->header( 'Link: ' . $linkEntries, true );
9491
}
9592

9693
}

Memento/includes/TimeMapResource.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,9 @@ public function renderFullTimeMap() {
576576
*
577577
*/
578578
public function renderPivotTimeMap() {
579+
580+
global $wgMementoTimemapNumberOfMementos;
581+
579582
$article = $this->article;
580583
$out = $article->getContext()->getOutput();
581584
$titleObj = $article->getTitle();
@@ -626,7 +629,7 @@ public function renderPivotTimeMap() {
626629
$title = $titleObj->getPrefixedURL();
627630

628631
# if $revCount is higher, then we've gone over the limit
629-
if ( $revCount > $wgTimemapNumberOfMementos ) {
632+
if ( $revCount > $wgMementoTimemapNumberOfMementos ) {
630633
$pivotTimestamp = $this->formatTimestampForDatabase(
631634
$earliestItem['rev_timestamp'] );
632635

@@ -641,7 +644,7 @@ public function renderPivotTimeMap() {
641644
$revCount = $revCount + 2; # for first and last
642645

643646
# if $revCount is higher, then we've gone over the limit
644-
if ( $revCount > $wgTimemapNumberOfMementos ) {
647+
if ( $revCount > $wgMementoTimemapNumberOfMementos ) {
645648
$pivotTimestamp = $this->formatTimestampForDatabase(
646649
$latestItem['rev_timestamp'] );
647650

tests/data/local-demo-wiki/expected_decreasing_timemap.link

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<http://localhost:8080/index.php/Special:TimeMap/20130522211900/-1/Kevan_Lannister>; rel="self"; type="application/link-format"; from="Fri, 18 May 2007 02:25:50 GMT"; until="Wed, 10 Apr 2013 06:23:21 GMT",
2-
<http://localhost:8080/index.php/Special:TimeMap/20070518022550/-1/Kevan_Lannister>; rel="timemap"; type="application/link-format";from=""; until="",
3-
<http://localhost:8080/index.php/Special:TimeMap/20130410062321/1/Kevan_Lannister>; rel="timemap"; type="application/link-format";from="Wed, 22 May 2013 21:19:00 GMT"; until="Mon, 20 May 2019 18:24:19 GMT",
42
<http://localhost:8080/index.php/Special:TimeGate/Kevan_Lannister>; rel="timegate",
53
<http://localhost:8080/index.php/Kevan_Lannister>; rel="original latest-version",
64
<http://localhost:8080/index.php?title=Kevan_Lannister&oldid=2>; rel="memento"; datetime="Fri, 18 May 2007 02:25:50 GMT",

tests/data/local-demo-wiki/expected_increasing_timemap.link

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<http://localhost:8080/index.php/Special:TimeMap/20130522211900/1/Kevan_Lannister>; rel="self"; type="application/link-format"; from="Thu, 23 May 2013 04:12:37 GMT"; until="Mon, 20 May 2019 18:24:19 GMT",
2-
<http://localhost:8080/index.php/Special:TimeMap/20130523041237/-1/Kevan_Lannister>; rel="timemap"; type="application/link-format";from="Fri, 18 May 2007 02:25:50 GMT"; until="Wed, 22 May 2013 21:19:00 GMT",
3-
<http://localhost:8080/index.php/Special:TimeMap/20190520182419/1/Kevan_Lannister>; rel="timemap"; type="application/link-format";from=""; until="",
42
<http://localhost:8080/index.php/Special:TimeGate/Kevan_Lannister>; rel="timegate",
53
<http://localhost:8080/index.php/Kevan_Lannister>; rel="original latest-version",
64
<http://localhost:8080/index.php?title=Kevan_Lannister&oldid=119>; rel="memento"; datetime="Thu, 23 May 2013 04:12:37 GMT",

tests/docker-image/LocalSettings.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,8 @@
132132
$wgShowDBErrorBacktrace = true;
133133
$wgShowSQLErrors = true;
134134

135+
error_reporting( -1 );
136+
ini_set( 'display_errors', 1 );
137+
135138
# load Memento MediaWiki Extension
136139
wfLoadExtension( 'Memento' );
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
#!/bin/bash
22

3+
version=$1
4+
5+
if [ -z $version ]; then
6+
echo "please specify a version as the first argument"
7+
exit 255
8+
fi
9+
310
echo "Starting docker containers for MediaWiki"
4-
docker-compose up -d
11+
docker-compose -f docker-compose-${version}.yml up -d
512

613
# for some reason, this must be run by the user
714
#echo "Loading database"
8-
#docker exec docker-image_database_1 /bin/bash -c /loaddb.sh
15+
echo "run the following now:"
16+
echo "docker exec docker-image_database_1 /bin/bash -c /loaddb.sh"
917

0 commit comments

Comments
 (0)