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

Replace deprecated gmstrftime PHP function #12

Conversation

liverpoolfc-fan
Copy link
Contributor

gmstrftime - Warning: This function has been DEPRECATED as of PHP 8.1.0. Relying on this function is highly discouraged.

Adding a new static function to Utils.php to generate the the required Compact Date strings to send to the device.

Released under the GNU Affero General Public License (AGPL), version 3

What does this implement/fix? Explain your changes.

Adds a new function to Utils.php

public static function FormatDateUtc($ts,$format) {

and replaces calls to the deprecated gmstrftime with calls to this new function

...

Does this close any currently open issues?

No.
...

Any relevant logs, error output, etc?

...

Where has this been tested?

Server (please complete the following information):

  • OS: Rocky Linux 9
  • PHP Version: 8.1.14
  • Backend for: Zimbra
  • and Version: z-push 2.7

Smartphone (please complete the following information):

  • Device: Galaxy S21
  • OS: Android 13, One UI 5.1
  • Mail App Samsung Email
  • Version 6.1.75

gmstrftime - Warning: This function has been DEPRECATED as of PHP 8.1.0. Relying on this function is highly discouraged.

Adding a new static function to Utils.php to generate the the required Compact Date strings to send to the device.
PHP 8.0 stopped allowing empty strings to be passed to gmstrftime. This led to the previously suggested change to replace the empty string with null. Unfortunately, that change collided with the gmstrftime also accepting null as a valid input where it would return the current time formatted as requested.

This led to contacts who had empty Anniversary and Birthday fields getting their empty strings replaced by nulls, and subsequently getting passed to gmstrftime which would assign them values of the current time.

The correct behaviour for the streamer in this instance is to just return the empty string
@matidau
Copy link
Collaborator

matidau commented May 31, 2023

Thanks for the PR, will test this for a few days and then merge.

@liverpoolfc-fan
Copy link
Contributor Author

liverpoolfc-fan commented May 31, 2023 via email

Copy link
Collaborator

@matidau matidau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working great!

@matidau matidau merged commit 52f9c73 into Z-Hub:develop Jun 2, 2023
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.

Every contact is getting a Birthday and anniversary set to the time of sync to the device
2 participants