Commit graph

69 commits

Author SHA1 Message Date
James D. Forrester
df5eb22f83 Replace uses of DB_MASTER with DB_PRIMARY
Just an auto-replace from codesniffer for now.

Change-Id: I5240dc9ac5929d291b0ef1c743ea2bfd3f428266
2021-04-29 09:24:31 -07:00
Reedy
6e5ef64f50 Give rebuildFileCache.php an all pages option
Bug: T257721
Change-Id: Id448c084d1a5bcc881b090d3e5300530a5fa9bb9
2020-07-11 12:54:58 +01:00
Reedy
12a3883a7b Fix SingleSpaceBeforeSingleLineComment
Change-Id: I285af438ce484af40741489797f20455726ec110
2020-05-11 00:57:11 +00:00
Timo Tijhof
d18e76dbef Setup: Move MWDebug logic to MWDebug.php
* Remove checks in HTMLFileCache.php and Article.php.

  These haven't been needed since the same check was added to Setup.php,
  many years ago. When FileCache is enabled, The Setup.php code disables
  MWDebug. There is no reason for FileCache to then also disable itself
  based on unused config. That means both of them lose.
  We now handle this logic in one place: MWDebug::setup().

* In rebuildFileCache.php, turn it off explicitly, just in case.
  The previous code there didn't work because finalSetup()
  is called after doMaintenance.php includes Setup.php, which
  is what checked this config var to decide on MWDebug::init.
  On the other hand, it's also always off in CLI mode.
  But, let's not depend on that, maybe we decide to enable it on
  CLI one day! Just keep it off explicitly here.

Bug: T189966
Change-Id: I45a8f77092249751dc6f276aa5bb67ebf5b4f64c
2019-09-04 16:33:25 +00:00
Aryeh Gregor
2e1ac38485 Mass conversion to NamespaceInfo
Change-Id: I2fef157ceec772f304c0923a1cd8c0eef2e82a0f
2019-05-07 22:44:56 +02:00
Fomafix
3ee1560232 No yoda conditions
Replace
  if ( 42 === $foo )
by
  if ( $foo === 42 )

Change-Id: Ice320ef1ae64a59ed035c20134326b35d454f943
2018-11-21 17:54:39 +01:00
Kevin Israel
06ba5ca383 Remove internal use of deprecated $wgRequestTime
* Use $_SERVER['REQUEST_TIME_FLOAT'] unconditionally in WebRequest.php
  and libs/Timing.php. WebStart.php was doing this already without issue.
  The key existst since PHP 5.4, for both Web and CLI (we require 5.5).

* In wfDebug() and wfReportTime(), use $_SERVER['REQUEST_TIME_FLOAT'] instead.

* In ApiFormatBase and MWDebug, use WebRequest::getElapsedTime() instead.

* In Maintenance.php, remove setting of $wgRequestTime.

* In rebuildFileCache.php, update mocking to $_SERVER['REQUEST_TIME_FLOAT']
  so that we avoid re-introducing bug T24852.

Change-Id: I1b647da2862f815029caa533b592ec8a05b33806
2018-03-18 04:41:12 +00:00
daniel
218e8311d5 Pass '' instead of false for the $conds parameter in select calls.
Per documentation on IDatabase, $conds must be a string or an array.
Passing false for conds is confusing, since it's unclear whether this
should match everything or nothing.

Bug: T188314
Change-Id: I8be1ac4cbdaafc41aadc2a658be8a99b754b0268
2018-03-02 02:32:54 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Umherirrender
ad776c7d5f Use ::class to resolve class names in maintenance scripts
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I1d4567f47f93eb1436cb98558388e48d35258666
2018-01-23 17:40:16 +00:00
Phantom42
9b4d71f531 Cast block start to int in maintenace SQL
Bug: T182209
Change-Id: Ic2dbbacdf0a77b8ac531cff8e11be0da8014e083
2017-12-08 22:03:49 +02:00
Bryan Davis
9e34eeff23 Maintenance: add fatalError() method
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.

Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
2017-11-21 21:34:16 -07:00
Max Semenik
55a9b2f8b6 Finish migration to Maintenance::getBatchSize()
Change-Id: I02d89f71d820e4d00a39e86a30397b614bbdb432
2017-11-07 19:35:11 -08:00
Timo Tijhof
1e0a992f6c maintenance: Consistently use hasOption() for boolean options
We already do this in many places, but there were also still plenty
of getOption(, false) calls. Change these to hasOption() for consistency.

Change-Id: I74f91a5bf5a8036496ab1f493e5862a04d27ec0f
2017-07-19 14:52:21 -05:00
Tim Starling
820f46964f A service for read-only mode
Introduce a service to represent wfReadOnly() and friends.

It's necessary to have two service instances, one for wfReadOnly() and
one for wfConfiguredReadOnlyReason(), to avoid a circular dependency,
since LoadBalancer needs the configured reason during construction, but
wfReadOnly() needs to query the currently active load balancer.

Not having a cache of the configuration makes it possible to dynamically
change the configuration. Ideally things would not change the
configuration, and I removed such instances in core, but to support
extensions, I added a test ensuring that the configuration can be changed.

Change-Id: I9bbee946c10742526d3423208efd68cb3cc5a7ee
2017-04-19 12:27:06 -07:00
James D. Forrester
242df680ce maintenance: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

This includes renaming fixBug20757.php to fixT22757.php for similar consistency.

Change-Id: If81a590d658fbd82c20c54ac47dfdc8856745ca3
2017-02-21 18:32:44 -08:00
Aaron Schulz
98fe37cabd Avoid fatal error with FlaggedRevs when running rebuildFileCache.php
Change-Id: I8d335c64cfc74a227528fbd85d333eaaa8157f41
2017-01-17 22:10:03 -08:00
Max Semenik
f0c8cbc6d9 Remove a few unused variables
Change-Id: Ibfc4c6cbbc08b5917f1a84d86d2d4a0855e371a1
2016-09-26 17:03:32 -07:00
Aaron Schulz
108ccb0352 Make rebuildFileCache cover ?action=history
Also simplified the logic slightly

Change-Id: I6145d52b6b701735fa4bd8e41e07fb2bf6fdcee3
2016-09-20 00:53:26 -07:00
Aaron Schulz
4246b3796a Fix broken select() call in rebuildFileCache.php
A few other small cleanups

Change-Id: Ie62cf93feb5a57f629a893c7ea298ed902b52789
2016-09-14 13:07:48 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Kunal Mehta
8091e9c6db Don't use $wgContentNamespaces directly
Change-Id: If8ed1bf7e7c6429c405c956413af07a191ec9c40
2016-07-12 15:50:29 -07:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Max Semenik
59db24e90b Use addDescription() instead of accessing mDescription directly
Change-Id: I0e2aa83024b8abf5298cfea4b21bf45722ad3103
2016-01-30 01:28:32 -08:00
Reedy
44cebea941 Update wfGetDB calls in Maintenance scripts to use getDB()
Change-Id: I9ad6745d84506b736dae94747256caac89715899
2016-01-02 16:58:23 +00:00
Aaron Schulz
fa8e1a9b00 Clean up transactions in maintenance scripts
Add transaction methods to complement getDB().
This makes it easy to grep for direct begin()/commit()
calls to IDatabase by having script use their own
wrapper. Maintenance scripts are one of the few places
that can (and need to) use begin/commit instead of the
start/end atomic methods.

Eventually, there should be almost no direct callers
and those methods can be made stricter about throwing
errors on nested calls.

Change-Id: Ibbfc7a77c0d2a55f7fc2261087f6c3a19061e0aa
2015-12-30 23:40:35 +00:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Chad Horohoe
518fa756f2 Remove $wgTitle from all maintenance scripts
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
2014-03-12 18:28:47 -07:00
Timo Tijhof
beb1c4a0ec phpcs: More require/include is not a function
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
2013-05-21 23:26:28 +02:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
umherirrender
b114f5e1c1 Fixed some spacing in maintenance folder
Added spaces before if, foreach
Added some braces for one line statements

Change-Id: I9657f72996358f8c1c154cea1ea97970d973723c
2013-04-18 20:48:44 +02:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Alexandre Emsenhuber
6015071beb Improve documentation of maintenance scripts.
Change-Id: I21b4fb873e88026108754eb7206e62c82648df0e
2012-08-09 19:28:14 +02:00
Sam Reed
c47f83a4d4 More __METHOD__ in our madness 2012-02-24 18:45:24 +00:00
Antoine Musso
2d56c97b8e rebuildFileCache now really disable debugToolbar
r110761 did not properly disabled the debug toolbar. It has to be
done before Setup.php (MWDebug uses a private static to track that
global variable).

