mirror of
https://github.com/diocloid/LinkTitles.git
synced 2025-07-13 09:49:31 +02:00
Merge branch 'develop'
This commit is contained in:
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@ -0,0 +1,2 @@
|
||||
.git
|
||||
|
21
Dockerfile
Normal file
21
Dockerfile
Normal file
@ -0,0 +1,21 @@
|
||||
# This Dockerfile can be used to create a Docker image/container
|
||||
# that runs the unit tests on the LinkTitles extension.
|
||||
FROM mediawiki:1.34
|
||||
MAINTAINER Daniel Kraus (https://www.bovender.de)
|
||||
RUN apt update -yqq && \
|
||||
apt install -yqq \
|
||||
php7.0-sqlite \
|
||||
sqlite3 \
|
||||
unzip \
|
||||
zip
|
||||
RUN curl https://raw.githubusercontent.com/composer/getcomposer.org/cb19f2aa3aeaa2006c0cd69a7ef011eb31463067/web/installer -s | php -- --quiet
|
||||
RUN php composer.phar install
|
||||
|
||||
COPY . /var/www/html/extensions/LinkTitles/
|
||||
RUN mkdir /data && chown www-data /data
|
||||
|
||||
WORKDIR /var/www/html/maintenance
|
||||
RUN php install.php --pass admin --dbtype sqlite --extensions LinkTitles Tests admin
|
||||
|
||||
WORKDIR /var/www/html/tests/phpunit
|
||||
CMD ["php", "phpunit.php", "--group", "bovender"]
|
11
Makefile
Normal file
11
Makefile
Normal file
@ -0,0 +1,11 @@
|
||||
.PHONY: test
|
||||
|
||||
test:
|
||||
# With MW version 1.34, there is one test that is expected to fail
|
||||
# because linking on page save no longer works with MediaWiki 1.32
|
||||
# and newer. The test that is expected to fail is:
|
||||
# ExtensionTest::testParseOnEdit with data set #0
|
||||
docker run -it --rm bovender/linktitles
|
||||
|
||||
build-test-container:
|
||||
docker build -t bovender/linktitles .
|
24
NEWS.md
Normal file
24
NEWS.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
For changes prior to version 6.0.0, please see [`NEWS.old`](news.old).
|
||||
|
||||
## [6.0.0][] - 2019-12-31
|
||||
|
||||
### Changed
|
||||
|
||||
- Because automatic linking upon page save no longer works with MediaWiki
|
||||
versions 1.32 and newer, the default value of the `$wgLinkTitlesParseOnRender`
|
||||
is now `true`. Please see `README.md` for more information.
|
||||
|
||||
### Fixed
|
||||
|
||||
- Prevent crash that occurred with MediaWiki version 1.34 due to a renamed
|
||||
constant (DB_SLAVE was renamed to DB_REPLICA). NOTE that the minimum
|
||||
required version of MediaWiki is now 1.28 (which is an obsolete version).
|
||||
|
||||
[6.0.0]: https://github.com/bovender/LinkTitles/releases/tag/v6.0.0
|
74
README.md
74
README.md
@ -4,7 +4,7 @@ LinkTitles
|
||||
[MediaWiki extension](https://www.mediawiki.org/wiki/Extension:LinkTitles) that
|
||||
automatically adds links to words that match titles of existing pages.
|
||||
|
||||
Minimum requirements: MediaWiki 1.25, PHP 5.3. Source code documentation can be
|
||||
Minimum requirement: MediaWiki 1.28. Source code documentation can be
|
||||
found at the [Github project pages](https://bovender.github.io/LinkTitles).
|
||||
|
||||
|
||||
@ -14,7 +14,8 @@ Table of contents
|
||||
1. [Oveview](#overview)
|
||||
- [Versions](#versions)
|
||||
2. [Installation](#installation)
|
||||
3. [Usage](#usage)
|
||||
3. [Important note for MediaWiki versions 1.32 and newer](#important-note-for-mediawiki-versions-1.32-and-newer)
|
||||
4. [Usage](#usage)
|
||||
- [Editing a page](#editing-a-page)
|
||||
- [Preventing automatic linking after minor edits](#preventing-automatic-linking-after-minor-edits)
|
||||
- [Viewing a page](#viewing-a-page)
|
||||
@ -24,7 +25,7 @@ Table of contents
|
||||
- [Batch processing](#batch-processing)
|
||||
- [Special:LinkTitles](#special-linktitles)
|
||||
- [Maintenance script](#maintenance-script)
|
||||
4. [Configuration](#configuration)
|
||||
5. [Configuration](#configuration)
|
||||
- [Linking when a page is edited and saved](#linking-when-a-page-is-edited-and-saved)
|
||||
- [Linking when a page is rendered for display](#linking-when-a-page-is-rendered-for-display)
|
||||
- [Enabling case-insensitive linking (smart mode)](#enabling-case-insensitive-linking-(smart-mode))
|
||||
@ -37,10 +38,10 @@ Table of contents
|
||||
- [Multiple links to the same page](#multiple-links-to-the-same-page)
|
||||
- [Partial words](#partial-words)
|
||||
- [Special page configuration](#special-page-configuration)
|
||||
5. [Development](#development)
|
||||
6. [Development](#development)
|
||||
- [Contributors](#contributors)
|
||||
- [Testing](#testing)
|
||||
6. [License](#license)
|
||||
7. [License](#license)
|
||||
|
||||
|
||||
Overview
|
||||
@ -75,19 +76,20 @@ are fixed.
|
||||
|
||||
Version | Date | Major changes ||
|
||||
-|-|-|-
|
||||
6 | 12-2019 | Renamed deprecated MW constant for compatibility with MW version 1.34, minimum required version is 1.28. | [Details][v6.0.0]
|
||||
5 | 09-2017 | Rewrote the entire extension; vastly improved namespace support; some breaking changes | [Details][v5.0.0]
|
||||
4 | 11-2016 | Changed format of the extension for MediaWiki version 1.25; added basic namespace support | [Details][v4.0.0]
|
||||
3 | 02-2015 | Added magic words; improved performance | [Details][3.0.0]
|
||||
2 | 11-2013 | Introduced smart mode | [Details][2.0.0]
|
||||
1 | 05-2012 | First stable release |
|
||||
|
||||
|
||||
[v6.0.0]: https://github.com/bovender/LinkTitles/releases/tag/v6.0.0
|
||||
[v5.0.0]: https://github.com/bovender/LinkTitles/releases/tag/v5.0.0
|
||||
[v4.0.0]: https://github.com/bovender/LinkTitles/releases/tag/v4.0.0
|
||||
[3.0.0]: https://github.com/bovender/LinkTitles/compare/2.4.1...3.0.0
|
||||
[2.0.0]: https://github.com/bovender/LinkTitles/compare/1.8.1...2.0.0
|
||||
|
||||
For more details, click the 'Details' links, see the `NEWS` file in the
|
||||
For more details, click the 'Details' links, see the `NEWS.md` file in the
|
||||
repository for a user-friendly changelog, or study the commit messages.
|
||||
|
||||
|
||||
@ -113,17 +115,43 @@ Do not forget to adjust the [configuration](#configuration) to your needs.
|
||||
If your MediaWiki version is really old (1.24 and older), you need to use
|
||||
a [different mechanism](https://www.mediawiki.org/wiki/Manual:Extensions#Installing_an_extension).
|
||||
|
||||
|
||||
Important note for MediaWiki versions 1.32 and newer
|
||||
----------------------------------------------------
|
||||
|
||||
**Links can no longer be automatically added when a page is saved with
|
||||
MediaWiki versions 1.32 and newer.** This is because MediaWiki changed the
|
||||
signature of an important callback function. See [GitHub issue #43][issue-43]
|
||||
and [T222413][] for more information. There's a slight chance that link-on-edit
|
||||
will work again in a future version of MediaWiki (that is, if/when pull request
|
||||
[467308][] is merged). Until that happens, admins are advised to use the
|
||||
link-on-render feature (which is now enabled by default).
|
||||
|
||||
A workaround is to set up a cron job for the command-line tool, e.g.
|
||||
|
||||
# /etc/crontab
|
||||
# Runs at 1 a.m. every morning.
|
||||
# m h dom mon dow user command
|
||||
0 1 * * * www-data php -f /var/www/html/extensions/LinkTitles/linktitles-cli.php
|
||||
|
||||
[issue-43]: https://github.com/bovender/LinkTitles/issues/43
|
||||
[T222413]: https://phabricator.wikimedia.org/T222413
|
||||
[467308]: https://gerrit.wikimedia.org/r/467308
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
### Editing a page
|
||||
|
||||
By default, the LinkTitles extension will add links to existing pages whenever
|
||||
you edit and save a page. Unless you changed the configuration variables, it will
|
||||
link whole words only, prefer longer target page titles over shorter ones, skip
|
||||
headings, and add multiple links if a page title appears more than once on the
|
||||
page. All of this is configurable; see the [Configuration](#configuration)
|
||||
section.
|
||||
*By default, the LinkTitles extension will **no longer** add links to existing
|
||||
pages whenever you edit and save a page. This is because MediaWiki 1.32 changed
|
||||
an important callback function that the LinkTitles extension relied on (see above).*
|
||||
|
||||
When linking-on-edit is enabled (with MW versions prior to 1.33), the extension
|
||||
will by default link whole words only, prefer longer target page titles over
|
||||
shorter ones, skip headings, and add multiple links if a page title appears
|
||||
more than once on the page. All of this is configurable; see the
|
||||
[Configuration](#configuration) section.
|
||||
|
||||
### Preventing automatic linking after minor edits
|
||||
|
||||
@ -436,9 +464,9 @@ Development
|
||||
-----------
|
||||
|
||||
If you wish to contribute, please issue pull requests against the `develop`
|
||||
branch, as I follow Vincent Driessen's advice on [A successful Git branching
|
||||
model](http://nvie.com/git-model) (knowing that there are [alternative
|
||||
workflows](http://scottchacon.com/2011/08/31/github-flow.html)).
|
||||
branch, as I roughly follow Vincent Driessen's advice on [A successful Git
|
||||
branching model](http://nvie.com/git-model) (knowing that there are
|
||||
[alternative workflows](http://scottchacon.com/2011/08/31/github-flow.html)).
|
||||
|
||||
The `master` branch contains stable releases only, so it is safe to pull the
|
||||
master branch if you want to install the extension for your own Wiki.
|
||||
@ -475,7 +503,7 @@ use Ubuntu).
|
||||
git clone --depth 1 https://phabricator.wikimedia.org/source/mediawiki.git
|
||||
|
||||
2. Install [composer](https://getcomposer.org) locally and fetch the
|
||||
dependencies (including development dependencies):
|
||||
dependencies (including development dependencies):
|
||||
|
||||
Follow the instructions on the [composer download page](https://getcomposer.org/download),
|
||||
but instead of running `php composer-setup.php`, run:
|
||||
@ -484,12 +512,12 @@ dependencies (including development dependencies):
|
||||
bin/composer install
|
||||
|
||||
3. Install phpunit (it was already installed on my Ubuntu system when I began
|
||||
testing LinkTitles, so I leave it up to you to figure out how to do it).
|
||||
testing LinkTitles, so I leave it up to you to figure out how to do it).
|
||||
|
||||
4. Copy your `LocalSettings.php` over from your local MediaWiki installation
|
||||
and remove (or comment out) any lines that reference extensions or skins that
|
||||
you are not going to install to your test environment. For the purposes of
|
||||
testing the LinkTitles extension, leave the following line in place:
|
||||
and remove (or comment out) any lines that reference extensions or skins that
|
||||
you are not going to install to your test environment. For the purposes of
|
||||
testing the LinkTitles extension, leave the following line in place:
|
||||
|
||||
wfLoadExtensions( 'LinkTitles' );
|
||||
|
||||
@ -503,7 +531,7 @@ testing the LinkTitles extension, leave the following line in place:
|
||||
ln -s ~/Code/LinkTitles
|
||||
|
||||
6. Make sure your local MediaWiki instance is up to date. Otherwise phpunit may
|
||||
fail and tell you about database problems.
|
||||
fail and tell you about database problems.
|
||||
|
||||
This is because the local database is used as a template for the unit tests.
|
||||
For example, I initially had MW 1.26 installed on my laptop, but the cloned
|
||||
@ -523,7 +551,7 @@ fail and tell you about database problems.
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright 2012-2018 Daniel Kraus <mailto:bovender@bovender.de> (@bovender)
|
||||
Copyright 2012-2020 Daniel Kraus <mailto:bovender@bovender.de> (GitHub: @bovender)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -6,19 +6,20 @@
|
||||
"Brent Laabs (labster)",
|
||||
"tetsuya-zama",
|
||||
"yoshida",
|
||||
"Caleb Mingle (dentafrice)"
|
||||
"Caleb Mingle (dentafrice)",
|
||||
"paladox"
|
||||
],
|
||||
"type": "parserhook",
|
||||
"url": "https://www.mediawiki.org/wiki/Extension:LinkTitles",
|
||||
"version": "5.0.7",
|
||||
"version": "6.0.0",
|
||||
"license-name": "GPL-2.0+",
|
||||
"descriptionmsg": "linktitles-desc",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.25.0"
|
||||
"MediaWiki": ">= 1.28.0"
|
||||
},
|
||||
"config": {
|
||||
"LinkTitlesParseOnEdit": true,
|
||||
"LinkTitlesParseOnRender": false,
|
||||
"LinkTitlesParseOnRender": true,
|
||||
"LinkTitlesParseHeadings": false,
|
||||
"LinkTitlesSkipTemplates": true,
|
||||
"LinkTitlesPreferShortTitles": true,
|
||||
|
@ -103,7 +103,7 @@ class Special extends \SpecialPage {
|
||||
$startTime = microtime( true );
|
||||
|
||||
// Connect to the database
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
|
||||
// Fetch the start index and max number of records from the POST
|
||||
// request.
|
||||
|
@ -134,7 +134,7 @@ class Targets {
|
||||
// shortest to longest. Only titles from 'normal' pages (namespace uid
|
||||
// = 0) are returned. Since the db may be sqlite, we need a try..catch
|
||||
// structure because sqlite does not support the CHAR_LENGTH function.
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$this->queryResult = $dbr->select(
|
||||
'page',
|
||||
array( 'page_title', 'page_namespace' , "weight" => $weightSelect),
|
||||
|
@ -154,7 +154,7 @@ class Cli extends \Maintenance {
|
||||
$config = new Config();
|
||||
|
||||
// Retrieve page names from the database.
|
||||
$dbr = $this->getDB( DB_SLAVE );
|
||||
$dbr = $this->getDB( DB_REPLICA );
|
||||
$namespacesClause = str_replace( '_', ' ','(' . implode( ', ', $config->sourceNamespaces ) . ')' );
|
||||
$res = $dbr->select(
|
||||
'page',
|
||||
|
@ -40,7 +40,7 @@ class TargetsTest extends LinkTitles\TestCase {
|
||||
|
||||
// Count number of articles: Inspired by updateArticleCount.php maintenance
|
||||
// script: https://doc.wikimedia.org/mediawiki-core/master/php/updateArticleCount_8php_source.html
|
||||
$dbr = wfGetDB( DB_SLAVE );
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$counter = new SiteStatsInit( $dbr );
|
||||
$count = $counter->pages();
|
||||
|
||||
|
Reference in New Issue
Block a user