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

Bug: About display ages #6847

Closed
goodst8114 opened this issue Feb 9, 2024 · 2 comments · Fixed by #6860
Closed

Bug: About display ages #6847

goodst8114 opened this issue Feb 9, 2024 · 2 comments · Fixed by #6860
Labels

Comments

@goodst8114
Copy link

  • ChurchCRM version: 5.5.0
  • PHP version the server running: PHP8.1.17
  • DB Server and Version the server is running: MariaDB 10.4.21

1707465599159

When I check "Hide Age," the following error message appears in the "Person Profile":
Fatal error: Uncaught ArgumentCountError: 3 arguments are required, 2 given in C:\xampp\htdocs\prm\ChurchCRM\model\ChurchCRM\Person.php:654 Stack trace: #0 C:\xampp\htdocs\prm\ChurchCRM\model\ChurchCRM\Person.php(654): sprintf('%d\xE6\xAD\xB2\xE5\xA4\xA7\nPlural...', 32) #1 C:\xampp\htdocs\prm\PersonView.php(307): ChurchCRM\model\ChurchCRM\Person->getAge() #2 {main} thrown in C:\xampp\htdocs\prm\ChurchCRM\model\ChurchCRM\Person.php on line 654

@goodst8114 goodst8114 added the bug label Feb 9, 2024
@respencer
Copy link
Contributor

Hi @goodst8114,

Can you please put the Fatal error in a code block so it's more readable?

Tested myself and got no error, so will need further testing.

  • ChurchCRM version: 5.5.0
  • PHP version the server is running: PHP 8.2.15
  • DB Server and Version the server is running: MariaDB 10.3.39

@goodst8114
Copy link
Author

Hi @respencer

public function getAge(?\DateTimeInterface $now = null): string
{
$birthDate = $this->getBirthDate();

    if (!$birthDate instanceof \DateTimeImmutable || $this->hideAge()) {
        return false;
    }
    if (!$now instanceof \DateTimeInterface) {
        $now = new \DateTimeImmutable('today');
    }
    $age = date_diff($now, $birthDate);

    if ($age->y < 1) {
        return sprintf(ngettext('%d month old', '%d months old', $age->m), $age->m);
    }

    return sprintf(ngettext('%d year old', '%d years old', $age->y), $age->y);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants