Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 8.2 deprecations #280

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Remove deprecated function
  • Loading branch information
abrain committed Dec 1, 2023
commit 2165e544acadf2fa25eabf23d90af2dc58f6675b
2 changes: 1 addition & 1 deletion src/Admin/TasksPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function renderPage()
$action = filter_input(
INPUT_GET,
'action',
FILTER_SANITIZE_STRING,
FILTER_SANITIZE_SPECIAL_CHARS,
FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH
);

Expand Down
6 changes: 5 additions & 1 deletion src/CustomFieldsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,11 @@ public function saveTerm($termId, $ttId, $taxonomy)
/** @var CustomField $field */
foreach ($this->taxonomyFields[$taxonomy] as $field) {
// TODO choose filter based on type of CustomField
$value = filter_input(INPUT_POST, $field->key, FILTER_SANITIZE_STRING);
$value = filter_input(INPUT_POST, $field->key);

if ($value === null) {
continue;
}

if ($field->isMultiValue()) {
$existingValues = get_term_meta($termId, $field->key);
Expand Down
9 changes: 4 additions & 5 deletions src/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
use function wp_update_post;
use function wp_verify_nonce;
use const FILTER_SANITIZE_NUMBER_INT;
use const FILTER_SANITIZE_STRING;
use const INPUT_POST;

/**
Expand Down Expand Up @@ -147,14 +146,14 @@ public function savePostdata(int $postId, WP_Post $post)

// Einsatznummer setzen, sofern sie nicht automatisch verwaltet wird
if (!ReportNumberController::isAutoIncidentNumbers()) {
$number = filter_input(INPUT_POST, 'einsatzverwaltung_nummer', FILTER_SANITIZE_STRING);
$number = filter_input(INPUT_POST, 'einsatzverwaltung_nummer');
$updateArgs['meta_input']['einsatz_incidentNumber'] = $number;
}

// Einsatzdetails speichern
$metaFields = array('einsatz_einsatzende', 'einsatz_einsatzort', 'einsatz_einsatzleiter', 'einsatz_mannschaft');
foreach ($metaFields as $metaField) {
$value = filter_input(INPUT_POST, $metaField, FILTER_SANITIZE_STRING);
$value = filter_input(INPUT_POST, $metaField);
$updateArgs['meta_input'][$metaField] = empty($value) ? '' : $value;
}

Expand All @@ -166,12 +165,12 @@ public function savePostdata(int $postId, WP_Post $post)
// Vermerke speichern (werden explizit deaktiviert, wenn sie nicht gesetzt wurden)
$annotations = array('einsatz_fehlalarm', 'einsatz_hasimages', 'einsatz_special');
foreach ($annotations as $annotation) {
$value = filter_input(INPUT_POST, $annotation, FILTER_SANITIZE_STRING);
$value = filter_input(INPUT_POST, $annotation);
$updateArgs['meta_input'][$annotation] = empty($value) ? '0' : $value;
}

// Explicitly set an empty collection for a taxonomy if no values have been selected
$taxInput = (array)filter_input(INPUT_POST, 'tax_input', FILTER_SANITIZE_STRING, FILTER_REQUIRE_ARRAY);
$taxInput = (array)filter_input(INPUT_POST, 'tax_input', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
foreach ([Vehicle::getSlug(), Unit::getSlug()] as $taxonomy) {
if (!array_key_exists($taxonomy, $taxInput)) {
$updateArgs['tax_input'][$taxonomy] = [];
Expand Down
2 changes: 1 addition & 1 deletion src/Import/Tool.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function renderToolPage()
}

// 'Sofort veröffentlichen'-Option übernehmen
$publishReports = filter_input(INPUT_POST, 'import_publish_reports', FILTER_SANITIZE_STRING);
$publishReports = filter_input(INPUT_POST, 'import_publish_reports');
$this->currentSource->putArg(
'import_publish_reports',
Utilities::sanitizeCheckbox($publishReports)
Expand Down
2 changes: 1 addition & 1 deletion src/Settings/MainPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private function getConflictingPage(): ?WP_Post
private function getCurrentSubPage(): SubPage
{
$flags = FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH;
$tab = filter_input(INPUT_GET, 'tab', FILTER_SANITIZE_STRING, $flags);
$tab = filter_input(INPUT_GET, 'tab', FILTER_SANITIZE_SPECIAL_CHARS, $flags);

if (empty($tab) || !array_key_exists($tab, $this->subPages)) {
$subPageObjects = array_values($this->subPages);
Expand Down