Skip to content

Commit

Permalink
fix: Passing null to parameter #1 is deprecated for some string funct…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
geokrety-bot committed Aug 11, 2023
1 parent 16f8eda commit 022fada
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion website/app-templates/smarty/plugins/modifier.alias.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ function smarty_modifier_alias($string, $params = null, $query = null, $fragment
$f3->set('__WORKAROUND_1__', true);
}

return GK_SITE_BASE_SERVER_URL.$f3->alias($string, $params, $query).$fragment;
return GK_SITE_BASE_SERVER_URL.$f3->alias($string, $params ?? [], $query).$fragment;
}
2 changes: 1 addition & 1 deletion website/app/GeoKrety/Controller/Pages/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function login2Secid_post(\Base $f3) {
* @return User Connected user authentication succeed
*/
public function secidAuth(\Base $f3, ?string $secid, bool $streamXML = true): User {
if (strlen($secid) !== GK_SITE_SECID_CODE_LENGTH) {
if (strlen($secid ?? '') !== GK_SITE_SECID_CODE_LENGTH) {
Error::buildError($streamXML, _('Invalid "secid" length'));
Event::instance()->emit('user.login.secid-failure', [
'secid' => $secid,
Expand Down
6 changes: 3 additions & 3 deletions website/app/GeoKrety/Model/Geokret.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static function generate(): void {
}

public function gkid(): int {
return hexdec(substr($this->gkid, 2));
return hexdec(substr($this->gkid ?? '', 2));
}

public function get_gkid($value): ?string {
Expand All @@ -205,11 +205,11 @@ public static function id2gkid(int $id): ?string {
}

public function get_name($value): string {
return html_entity_decode($value);
return html_entity_decode($value ?? '');
}

public function get_tracking_code($value): string {
return strtoupper($value);
return strtoupper($value ?? '');
}

public function get_type($value): GeokretyType {
Expand Down
2 changes: 1 addition & 1 deletion website/app/GeoKrety/Model/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public function set_password($value): string {
}

public function get_username($value): string {
return html_entity_decode($value);
return html_entity_decode($value ?? '');
}

public function get_joined_on_datetime($value): ?\DateTime {
Expand Down
2 changes: 1 addition & 1 deletion website/app/GeoKrety/Service/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static function serializeGoto(string $alias = 'home', $params = null): st
'query' => base64_encode($f3->serialize($f3->get('GET'))),
];

return \Base::instance()->alias($alias, $params, $query);
return \Base::instance()->alias($alias, $params ?? [], $query);
}

/**
Expand Down
7 changes: 5 additions & 2 deletions website/app/GeoKrety/Service/Validation/TrackingCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function getErrors() {
}

private function checkLength($trackingCode) {
if (strlen($trackingCode) < GK_SITE_TRACKING_CODE_MIN_LENGTH) {
if (strlen($trackingCode ?? '') < GK_SITE_TRACKING_CODE_MIN_LENGTH) {
array_push($this->errors, sprintf(_('Tracking Code "%s" seems too short. We expect at least %d characters here.'), $trackingCode, GK_SITE_TRACKING_CODE_MIN_LENGTH));

return false;
Expand All @@ -33,7 +33,7 @@ private function checkLength($trackingCode) {
}

private function isGKNumber($trackingCode) {
if (substr($trackingCode, 0, 2) === 'GK') {
if (!is_null($trackingCode) && substr($trackingCode, 0, 2) === 'GK') {
if (strlen($trackingCode) >= GK_SITE_TRACKING_CODE_MIN_LENGTH) {
$geokret = new Geokret();
$geokret->load(['tracking_code = ?', $trackingCode]);
Expand Down Expand Up @@ -101,6 +101,9 @@ private function renderGeokret(Geokret $geokret) {
}

public static function split_tracking_codes(?string $trackingCodeString): array {
if (is_null($trackingCodeString)) {
return [];
}
$trackingCodeArray = explode(',', $trackingCodeString);
$trackingCodeArray = array_map('strtoupper', $trackingCodeArray);
$trackingCodeArray = array_map('trim', $trackingCodeArray);
Expand Down
4 changes: 2 additions & 2 deletions website/app/GeoKrety/Service/Xml/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public function __construct(bool $streamXML = false, ?string $compress = self::C
// No output buffer while streaming
ob_end_flush();
ob_implicit_flush();
if (strtolower($compress) === self::COMPRESSION_BZIP2) {
if (strtolower($compress ?? '') === self::COMPRESSION_BZIP2) {
header('Content-Disposition: attachment; filename='.$filename.'.bz2');
header('Content-type: application/x-bzip2');
stream_filter_append($this->stream, 'bzip2.compress', STREAM_FILTER_WRITE);
} elseif (strtolower($compress) === self::COMPRESSION_GZIP) {
} elseif (strtolower($compress ?? '') === self::COMPRESSION_GZIP) {
// Unfortunately, gzip require header and trailer, which are not handled by stream-filter, so
// we need to rely on temporary files :( The header is easy to implement, however, trailer require
// checksum and length or the **original** data, which is not stored in the filter (implementing a
Expand Down
4 changes: 2 additions & 2 deletions website/app/GeoKrety/Service/Xml/GeokretyExport2.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public function addGeokret(\GeoKrety\Model\Geokret &$geokret) {

if ($geokret->owner) {
$xml->writeAttribute('owner_id', $geokret->owner);
$xml->writeAttribute('ownername', $geokret->owner_username);
$xml->writeAttribute('ownername', $geokret->owner_username ?? '');
}
if ($geokret->holder) {
$xml->writeAttribute('holder_id', $geokret->holder);
$xml->writeAttribute('holdername', $geokret->holder_username);
$xml->writeAttribute('holdername', $geokret->holder_username ?? '');
}
$xml->writeAttribute('dist', $geokret->distance);
if (!is_null($geokret->position)) {
Expand Down

0 comments on commit 022fada

Please sign in to comment.