Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SETUP/tests/smoketests/pageload_smoketest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@

{'name': 'api-queues', 'path': 'api/index.php?url=v1/queues'},
{'name': 'api-queue', 'path': 'api/index.php?url=v1/queues/500'},
{'name': 'api-queue-noname', 'path': 'api/index.php?url=v1/queues&name=noname'},
{'name': 'api-queue-inv-keys', 'path': 'api/index.php?url=v1/queues&invalid=query', 'expect_status': 400},
{'name': 'api-queue-inv-field', 'path': 'api/index.php?url=v1/queues&field[]=name&field[]=enabled&field[]=place-des', 'expect_status': 400},
{'name': 'api-queue-stats', 'path': 'api/index.php?url=v1/queues/500/stats'},
{'name': 'api-queue-projects', 'path': 'api/index.php?url=v1/queues/500/projects'},

Expand Down
14 changes: 12 additions & 2 deletions api/v1_queues.inc
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,19 @@ function api_v1_queues(string $_method, array $_data, array $query_params): arra
array_push($valid_return_fields, "project_selector", "projects_target", "pages_target");
}

// restrict to list of desired fields, if set
$return_fields = array_get_as_array($query_params, "field", $valid_return_fields);
$return_fields = array_intersect($return_fields, $valid_return_fields);

// Validate query params
$valid_query_keys = array_merge($valid_fields, ['show', 'field']);
$invalid_query_params = array_diff(array_keys($query_params), $valid_query_keys);
if (!empty($invalid_query_params)) {
throw new InvalidValue("Invalid query args: " . join(", ", $invalid_query_params));
}

$invalid_fields = array_diff($return_fields, $valid_return_fields);
if (!empty($invalid_fields)) {
throw new InvalidValue("Invalid field[] args: " . join(", ", $invalid_fields));
}

$name_selector = $query_params["name"] ?? null;
$group_selector = $query_params["group"] ?? null;
Expand Down
8 changes: 4 additions & 4 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ parameters:
paths:
- pinc/3rdparty/mediawiki/*.php

# Use $_foo as the naming convention for unused function params that
# we want to keep to satisfy some API. Silence PHPStan warnings when
# this happens.
- message: '#Function .* has an unused parameter \$_.*\.#'


typeAliases:
# TODO: data.y should be numeric list, but callers needs fixing
GraphConfig: """
Expand Down
3 changes: 2 additions & 1 deletion pinc/Activity.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ include_once($relPath.'User.inc');

// $ACCESS_CRITERIA are extended as activities are defined.

/** @var array<string, string> $ACCESS_CRITERIA */
global $ACCESS_CRITERIA;
$ACCESS_CRITERIA = [
'days since reg' => _('Days since registration'),
Expand Down Expand Up @@ -128,7 +129,7 @@ class UserAccess
/**
* @param bool $can_access
* user can access this activity.
* @param list{string, int, int, bool}[] $minima_table
* @param array<string, list{string, int, float, bool}> $minima_table
* ( $criterion_str, $minimum, $user_score, $satisfied )
* @param ?('sat-unneeded'|'sat-granted'|'sat-available'|'sat-requested'|'sat-wait'|'sat-denied'|'unsat-granted'|'unsat-requested'|'unsat-ungranted'|'unsat-denied') $request_status
* @param ?string $evaluation_criteria
Expand Down
5 changes: 3 additions & 2 deletions pinc/bad_bytes.inc
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ function define_bad_byte_sequences(): void
{
global $_bad_byte_sequences, $_character_data;

/** @var non-empty-array<string, list{string, string}> $_bad_byte_sequences */
$_bad_byte_sequences = [];

foreach ($_character_data as $code_point => $info) {
Expand Down Expand Up @@ -681,8 +682,8 @@ function define_bad_byte_sequences(): void

ksort($_bad_byte_sequences);

if (0) { /** @phpstan-ignore-line */
foreach ($_bad_byte_sequences as $raw => $remarks) { /** @phpstan-ignore-line Fixed in https://github.com/phpstan/phpstan/issues/9403 */
if (0) { // @phpstan-ignore if.alwaysFalse
foreach ($_bad_byte_sequences as $raw => $remarks) {
[$code_point, $why_bad] = $remarks;
echo sprintf(
"%s: U+%04x %s\n",
Expand Down
1 change: 1 addition & 0 deletions pinc/html_page_common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function output_html_header(?string $nameofpage, array $extra_args = [], bool $s
if ($was_output) {
return;
}
$was_output = true;

$user = User::load_current();

Expand Down