Commit graph

129 commits

Author SHA1 Message Date
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
Alexandre Emsenhuber
f3c8358eb8 Fix for Ibe3e88fa (a12ce17c): Moved WikiPage::getDeletionUpdates() near WikiPage::doDeleteUpdates().
Please group related methods instead of adding new at the bottom along with deprecated ones. Thanks.

Change-Id: Ie08500de8226e33d5fe4c8a2a95c6a23a550e6d1
2012-06-01 11:09:59 +02:00
Platonides
74fa4635ca Change if/else to a ternary operator
This keep the wfProfileOut() detector happy.

Change-Id: I85ecc33121d94e6a2d2e8ea3d1f5ca47f3db86bc
2012-05-29 20:58:15 +02:00
daniel
fa132be893 fix for Ibe3e88fa: restoring doDeleteUpdates().
When generalizing LinksUpdate to DataUpdate and introducing
WikiPage::getDeletionUpdates(), WikiPage::doDeleteUpdates()
was removed, even though it was still used by Title::moveToInternal().

This patch restores WikiPage::doDeleteUpdates(), using the
new logic based on WikiPage::getDeletionUpdates() to implement it.

Change-Id: I12a49d5ca3ccb6bb9cbb63dde436bcf2a7d8a985
2012-05-18 18:58:21 +02:00
Aaron Schulz
060ba3cb68 Merge "Generalizing LinksUpdate to allow extensions to add arbitrary update handlers." 2012-05-14 22:20:04 +00:00
daniel
a12ce17c6e Generalizing LinksUpdate to allow extensions to add arbitrary update handlers.
This supercedes I6d03bf2a, using better names for the new classes and
incorporating the changes requested by Aaron.

This change introduces the base class SecondaryDataUpdate to be used for any
updates that need to be applied when a page is changed or deleted. Until now,
this was done by the LinksUpdate class for updates and WikiPage::doDeletionUpdates
upon deletion. This patch uses a list of SecondaryDataUpdates in both cases.

This allows extensions (e.g. via the ContentHandler facility, once that is in) to
easily specify what needs to be done when a page is updated or deleted in order to
keep any secondary data stores (such as link tables) in sync.

Note that limited transactional logic is also introduced, so SecondaryDataUpdate
can be implemented to only commit their changes if all updates were performed
sucessfully.

Patch Set 2: fixing some coding style issues mentioned by Nikerabbit.

Patch Set 4: some stuff I kept from the old LinksUpdate class needs cleanup,
             but might break extensions when changed. Marking as todo for now.

Patch Set 5: fixed misnamed member in LinksDeletionUpdate (thanks Aaron).

Change-Id: Ibe3e88fadd8c1d4063cf13bb6972f2a23569a73f
2012-05-13 20:53:37 +02:00
Kaldari
57975e257f Adding new getCreator and getOldestRevision methods to WikiPage class.
Patch 2: Adding getOldest method per comments
Patch 3: whitespace fix
Patch 4: renaming getOldest to getOldestRevision
Patch 5: separating into 3 methods: getOldestRevisionId, getOldestRevision, getCreator
Patch 6: more concise, fixing whitespace
Patch 7: return user object instead of user id
Patch 8: consolidating revision methods per discussion
Patch 9: whitespace
Patch 11: better commit summary
Patch 12: Typo, sigh
Patch 13: switching to use Revision::newFromRow per comment
Patch 14: using Revision::selectFields()
Patch 15: moving outside of while loop
Change-Id: I140e17a95b89c9263978942fd642d6a236a5cc4f
2012-05-09 20:41:16 -07:00
Alexandre Emsenhuber
2040d1337e Added missing GPLv2 headers in some places.
Also made file/class documentation more consistent.

Change-Id: Ib46e50da4ec649a6a06cbeed00752effb79ed06e
2012-05-09 20:11:36 +02:00
Alexandre Emsenhuber
61f246aa78 Made WikiPage recall the source of the data used to load its state.
In WikiPage.php:
* Added WikiPage::$mDataLoadedFrom to store the source of the data used to load the state of the object and four new WikiPage::DATA_* constants for its possible values.
* Added WikiPage::convertSelectType() to convert 'fromdb', 'fromdbmaster' and 'forupdate' to the new WikiPage::DATA_* constants.
* Added $options to WikiPage::pageData(), WikiPage::pageDataFromTitle() and WikiPage::pageDataFromId() so that the "FOR UPDATE" option can be passed to DatabaseBase::select().
* Added new possibility "forupdate" to WikiPage::loadPageData() load the data from the master database using SELECT FOR UPDATE; this avoids to have to do this by LinkCache (via Title::getArticleID( Title::GAID_FOR_UPDATE ) )).
* Changed WikiPage::doDeleteArticleReal() to use this new feature so that all the data stored in WikiPage is up-to-date.