really fix r110758 / r110762
2012-02-07 09:37:59 +00:00
Antoine Musso
57e874c374 disable wgDebugToolbar when rebuilding file cache
credits to iAlex :)
2012-02-06 17:17:51 +00:00
Alexandre Emsenhuber
fc85d44def * Reordered code to not create a RequestContext if the title is invalid
* Use Article::newFromTitle() instead of new Article()
* Set the WikiPage in the context from the created Article object
2012-01-17 12:38:23 +00:00
Aaron Schulz
3205bdf761 * Added end parameter and redid arguments as parameters.
* Set $wgReadOnly to avoid firing enotif stuff and such.
* Pushed commit() statements outside of batch loop...added begin().
* Removed wfWaitForSlaves(), which is just more overhead...nothing should be writing to the DB, the transaction is there just in case.
2011-10-02 17:19:19 +00:00
Aaron Schulz
6014f0db91 HTMLFileCache refactoring:
* Rewrote class and split into three classes: a base class, and html cache and a more generic cache to be used later.
* The new classes now use RequestContext.
* Renamed fetchPageText() -> fetchText().
* Split out new saveText() function from saveToFileCache().
* Various other cleanups and fixes.
Also fixed backwards setting of $wgDisableCounters in rebuildFileCache.php.
2011-09-29 08:18:20 +00:00
Chad Horohoe
f1cd059859 Bunch of error suppression operator fixes (bug 2011-07-06 21:57:44 +00:00
Happy-melon
295f513e8b More unpicking of r85288. I think this is all of the magic method calls, but they're very hard to grep for (part of the problem with them!), so let's leave the calls in with a wfDeprecated() for a while... 2011-06-03 11:04:49 +00:00
Chad Horohoe
2433320259 $wgArticle ain't needed here either ;) (followup r88588) 2011-05-22 18:05:17 +00:00
Chad Horohoe
3e11266ae5 $wgArticle is deprecated! Possible removal in 1.20 or 1.21!
* Encapsulate index.php in wfIndexMain() (similar to r77873)
* Kill $wgArticle check in Exception, not necessary anymore
* Kill $wgArticle in Setup, also not necessary
* Add angry note about $wgArticle to rebuildFileCache.
* Remove note about $wgArticle in Parser since it's dying anyway
2011-05-22 17:59:47 +00:00
Platonides
62053ac8fd Merge r86398 into the old wfWaitForSlaves. Update core calls.
maintenance/waitForSlave.php still calls the old prototype.
Most instances were replaced with 
sed -i 's/wfWaitForSlaves( [0-9]* );/wfWaitForSlaves();/' ./maintenance/initEditCount.php ./maintenance/updateRestrictions.php ./maintenance/updateSpecialPages.php ./maintenance/importDump.php ./maintenance/moveBatch.php ./maintenance/storage/resolveStubs.php ./maintenance/storage/trackBlobs.php ./maintenance/storage/fixBug20757.php ./maintenance/storage/moveToExternal.php ./maintenance/storage/compressOld.inc ./maintenance/populateSha1.php ./maintenance/deleteDefaultMessages.php ./maintenance/migrateUserGroup.php ./maintenance/importImages.php ./maintenance/runJobs.php ./maintenance/archives/upgradeLogging.php ./maintenance/deleteBatch.php ./maintenance/populateLogSearch.php ./maintenance/populateLogUsertext.php ./maintenance/gearman/gearmanWorker.php ./maintenance/populateRevisionLength.php ./maintenance/refreshLinks.php ./maintenance/deleteSelfExternals.php ./maintenance/upgrade1_5.php ./maintenance/rebuildFileCache.php ./includes/job/RefreshLinksJob.php ./includes/installer/MysqlUpdater.php ./maintenance/convertUserOptions.php ./maintenance/populateParentId.php ./maintenance/runBatchedQuery.php ./maintenance/upgrade1_5.php ./maintenance/waitForSlave.php ./maintenance/populateCategory.php ./maintenance/importImages.php
2011-04-20 00:12:06 +00:00
Sam Reed
3112302c73 Remove unused globals 2011-04-11 13:53:57 +00:00
Happy-melon
e400425bfc Follow-up r85403: rm debugging code and a defunct method call. 2011-04-05 10:44:07 +00:00
Happy-melon
625695317e Follow-up r85302: update OutputPage constructors in core. 2011-04-05 00:06:47 +00:00
Chad Horohoe
26505b170a Fix concern raised by Brion in r74108 (but has really existed since the maintenance rewrite). Right now, including a maintenance script causes it to execute. This is bad when you want to reuse the particular class but not have it start executing all by itself.
Until now, we relied on setting MW_NO_SETUP which was a) hacky, b) irreversable, and c) likely to be forgotten if you didn't use one of the wrappers like runChild().

Instead, move the freaky magic to doMaintenance and have *it* check if it's in a specific call stack that indicates this is being run from the file scope and should be executed. Rename DO_MAINTENANCE to RUN_MAINTENANCE_IF_MAIN so it's nice and clear what magic happens behind the require_once().
2011-01-13 22:58:55 +00:00
Alexandre Emsenhuber
1343d55200 Removed OutputPage::setEncodings(); its current implementation just converts $wgInputEncoding and $wgOutputEncoding to lowercase but the inclusion of Language.php will set them back to uppercase.
So instead of playing with these variables, let's just remove that function.
2010-12-08 08:03:52 +00:00
Mark A. Hershberger
617a5b1e15 Whitespace fixup under tha maint directory. 2010-12-04 03:20:14 +00:00