* Some functions accept only string, cast ints and floats to string
* After preg_matches or explode() casts numbers to int to do maths
* Cast unix timestamps to int to do maths
* Cast return values from timestamp format function to int
* Cast bitwise operator to bool when needed as bool
* php internal functions like floor/round/ceil documented to return
float, most cases the result is used as int, added casts
Found by phan strict checks
Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.
Created by I25a17fb22b6b669e817317a0f45051ae9c608208
Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
This messages should be DEBUG level instead of ERROR level.
Also use __METHOD__ for consistency with other log messages.
Bug: T270994
Change-Id: I1449f618747d48bd1205adfc968cc6a92ecf1ac7
Currently 62.79% coverage, 108/172 lines.
One oddity discovered during testing was that the "quick" variants of
most methods don't have an $opts parameter. It seems like just an
oversight, so I added it.
Bug: T234227
Change-Id: If2978065392cd6dcf693a588bb1ce6b5d43828f2
* Only call FileBackend::clearCache() only specific file paths.
Make FSFileBackend respect specific path lists in doClearCache().
* Detect FSFileBackendList errors during initialization rather than
doing additional stat calls beforehand.
* Simplify FSFileBackend::doPrepareInternal() by removing is_readable()
check as well as is_writable() when mkdir() was just successfully run.
* Simplify FSFileBackend::isPathUsableInternal() to just look at the
parent directory (more likely to exist and be cacheable). Since files
are renamed into place, there isn't much need to sanity check the
target file path itself.
* Add a process cache for "usable directories" to FSFileBackend.
* Use is_dir() in TempFSFile to avoid triggering access() syscalls
each time.
Change-Id: Ib2c76f4c4117b9beffd89370498aa57b5972f167
Add more result constants and split up FileBackend::UNKNOWN for
clarity. This follows up 5719815f3b, which added that constant.
Make internal FileBackendStore::doGet* methods distinguish I/O errors
from missing files; the return types of public FileBackend methods are
unchanged. Avoid process caching any mtime/size/sha1 values in the
case of I/O errors. Use error constants consistently for stat methods
when given invalid paths.
Also:
* Factor out FileBackendStore::processCacheAndPersistStatEntries() method
to reduce significant code duplication.
* Consolidate duplicated isPathUsable() checks in FileOp subclasses to
FileOp::precheck().
* Remove null process cache value check from FileBackend::getFileStat()
as null values are never stored in the process cache to begin with.
* Reformat some oddly wrapped lines to look cleaner.
Change-Id: Id0e4b0da0bb2ed3184847b35142d587c7f3d953d
Report file stat errors and sha1/stat mismatches in consistencyCheck().
This will trigger resyncFiles() which will make second attempt to check
the consistency while also fixing any problems if possible. Make sure
that it also bails out if such errors occur again.
Improve consistencyCheck()/resyncFiles() variable naming and add more
comments to FileBackend::UNKNOWN.
Also replace wfDebugLog() calls with PSR logger calls and wfTimestamp()
calls with ConvertibleTimestamp::convert() calls.
Bug: T231086
Change-Id: I69bcee636c6d99970e9a6448bb8296c0790c7254
MediaWiki core now runs phan 1.2.6, bringing in nearly 2+ years of upstream
fixes.
Configuration was moved from `tests/phan` to `.phan/`. The legacy bash wrapper
script is still kept in the repository in its own location for any extensions
that are still using it. It should be removed before 1.33 is released.
Since there's a lot of new issues being flagged, all currently failing issues
are suppressed, and will be fixed in follow-up patches.
We're dropping the jetbrains/phpstorm-stubs repository in favor of just
the minimal stubs we need. Stubs for PHP extensions are kept in
the new `.phan/internal_stubs` directory, since they're in a slightly
different format than normal stubs.
Normal stubs are kept in `.phan/stubs`. wikidiff2 and excimer are kept with
these since we're also the upstream for them.
Change-Id: I3fe437befa17f4fbaf97aa6271f659b56021f396
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
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168
Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||
Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
* FileBackendGroup now applies the usual config for these sub-backends,
the same config get() applies.
* Also make sure FileBackendMultiWrite::concatenate() uses the status wrapper.
Bug: T146904
Change-Id: I1e9b5027dbac11ea9484cd16851e5db998574429