My point is also to deprecate the loading using SELECT FOR UPDATE in Title and remove LinkCache::forUpdate() at some point (there are still one usage in Title::moveTo(), two other in UploadFromUrlTest plus some in extensions).

In EditPage.php:
* Don't call WikiPage::clear() after fetching informations from master, this destroys all we work we did to get the correct data.
* Reload the whole data from master using SELECT FOR UPDATE directly in WikiPage and not only in Title. The problem was that before, the up-to-date information was only available in Title and not in WikiPage.
  Consider the following sequence from a MySQL prompt (where both revision 1 and 2 belong to page one, revision #2 being the current one):

mysql> UPDATE page SET page_latest=1 WHERE page_id=1;
mysql> COMMIT;
// Now grad the edit form for page #1 from the web and do some changes
mysql> BEGIN;
mysql> SELECT page_latest FROM page WHERE page_id=1 FOR UPDATE;
// Now submit the web form
mysql> UPDATE page SET page_latest=2 WHERE page_id=1;
mysql> COMMIT;

Before you ended-up with a "edit conflict" form with revision #1's text being displayed as current text (even if the texts are mergeable), due to the fact that
in the submit request the WikiPage object was loaded at the moment where page_latest was 1 (certainly due to MySQL's "consistent read" feature) making the
"UPDATE page SET ... WHERE page_id=1 AND page_latest=1" query of WikiPage::updateRevisionOn() return zero row, and thus WikiPage::doEdit returing a fatal Status object with message "edit-conflict".
Now the SELECT FOR UPDATE is done in the WikiPage, meaning that the object has the correct data and EditPage will correctly try to merge the revisions (and show the correct edit conflict if needed).

Change-Id: Ic4878ddb4dd96432b7ecaf43f9f359458d966999
2012-05-07 09:17:14 +02:00
Reedy
5813680952 Few documentation/type hint updates
Change-Id: Ib2882cc03540403f74f68854fa76df375c1bb25a
2012-05-01 22:03:50 +01:00
Alexandre Emsenhuber
658ae44bd1 Optimise WikiPage::newFromID() to load all the data in one database query.
* Separated the last part of WikiPage::loadPageData() into loadFromRow() to put database access and object loading into separate methods (and also for consistency with other classes)
* Added WikiPage::newFromRow() to be able to get a WikiPage object from an already-existing database row
* Modified WikiPage::newFromID() to do a single database request to get all the necessary data and make it use the new newFromRow() method

Change-Id: I2db423f2dba10cc3db4f4b2e7a7b9d99cd114f33
2012-04-17 21:08:29 +02:00
Sam Reed
2d25a902e3 More of r113580 2012-03-11 22:05:54 +00:00
Alexandre Emsenhuber
a221f358a6 Pass __METHOD__ to DatabaseBase::begin(), DatabaseBase::commit() and DatabaseBase::rollback() 2012-02-23 20:01:17 +00:00
Alexandre Emsenhuber
75da88318c Added $performer parameter to PatrolLog::record() and pass it from WikiPage::doEdit() and RecentChange::doMarkPatrolled() since the performer is not necessarily $wgUser 2012-02-21 22:27:33 +00:00
Alexandre Emsenhuber
4943b75b89 fix documentation: WikiPage::newFromID() can return null 2012-02-20 21:48:01 +00:00
Alexandre Emsenhuber
77fe134b08 Also call $this->clear() from WikiPage::doDeleteUpdates() so that the object is in a consistent state after deletion 2012-02-14 15:06:13 +00:00
Jeroen De Dauw
abfdd0b617 fix doc 2012-02-13 19:13:30 +00:00
Sam Reed
c052fc3b7b Documentation followups from lastnight 2012-02-10 15:37:33 +00:00
Sam Reed
09a78c1368 More return documentation 2012-02-09 21:36:14 +00:00
Sam Reed
0a626db6e1 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:29:36 +00:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Max Semenik
efb855cb88 Fix my stupid mistake in r110750 that resulted in fake "can't delete page" errors (bug 34245) 2012-02-08 18:07:41 +00:00
Max Semenik
ad5292af60 Follow-up r110750: move constants to a different class per CR 2012-02-07 09:40:08 +00:00
Max Semenik
5dd5b558e3 Fixed r63018: made it possible to delte half-baked images w/o descriptions, clearer error message 2012-02-06 15:21:10 +00:00
Alexandre Emsenhuber
7f53e62508 * Use $this->getRevision() to get the latest revision instead of loading it each time from the database
* Moved wfGetDB( DB_MASTER ) a bit after so that it is only called when needed
2012-02-05 18:45:07 +00:00
Alexandre Emsenhuber
afab06cc73 wfTime() -> microtime( true ), no need to use the former which is just a wrapper to the latter 2012-02-03 08:32:34 +00:00
Antoine Musso
fc6bc233be Fix doxygen docs before REL1_19 branching 2012-02-01 20:53:38 +00:00
Alexandre Emsenhuber
829dd6ef9d * Group related functions
* Moved isCountable() and redirect-related function a bit downward
2012-01-27 21:13:25 +00:00
Alexandre Emsenhuber
16ec2100de * Do the page existence check before calling ignore_user_abort() so that we don't return after having modified that value
* Change the check to use $oldid since we already have the result of getLatest()
2012-01-26 16:44:29 +00:00
Alexandre Emsenhuber
b1d0376c1e Fix bug 32948:
* {{REVISIONID}} and related variables are no longer blank after doing a null edit
* {{REVISIONID}} and related variables are no longer blank after calling action=purge&forcelinkupdate
2012-01-21 07:59:25 +00:00
Alexandre Emsenhuber
da4780c12e * Use WikiPage instead of Article to call commitRollback()
* Pass the User object from WikiPage::commitRollback() to WikiPage::doEdit()
* Do the edits with 'Maintenance script' user as other maintenance scripts instead of 127.0.0.1
2012-01-14 14:11:08 +00:00
Aaron Schulz
5a6559d8b1 Reverted r108743 per CR comment. This should at least be discussed first. 2012-01-12 19:41:18 +00:00
Sam Reed
a5c200a25b Kill "* @return void" 2012-01-12 19:12:24 +00:00
Platonides
99f352e556 Profile all returns (r107319 follow-up) 2012-01-07 23:23:29 +00:00
Alexandre Emsenhuber
a02ee030e7 Simplify the check to make it more understandable 2012-01-07 16:58:56 +00:00
Alexandre Emsenhuber
c9df79c484 Cleanup in WikiPage::getRedirectURL():
* Call Title::isValidRedirectTarget() in case of special page instead of checking only for Special:Userlogout
* Refactor the code a bit to be more readable and remove unneeded nested conditions
2012-01-07 15:48:42 +00:00
Alexandre Emsenhuber
99fde665ed Revert r105790 and move back view counter back to WikiPage with two modifications:
* WikiPage::$mCounter is now marked as protected
* Call WikiPage::loadPageData() from WikiPage::getCount() if the count is not set intead of loading the page_counter field only
2012-01-06 20:26:53 +00:00
Alexandre Emsenhuber
36071ad2a5 Fix for r107945: also partially revert r107842 2012-01-04 08:24:11 +00:00
Brion Vibber
0bbf9a45b0 Revert r107769, r107771, r107825, r107840, r107927, r107934
Title objects are meant to be dumb value objects; we shouldn't add to their internal state like this, but should be working to remove the bits already in there like the article ID.
Preloading information like this can make sense, but probably belongs in WikiPage, not Title.
2012-01-03 21:44:41 +00:00
Alexandre Emsenhuber
e40e80e74e Per Aaron, fix for r107771: Title::getTouched() should return false on non-existing page 2012-01-03 20:15:45 +00:00
Alexandre Emsenhuber
17230f6a4e Give Title a decent loading mechanism:
* Added Title::load() to factorise common code that load member variables instead of having each accessor doing it own loading system for its related member variable
* Removed usage of LinkCache::addLinkObj() to do the database query and do this directly in Title::load(). This allows to select the complete database row and populate all member variables; previously, requesting a field not stored in LinkCache (using getCount(), getTouched() or isNewPage()) results in two database query, one to load LinkCache data and the second to load the requested field; now there'll be only one query.
* Added Title::FIELD_IN_LINKCACHE and Title::FIELD_NOT_IN_LINKCACHE to specify whether the requested field is stored in LinkCache or not. LinkCache will be used if possible (i.e. Title::FIELD_IN_LINKCACHE is passed), otherwise a DB query to select the complete row is issued.
* Made Title::loadFromRow() save the row to LinkCache if possible.
* Added $wasFromMaster parameter to Title::loadFromRow() to tell that method whether the row was loaded from the master database or not and pass it from WikiPage::loadPageData()
* Added Title::GAID_USE_MASTER in addition to Title::GAID_FOR_UPDATE to get the row from the master database without having to do a SELECT FROM UPDATE query
* Added Title::selectFields() method to return the fields to select to given Title::loadFromRow() (and methods using it such as Title::newFromRow()) a complete row
* Made Title::$mCounter private since it has only been added recently (in r105790)
* Mark the object as loaded if Title::resetArticleID() is called with as new ID as 0
2012-01-03 19:28:03 +00:00
Niklas Laxström
ba5cc24eb4 Typofix r107842 2012-01-02 18:22:26 +00:00
Alexandre Emsenhuber
f59b944ab1 * Removed WikiPage::$mTouched and use the value from Title; that member is not used anywhere else and is marked protected
* Fix some spaces and added description for WikiPage::$mTouched
2012-01-02 17:26:47 +00:00
Alexandre Emsenhuber
68bf1a77b4 * Store the value of the page.page_restrictions field in Title::loadFromRow() and defers loading restrictions until when it's really needed; this reuses the Title::$mOldRestrictions member which is not used anywhere yet
* Removed $oldFashionedRestrictions parameter from Title::loadRestrictions*(); the only extension using it is LiquidThreads and it's using Title::newFromRow() to create the Title object, so the field is already cached (and this even allows to cache that field when there's no row for that page in the page_restrictions table)
* Also reset $mTouched and $mIsNew members on resetArticleId() calls
* Updated FakeTitle a bit
2012-01-02 12:49:50 +00:00
Alexandre Emsenhuber
40addf3204 * Moved post-deletion code from WikiPage::doDeleteArticle() to WikiPage::doDeleteUpdates() so that it can be shared with page move
* Use WikiPage::doEditUpdates() and WikiPage::onArticleDelete() to do updates instead of reimplementing the whole thing in Title::moveTo(); avoids some bugs since the implementation differs from the one from WikiPage (notably the page and article count). This adds some more cache clearing, but they are needed depending on parameters (e.g. if the redirect is not created).
2011-12-30 15:54:11 +00:00
Alexandre Emsenhuber
1b655a802a * Added Title::getLinksFrom() and Title::getTemplateLinksFrom() for consistency with Title::getLinksTo() and Title::getTemplateLinksTo()
* Deprecated WikiPage::getUsedTemplates() in favour of Title::getTemplateLinksFrom() and updated to it in core
2011-12-29 15:12:00 +00:00
Alexandre Emsenhuber
7654ddf798 * Group related functions
* Put deprecated functions at the bottom
2011-12-29 14:21:15 +00:00
Tim Starling
28482987fb Revert the fix for bug 32858 (r105664, r105161, r103476): no consensus, backwards compatibility issues not addressed (e.g. {{selfsubst/now string}}) 2011-12-27 22:50:10 +00:00
Alexandre Emsenhuber
4f68ae8939 * Integrate $wgDeleteRevisionsLimit in Title::getUserPermissionsErrors() (only if doing expensive checks)
* Moved WikiPage::estimateRevisionCount() and WikiPage::isBigDeletion() to Title and marked those WikiPage methods as deprecated (only call in extensions removed in r107385)
* Show an error message when deleting a page to move another one in Special:MovePage and the deletion fails due to permissions errors (previously the form would simply show again)
* Cache the result of Title::estimateRevisionCount() since it's called two times when showing the deletion form and the user doesn't have 'bigdelete' right (one for the permissions check and the other when showing the number of revisions)
2011-12-27 15:29:44 +00:00