Skip to content

DPDatabase.inc: query() never returns false if $throws_exception == true - #1658

Merged
cpeel merged 1 commit into
DistributedProofreaders:masterfrom
bpfoley:level-7-query-exception
Sep 29, 2026
Merged

cpeel merged 1 commit into
DistributedProofreaders:masterfrom
bpfoley:level-7-query-exception

Conversation

@bpfoley

@bpfoley bpfoley commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Give more precise PHPStan type annotations which reveals issues with several callers.

This removes false as a possible return value for several callers such as:

  • ProjectSearchResults::get_sorting()
  • log_access_change()
  • get_latest_access_change_entry()
  • _run_pp_threshold_query_result()

This has knock-on effects for several callers which relied on query() returning false on a DB connection failure so it can do its own error handling, so add throws_exception: false to these calls:

  • project_recalculate_page_counts()
  • DPSessionHandler::write()
  • DPSessionHandler::destroy()
  • page_info_query()

Give more precise PHPStan type annotations which reveals issues with
several callers.

This removes `false` as a possible return value for several callers
such as:
- `ProjectSearchResults::get_sorting()`
- `log_access_change()`
- `get_latest_access_change_entry()`
- `_run_pp_threshold_query_result()`

This has knock-on effects for several callers which relied on `query()`
returning false on a DB connection failure so it can do its own
error handling, so add `throws_exception: false` to these calls:
- `project_recalculate_page_counts()`
- `DPSessionHandler::write()`
- `DPSessionHandler::destroy()`
- `page_info_query()`

(cherry picked from commit 9e3d604905c96419adc5d89da27bae477943ada7)
@cpeel
cpeel merged commit 6b74a9c into DistributedProofreaders:master Sep 29, 2026
12 checks passed
@bpfoley
bpfoley deleted the level-7-query-exception branch September 29, 2026 21:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants