In some functions MediaWikiServices::getInstance() was called twices or
in loops. Extract the variable to reduce calls.
Change-Id: I2705db11d7a9ea73efb9b5a5c40747ab0b3ea36f
When aliasing a field to null, it has to be aliased to the string 'NULL'
rather than PHP null.
Bug: T198687
Change-Id: I6096f306b97022da781eaabeb15e502f391673a9
Hash the file name portion and make the string constant portions
more relevant to what the keys are actually used for (e.g. there
is no URL parameter in the key)
Bug: T198279
Change-Id: Idf6f97db26f5be291cdd3a50a91346677fe9c3e6
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '
(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)
Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).
Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
When uploading multiple file revisions with fitting text revisions to
core the UploadRevisionImporter will create a unwanted NullRevision on
the file page.
This NullRevision originates from LocalFile:upload() and is added there
in recordUpload2 as part of the normal upload process. There it is meant
to leave a hint on the text revision history.
This whole area is in need of heavy refactoring. But since the issue is
blocking the current implementation of the FileImporter extension, a
parameter is added to control the creation of that NullRevision.
Bug: T193621
Change-Id: I57c947eb63a7627ab1eec850cdf5e076f5f62df5
Storing the user name or IP in every row in large tables like revision
and logging takes up space and makes operations on these tables slower.
This patch begins the process of moving those into one "actor" table
which other tables can reference with a single integer field.
A subsequent patch will remove the old columns.
Bug: T167246
Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50
Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
This reduces the odds of having files without corresponding
wiki pages, given that the later is done in a deferred update.
Also made some documentation cleanups.
Bug: T187942
Change-Id: Iff516669f535713d37e0011e2d7ed285c667f1c5
This was incorrectly changed in I3abb62a5, createComment() is not one of
the methods that was adjusted in that patch.
Change-Id: I9c26e0ad69ffc6fa5349a6975a4134efb3cf0eff
Remote audio files have no thumbnails, so this check in
ForeignAPIFile for thumbnails by iterating over the result
from FileBackend::getFileList() could throw a warning about
invalid input to foreach, as it may return null.
Change-Id: I07f37ed5a299e1a3c9a1e6bddcbc5582f99e5274
This allows CommentStore to be added to MediaWikiServices
without the need of an aditional Factory.
This change includes a compatability layer to allow the behaviour
from 1.30 to continue to be used while deprecated.
CommentStore::newKey has been deprecated.
Keys are now passed into the public methods of CommentStore
where needed.
The following CommentStore methods have had their signatures changed
to introduced a $key parameter, but when used in conjunction with
CommentStore::newKey behaviour will remain unchanged:
* CommentStore::getFields
* CommentStore::getJoin
* CommentStore::getComment
* CommentStore::getCommentLegacy
* CommentStore::insert
* CommentStore::insertWithTemplate
Change-Id: I3abb62a5cfb0dcd456da9f4eb35583476ae41cfb
See https://tools.ietf.org/html/bcp47#section-2.1.1
Also implement matching of systemLanguage attribs as
specified in the SVG spec
Note that librsvg that we use for rendering pngs of svg
files has a bug, and matches languages in the following
way instead of what is implemented in SVG::getMatchedLanguage()
public function getMatchedLanguage( $userPreferredLanguage, array $svgLanguages ) {
foreach ( $svgLanguages as $svgLang ) {
if ($svgLang == $userPreferredLanguage) {
return $svgLang;
}
$dashPosition = strpos( $userPreferredLanguage, '-' );
if ( $dashPosition !== false ) {
if (
strtolower( substr( $svgLang, 0, $dashPosition ) ) ==
strtolower( substr( $userPreferredLanguage, 0, $dashPosition ) )
) {
return $svgLang;
}
}
return null;
}
Bug: T154132
Change-Id: Ibff66a0844f0cecfae0260c6a7d20aeedc2849a2
Several classes have a "selectFields()" static method to tell callers
which fields to select from the database. With the recent comment table
change and the upcoming actor table change, this pattern has become too
simplistic as a SELECT will need to join several tables to be able to
retrieve all the needed fields.
Thus, we deprecate the selectFields() methods in favor of getQueryInfo()
methods that return tables and join conditions in addition to the
fields.
Change-Id: Idcfd15568489d9f03a7ba4460e96610d33bc4089
CommentStore->insert() takes the raw comment, not quoted, and returns
fields appropriate for passing as $a to IDatabase->insert() or $values
to ->update(). Such fields need to be passed through
IDatabase->addQuotes() to be appropriate for passing in $varMap to
IDatabase->insertSelect().
Change-Id: Ie64b279ee7cf9c8c396af385e46c826e0597ab1e
When uploading a file, there are a few ways of checking for and blocking
(or at least warning about) duplicate uploads already.
However, it occasionally seems to happen that files get uploaded twice.
The exact same file, usually - submitted at (almost) the exact same time
(possibly some error in whatever submits the file upload, but still)
Given 2 uploads at (almost) the exact same time, both of them are stored,
even if they are the exact same files.
The last upload also ends up with a `logging` entry with `log_page = 0`.
I don’t believe such upload should go through: if we do find that a file
is an exact duplicate of something that already exists, I don’t see any
reason it should go through.
Note that with this patch, it will become impossible to reupload a file
with the exact same hash (which was possible before.)
If we still want to allow same-file reuploads while also blocking these
kind of race-condition same-uploads, we could make the check more strict
(e.g. also check timestamps, or check if page already exists, or …)
Bug: T158480
Change-Id: I76cbd2c64c3b893997f1f85974d6f82cbfe121e1
With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation.
Change-Id: I2ecb6030bf253664c3227d69b5ed2277596a83f0
It doesn't matter when $wgCommentTableSchemaMigrationStage is
MIGRATION_OLD, but it'll fail when we start changing that to later
migration stages.
Follows up I3447a412.
Change-Id: I6c010cefedd99324080ec078b83159d12709c1b1