This is a re-submission of I4f24e7fbb68.
As a first major step towards Multi-Content-Revisions (MCR),
this patch turns the Revision class into a legacy proxy for
the new RevisionRecord and RevisionStore classes.
Backwards compatibility is maintained for all but some
rare edge cases, like constructing a completely empty
Revision object.
For more information on MCR, see
<https://www.mediawiki.org/wiki/Requests_for_comment/Multi-Content_Revisions>.
NOTE: once this is merged, verify create/delete/restore cycle on beta,
ideally with emulated replication lag.
Bug: T174025
Change-Id: Ia4c20a91e98df0b9b14b138eb4825c55e5200384
This reverts commit 9dcc56b3c9.
With this patch applied, newly created revisions are sometimes not found
just after submitting an edit, until replicas have caught up.
Our best theory is that it somehow interfere with ChronologyProtector,
but we don't have a good idea how.
Also, as legoktm mentioned, the commit message is terrible and needs fixing.
Change-Id: Idf3404f3fa8f8d08a7fb2ab8268726e2c1edecfe
I'm guessing that RevisionStore::newMutableRevisionFromArray() is
what is supposed to be tested here, since Revision::__construct()
calls that if it gets an array.
Change-Id: Ia6c2e7eb667aa746a12ce74aad62e58d2468defd
I4f24e7fbb683cb51f3fd8b250732bae9c7541ba2 releaved
a failing test "PageArchiveTest::testUndeleteRevisions"
that constructs a revision from an array only passing
in 'user_text' and no 'user' field.
After investigation this is quite an odd case that
probably shouldnt happen in production code.
The test cases in this patch test the current behaviour.
Bug: T180210
Change-Id: I7040a16ac6cb29b49f8e7bed1caee72cdd4c6a61
This is a partial revert of:
Idcfd15568489d9f03a7ba4460e96610d33bc4089
which removed these tests.
Bug: T180210
Change-Id: Ib0617ee0a7bd4391ed25415b44a8ed077a985eaa
core used to have a test case that ran various Revision tests
with and without ContentHandlerUseDB set, however it did not
run due to the class / file having a bad name.
This patch reintroduces the running on Revision tests for both
ContentHandlerUseDB settings.
The global has to be set in setup / before the page used for
testing is created, else this page will be created with the
wrong values in the DB for use in the tests.
Change-Id: Ied1023e22eeac413fa86ea6946aa31619fd66319
This makes the logic much easier to follow and each type of
construction easier to see.
This also emphisises the testing of construction being split
into row object vs array
Change-Id: Ie3aa6ec4c026f0249ccd438903fec27fcd266b67
This adds tests for each exception that can be thrown
in the Revision constructor.
It also fixes where the exception for the content part of a row
not containing a content object is thrown.
Prior to this ->getModel() could be called on the content row
element before the check had actually occoured.
Change-Id: Ia2d2cfdca01871fc6dbb96707d781db33d7d0a40
MWNamespace has three internal caches, only one of which can be cleared
(and that somewhat oddly by passing a boolean to
MWNamespace::getCanonicalNamespaces()).
This change introduces a MWNamespace::clearCaches() method to clear all
three caches. It also adds some resetting in tests that seemed to be
missing it.
Change-Id: I1dcfcd8713888b3ff8fc75e95329ba72bd95d0c9
Change some tests to use setMwGlobals to have restoring of globals after
the test.
This also removes some save/restore code, which is not needed, due to
the automatically restoring on tearDown with setMwGlobals.
Change-Id: I8d2ac9f6cc14f0bd4ee8eb851c09f2e71babc6e0
Fix almost all occurences of the following sniffs:
Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility
Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
Setting $wgContLang without changing $wgLanguageCode accordingly is a
very bad idea.
This caused about 20 exceptions when using LanguageCode set to 'fr'
on my installation:
"MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode
('fr') is different from $wgContLang->getCode() (en)"
Follow-up of I2987db68 (2b0edc8).
Change-Id: I56d3f1bfc78d6a2e40460533524e82f360490206
This introduces the ContentHandler facility into MediaWiki,
see docs/contenthandler.txt.
For convenient review, a squashed version is available at
https://gerrit.wikimedia.org/r/27191
The ContentHandler facility is a major building block of the Wikidata project.
It has been discussed repeatedly on wikitech-l.
Change-Id: I3804e2d5f6f59e6a39db80744bdf61bfe8c14f98
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.
Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...
Either way they won't have to anymore with setMwGlobals.
Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)
(Matching the function signature with PHPUnit/Framework/TestCase.php)
Replaces:
* public function (setUp|tearDown)\(
* protected function $1(
* \tfunction (setUp|tearDown)\(
* \tprotected function $1(
* \tfunction (data|provide)\(
* \tpublic static function $1\(
Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.
Fixes:
TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).
MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...
FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"
HttpTest
* Added comment about:
"PHP Fatal: Call to protected MWHttpRequest::__construct()"
(too much unrelated code to fix in this commit)
ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
because regardless of whether wgExternalStores is true or false
it only uses it if it is an array.
Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
a) when testing deprecated functions, use $this->hideDeprecated() to
suppress warnings.
b) use doEditContent() instead of doEdit()
Change-Id: Ifa9e0ef373ed72ef7d4a3c2dd558483af4a3fd55
Revision::getContent must return a cloned instance of the Content object
if the Content object is mutable to avoid confusion.
Content::copy is used to achieve this, which is specified to return $this
for immutable Content.
Change-Id: Iace17b6ae8aa85a3500624441b69bc067c1ade00
By adding '@group Database', we make sure those tests are not going to
be run before a database is actually setup.
Change-Id: I6ef256e4c247ceb0a344a963dd3cb67b018e586f
The content model is stored as a varbinary(32), the format
as varbinary(64).
If the standard model resp. format is used, null is written
to the database instead of the actual id, saving space.
Change-Id: I32659b49a9ad3cb8ecae9019562cff7de42b65f9
Representing content_model and content_format as integers in the
database was suggested by Asher mainly to save space.
This change entails some refactoring and renaming, but no big
change in logic.