Skip to content

Commit 688c994

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents 54a1203 + 4efc9d5 commit 688c994

File tree

4 files changed

+71
-61
lines changed

4 files changed

+71
-61
lines changed

Memento/Memento.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* for clarity, testing, maintainability, etc.
3232
*
3333
*/
34-
if ( ! defined( 'MEDIAWIKI' ) ) {
34+
if ( !defined( 'MEDIAWIKI' ) ) {
3535
echo "Not a valid entry point";
3636
exit( 1 );
3737
}
@@ -55,13 +55,11 @@ class Memento {
5555
public static function onArticleViewHeader(
5656
&$article, &$outputDone, &$pcache
5757
) {
58-
59-
6058
// avoid processing Mementos for nonexistent pages
6159
// if we're an article, do memento processing, otherwise don't worry
6260
// if we're a diff page, Memento doesn't make sense
6361
if ( $article->getTitle()->isKnown() ) {
64-
62+
6563
$revision = $article->getRevisionFetched();
6664

6765
// avoid processing Mementos for bad revisions,
@@ -78,7 +76,6 @@ public static function onArticleViewHeader(
7876
}
7977
}
8078

81-
8279
return true;
8380
}
8481

Memento/includes/TimeMapResource.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,9 @@ public function renderFullTimeMap() {
526526
// calculate the difference
527527
// this counts the revisions BETWEEN, non-inclusive
528528
$revCount = $titleObj->countRevisionsBetween( $firstId, $lastId );
529-
$revCount = $revCount + 2; # for first and last
529+
530+
// for first and last
531+
$revCount = $revCount + 2;
530532

531533
// if it is greater than limit then get the revision ID prior
532534
// to the lowest one returned by getFullTimeMapData
@@ -576,7 +578,6 @@ public function renderFullTimeMap() {
576578
*
577579
*/
578580
public function renderPivotTimeMap() {
579-
580581
global $wgMementoTimemapNumberOfMementos;
581582

582583
$article = $this->article;
@@ -622,7 +623,9 @@ public function renderPivotTimeMap() {
622623
# this counts revisions BETWEEN, non-inclusive
623624
$revCount = $titleObj->countRevisionsBetween(
624625
$firstId, $earliestItem['rev_id'] );
625-
$revCount = $revCount + 2; # for first and last
626+
627+
// for first and last
628+
$revCount = $revCount + 2;
626629

627630
$timeMapPages = [];
628631

@@ -641,7 +644,9 @@ public function renderPivotTimeMap() {
641644
# this counts revisions BETWEEN, non-inclusive
642645
$revCount = $titleObj->countRevisionsBetween(
643646
$latestItem['rev_id'], $lastId );
644-
$revCount = $revCount + 2; # for first and last
647+
648+
// for first and last
649+
$revCount = $revCount + 2;
645650

646651
# if $revCount is higher, then we've gone over the limit
647652
if ( $revCount > $wgMementoTimemapNumberOfMementos ) {

README.md

Lines changed: 58 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,15 @@ This package contains the source code, build scripts, and tests for the Memento
66

77
This file also contains installation information, but more comprehensive information about the extension is at: https://www.mediawiki.org/wiki/Extension:Memento
88

9-
Note: the released version of this extension does not contain this file, so the target audience for this file is those who wish to build/maintain the source code.
10-
11-
# Directory Contents
12-
13-
* Makefile - the build script that does all of the magic
14-
* README.md - this file
15-
* TODO - list of items to address in the codebase
16-
* Memento/ - the source code for this extension
17-
* externals/ - git submodule linking to the code verification rules at https://gerrit.wikimedia.org/r/p/mediawiki/tools/codesniffer.git
18-
* scripts/ - command line scripts used for testing the extension by hand
19-
* tests/integration/ - the integration tests
20-
* tests/lib/ - libraries needed by the tests
21-
* tests/data/ - data used by the tests
22-
9+
Note: the released version of this extension does not contain this ``README.md`` file, so the target audience for this file is those who wish to build/maintain the source code.
2310

2411
# Installation
2512

2613
To install this package within MediaWiki perform the following:
27-
* copy the Memento directory into the extensions directory of your MediaWiki installation
14+
* copy the ``Memento`` directory into the extensions directory of your MediaWiki installation
2815
* add the following to the LocalSettings.php file in your MediaWiki installation:
2916
```
30-
require_once "$IP/extensions/Memento/Memento.php";
17+
wfLoadExtension( 'Memento' );
3118
```
3219

3320
# Configuration
@@ -38,10 +25,6 @@ This extension has sensible defaults, but also allows the following settings to
3825

3926
* `$wgMementoIncludeNamespaces` - is an array of MediaWiki Namespace IDs (e.g. the integer values for Talk, Template, etc.) to include for Mementofication, default is an array containing just 0 (Main); the list of MediaWiki Namespace IDs is at https://www.mediawiki.org/wiki/Manual:Namespace
4027

41-
* `$wgMementoTimeNegotiationForThumbnails` - EXPERIMENTAL: MediaWiki, by default, does not preserve temporal coherence for its oldid pages. In other words, and oldid (URI-M) page will not contain the version of the image that existed when that page was created. See http://arxiv.org/pdf/1402.0928.pdf for more information on this problem in web archives.
42-
* false - (default) do not attempt to match the old version of the image to the requested oldid page
43-
* true - attempt to match the old version of the image to the requested oldid page
44-
4528
# Packaging
4629

4730
To package the Memento MediaWiki Extension, type the following
@@ -51,66 +34,90 @@ from this directory:
5134

5235
This serves to run everything needed to verify the code and package the zip for release.
5336

54-
# Automated Deployment for Testing
37+
# Automated Deployment and Testing
5538

56-
To deploy the Memento MediaWiki Extension locally for testing, one must first indicate to the shell where MediaWiki is installed, then run the appropriate make target.
39+
## Using Docker
40+
41+
Easier testing with supported MediaWiki versions is now available via Docker. First change into the directory containing the docker-compose files:
5742

5843
```
59-
export MWDIR=<where your MediaWiki is installed>
60-
make deploy
44+
cd tests/docker-image
6145
```
6246

63-
To remove the software from a MediaWiki instance, type:
47+
48+
Then decide which version of MediaWiki to test against. We currently test against:
49+
* 1.31.1
50+
* 1.32.1
51+
52+
Run the following to start the container for 1.31.1:
6453

6554
```
66-
make undeploy
55+
./starttestdocker.sh 1.31.1
6756
```
6857

69-
# Integration Testing
58+
**Do not forget this step!** Run the following to load the database:
7059

71-
Once the code is deployed, the integration tests can be run.
60+
```
61+
docker exec docker-image_database_1 /bin/bash -c /loaddb.sh
62+
```
7263

73-
Running the integration tests requires phpunit and the curl command.
64+
This extra manual step is necessary because the script does not yet know when the database has fully started.
7465

75-
You will need to change the test data inside tests/integration/data to reflect your MediaWiki installation URIs and appropriate expected data. Seeing as Mementos vary from site to site, it was decided not to come up with a "one size fits all" integration test set.
66+
Change back to the directory at the top of the repository:
7667

77-
Example test data exists for our demo site in the 'demo-wiki' directory. To use that test set, the XML dump within tests/data/demo-wiki-data can be imported into a test MediaWiki installation using mwdumper, as described at https://www.mediawiki.org/wiki/Manual:MWDumper. DO NOT USE Special:Import or if you are going to use this dataset as it is, because mwdumper preserves the oldid values, which are the bulk of the value found in this data set.
68+
```
69+
cd ../../
70+
```
7871

79-
**For more information on the integration tests and the test data format, consult the tests/integration/integration-test-description.html and tests/integration/how-to-read-output.txt files. Detailed test output is generated in the build/test-output directory once the integration tests are run.**
72+
Run the tests as stated in the **Integration Testing** section.
73+
74+
75+
## The hard way
8076

81-
Before running the tests you will need to set the following environment variables:
82-
* TESTDATADIR - the data directory containing the datasets for your test run
83-
* TESTUSERNAME - the username for logging into your MediaWiki instance, set to NOAUTH if no authentication needed
84-
* TESTPASSWORD - the password that goes with TESTUSERNAME, set to NOAUTH if no authentication needed
77+
To deploy the Memento MediaWiki Extension locally for testing, one must first indicate to the shell where MediaWiki is installed, then run the appropriate make target.
8578

86-
Test output is saved to build/test-output.
79+
```
80+
export MWDIR=<where your MediaWiki is installed>
81+
make deploy
82+
```
8783

88-
Because of all of the possible combinations of configuration options, the following Make targets are intended to test the following capabilities:
84+
To remove the software from a MediaWiki instance, type:
8985

90-
* defaults-integration-test - test an installation with the default settings
86+
```
87+
make undeploy
88+
```
9189

92-
* 302-style-time-negotiation-integration-test - test only the 302-style Time Negotiation capability of the install
90+
# Setting Up Testing and Code Compliance
9391

94-
* friendly-error-with-302-style-integration-test - test the 302-style Time Negotiation error states with friendly output
92+
If you have [composer](https://getcomposer.org/) installed, you can install this version of PHPUnit and PHP Code Sniffer by running:
9593

96-
Of course, the fastest development process is:
94+
```
95+
php /path/to/composer install
9796
98-
1. edit tests or change code, if necessary
99-
2. make undeploy && make clean package deploy
100-
3. run the integration test battery matching your deployment
97+
export PATH=$PATH:`pwd`/vendor/bin
98+
```
10199

102-
# Code compliance verification
100+
If do not have [composer](https://getcomposer.org/), you will need to ensure that [PHP Unit](https://phpunit.de/) (``phpunit``) and [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer) (``phpcs``) are in your ``PATH``.
101+
102+
# Integration Testing
103+
104+
Once the code is deployed, the integration tests can be run.
103105

104-
Running the code compliance requires phpcs.
106+
Running the integration tests requires phpunit 6.5.14 and the curl command.
105107

106-
This git repository uses an external repository for coding convention rules, so we can update the coding convention rules at any time. The git command for performing the initial import is:
108+
**For more information on the integration tests and the test data format, consult the tests/integration/integration-test-description.html and tests/integration/how-to-read-output.txt files. Detailed test output is generated in the build/test-output directory once the integration tests are run.**
109+
110+
To run integration tests, execute the following script from the root of the repository:
107111

108112
```
109-
git submodule update --init
113+
./run_default_tests.sh
110114
```
111115

112-
To see if the code complies with MediaWiki's coding conventions, run:
116+
# Code compliance verification
117+
118+
Running the code compliance requires phpcs. If you installed the development dependencies using ``composer`` then type the following to see if the code complies with MediaWiki's coding conventions:
113119

114120
```
115-
make verify
121+
phpcs --standard=vendor/mediawiki/mediawiki-codesniffer/MediaWiki Memento
116122
```
123+

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"jakub-onderka/php-console-highlighter": "0.3.2",
55
"mediawiki/mediawiki-codesniffer": "24.0.0",
66
"mediawiki/minus-x": "0.3.1",
7-
"phpunit/phpunit": "6.5.14"
7+
"phpunit/phpunit": "6.5.14",
8+
"squizlabs/php_codesniffer": "3.4.0"
89
},
910
"scripts": {
1011
"fix": [

0 commit comments

Comments
 (0)