Apply prefix and suffix to invalid titles just like it's applied
to conflicting titles. (Typically this will be needed when the
Foo namespace is created and there is a Foo: article already.)
Also remove a broken for loop. Presumably the intent was to
repeatedly add prefix/suffix on conflict, but actually it would
just get into an infinite loop. The behavior doesn't seem that
useful anyway.
Bug: T293407
Change-Id: Ieef6698b461e7db003dc326e5cd82accd2909540
Deconstructing non-sparse, numerically indexed arrays directly in
foreach (a.k.a. using the list() syntax in foreach) is possible since
PHP 5.5.
The possibility to use string array keys as well as non-sequential
numeric keys in array deconstruction was added in PHP 7.1.
Change-Id: I56a48552a45f61cedc291b306cad8548fc70d485
These are not configuration but business logic, similar to the
canonical names that are in NamespaceInfo.php, these must always
exist and cannot be altered or unset.
They were previously unconditionally assigned during all requests
in Setup.php and passed down as "site configuration".
Changes:
* Move them to MessagesEn.php where they can be cached and
processed the same way as other core-provided aliases.
Document and confirm with tests that this is a mergeable
attribute that follows the language chain.
* Remove the duplicated code in a few places that was reading
this variable + Language::getNamespaceAliases(), to instead
just call the latter and move the logic there, centralised,
and tested.
In doing so I noticed that these were applied in an
inconsistent order. Sometimes the config won, sometimes not.
There's no obvious right or wrong way here, but I've chosen
to standardise on the way that Language::getNamespaceIds() did
it, which is that config wins. This because that method seems
to be most widely used of the three (it decides how URLs and
titles are parsed), and thus the one I least want to change
the behaviour of.
* Document that $wgNamespaceAliases may only be used to
define (extra) aliases, it is and never was a way to access
the complete list of aliases.
Bug: T189966
Change-Id: Ibb14181aba8c1b509264ed40523e9ab4000fd71a
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.
It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.
* Replace a common pattern like `return $a < $b ? -1 : 1` with the
new operator (and similar patterns with the variables, the numbers
or the comparison inverted). Some of the uses were previously not
correctly handling the variables being equal; this is now
automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
$a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
when both variables are strings, but if any of the variables is not,
'strcmp()' converts it to a string before comparison, which could
give different results than '<=>', so changing this would require
careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
of the time (returns `1` if `$b` is lesser, and `0` if they are
equal or `$a` is lesser) but is erroneous.
Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
Each of these scripts had a class name that was not referenced outside
of the script file itself, and are safe to rename as a result.
Change-Id: Id605aca11db51ee433baeaa998a0e33184c930ca
This DataUpdate (or any for that matter) is not meant to be run in
the same transaction as random other stuff.
Bug: T143631
Change-Id: Ic40865805c26acc88e613a592b922ffb121962d2
This allows empty lines inside the comment as found by the
MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment sniff
Change-Id: Iac155bbda4a84562db2b452baeae9b8973899453
* Fix link destinations where a link was previously made to the
pseudo-namespace. Don't do this for --source-pseudo-namespace since it
only makes sense when the PDBK is essentially unchanged.
* Update pl_from_namespace, il_from_namespace and tl_from_namespace when
moving a page.
* Run LinksDeletionUpdate::doUpdate() when deleting a page, so that
referential integrity is preserved.
Change-Id: I584ead93d6267d1a2928ecbcdf8a4cd8e5aeef94
General review and improvement in service of T87645.
* Add the option to add a prefix to a page on conflict, instead of a suffix.
This makes it easier to find the pages after they are renamed, since
[[Special:Prefixindex]] can be used.
* Rename options --prefix to --source-pseudo-ns, --suffix to --add-suffix,
--key to --dest-ns.
* Document --source-pseudo-ns and verify that it does what I think it was
meant to do, per T14371, thus allowing me to remove the "todo" note.
* Add the option to do a history merge instead of a rename to resolve
conflicts.
* Pass around an options array instead of an ever-growing list of formal
parameters.
* Rename resolveConflictOn() to movePage() and remove the $table and
$prefix parameters which were unused since MW 1.5. Also get rid of
the usage AS in getConflicts(), most instances of which were for MW 1.4
compatibility.
* Rename getConflicts() to getTargetList() since "conflict" is a
misnomer. A conflict occurs between two entities, really what the code
was calling an "unresolvable conflict" is actually a conflict, whereas a
"resolvable conflict" is merely a page in the wrong namespace.
* Add option --move-talk since checking the talk namespace doesn't make sense
in the case of corruption, it only makes sense when introducing a new
namespace, when a pseudo-namespace has previously been used.
* Use terse, greppable output, with a single line per page.
* Replace ksort() followed by asort() with a single uksort(), since I think
that is what was intended. PHP's sort functions are not stable, so you
can't run two different sort functions on the same array and expect to the
first sort to have a predictable effect on the result.
* If --fix is not given, give the same output, just don't take the action.
* Refactor checkNamespace(). Move target title determination to its own
function, was a mixture of SQL and a couple of lines in reportConflict().
Move alternate title determination to its own function, was mostly in
resolveConflict(). Get rid of reportConflict() and resolveConflict(), do
what's left of them in the main loop. Get rid of modification of page row.
* Improve destination namespace calculation logic of --move-talk feature,
per comments by PleaseStand.
Change-Id: I49921315315e1a29c9559ba221e9903b10b73d68
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.
Change-Id: I727deec35a712de0f0c676cc87dfa661f1ee965b
Shouldn't be needed and aren't for any core operations. If any
extension relies on these $wgTitles being set in maintenance
environments those extensions are broken and should be fixed.
Change-Id: Ie02a5042ab96e155d783d56d5340dd0da8e3d55c
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.
Also updated usage in text in documentation and the
installer LocalSettingsGenerator.
Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;
Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa