Skip to content

Handle cache watcher update checks when cache is empty#37279

Merged
phil-davis merged 1 commit into
masterfrom
cache-watcher-checks
Apr 21, 2020
Merged

Handle cache watcher update checks when cache is empty#37279
phil-davis merged 1 commit into
masterfrom
cache-watcher-checks

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

Description

On PHP 7.4 phpunit gets these errors:

1) Test\Files\Storage\CommonTest::testCheckUpdate
Trying to access array offset on value of type bool

/drone/src/lib/private/Files/Cache/Watcher.php:125
/drone/src/lib/private/Files/Cache/Watcher.php:87
/drone/src/tests/lib/Files/Storage/Storage.php:346

2) Test\Files\Storage\CopyDirectoryTest::testCheckUpdate
Trying to access array offset on value of type bool

/drone/src/lib/private/Files/Cache/Watcher.php:125
/drone/src/lib/private/Files/Cache/Watcher.php:87
/drone/src/tests/lib/Files/Storage/Storage.php:346

3) Test\Files\Storage\HomeTest::testCheckUpdate
Trying to access array offset on value of type bool

/drone/src/lib/private/Files/Cache/Watcher.php:125
/drone/src/lib/private/Files/Cache/Watcher.php:87
/drone/src/tests/lib/Files/Storage/Storage.php:346

4) Test\Files\Storage\LocalTest::testCheckUpdate
Trying to access array offset on value of type bool

/drone/src/lib/private/Files/Cache/Watcher.php:125
/drone/src/lib/private/Files/Cache/Watcher.php:87
/drone/src/tests/lib/Files/Storage/Storage.php:346

Methods in lib/private/Files/Cache/Watcher.php can get called when there is currently no entry in the cache. Check for that case and cleanly signal that the cache needs updating (i.e. if there is a file not it is not in the cache yet, then "by definition" the cache needs updating).

IMO in PHP 7.2 and 7.3 this is what ends up happening now anyway. The accesses like $cachedData['storage_mtime'] when $cachedData id boolean false happen without PHP complaining, and it ends up updating the cache.

How Has This Been Tested?

CI

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Database schema changes (next release will require increase of minor version instead of patch)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:
  • Changelog item, see TEMPLATE

@update-docs

update-docs Bot commented Apr 20, 2020

Copy link
Copy Markdown

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes.

@phil-davis

Copy link
Copy Markdown
Contributor Author

@micbar IMO the current run-time behavior with PHP 7.2 and 7.3 works. So there is no "bug". This is a refactoring to improve the code and stop PHP 7.4 complaining.

Do we add a changelog entry for this sort of thing?

@codecov

codecov Bot commented Apr 20, 2020

Copy link
Copy Markdown

Codecov Report

Merging #37279 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #37279   +/-   ##
=========================================
  Coverage     64.52%   64.53%           
- Complexity    19155    19157    +2     
=========================================
  Files          1266     1266           
  Lines         74912    74915    +3     
  Branches       1331     1331           
=========================================
+ Hits          48340    48343    +3     
  Misses        26180    26180           
  Partials        392      392           
Flag Coverage Δ Complexity Δ
#javascript 54.14% <ø> (ø) 0.00 <ø> (ø)
#phpunit 65.68% <100.00%> (+<0.01%) 19157.00 <0.00> (+2.00)
Impacted Files Coverage Δ Complexity Δ
lib/private/Files/Cache/Watcher.php 97.22% <100.00%> (+0.25%) 19.00 <0.00> (+2.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 680894d...184bb5d. Read the comment docs.

@phil-davis phil-davis merged commit 8f57503 into master Apr 21, 2020
@delete-merged-branch delete-merged-branch Bot deleted the cache-watcher-checks branch April 21, 2020 06:47
@phil-davis phil-davis mentioned this pull request Apr 24, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants