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

feat(legacy): update deprecated PHP code #2789

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

mp3butcher
Copy link
Contributor

@mp3butcher mp3butcher commented Nov 27, 2023

Description

update deprecated code. It's mergeable with master without syntax conflicts across php versions
remove deprecated((https://www.php.net/manual/fr/function.strftime.php)) and unsafe (https://cve.mitre.org/cgi-bin/cvekey.cgi?keyword=strftime) strftime syntax

@mp3butcher mp3butcher changed the title update deprecated code feat(application): update deprecated PHP Nov 27, 2023
@mp3butcher mp3butcher changed the title feat(application): update deprecated PHP feat(legacy): update deprecated PHP Nov 27, 2023
Copy link
Contributor

@paddatrapper paddatrapper left a comment

Choose a reason for hiding this comment

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

These all look reasonable. Can you please add CI runs against PHP 8.x here and fix the linting failures?

@mp3butcher
Copy link
Contributor Author

@paddatrapper Hi,
I'm not very familiar with CI but:

  • these changes does't seem to involve php version conflicts (only deprecation)
  • lint error is not clear at all. How do I debug these logs?

@paddatrapper
Copy link
Contributor

these changes does't seem to involve php version conflicts (only deprecation)

Ah, I misunderstood the purpose of this PR and thought you were adding support for PHP 8.

lint error is not clear at all. How do I debug these logs?

The failing 7.4 PHP linting CI shows diffs on formatting changes that need to be applied to your code. You can also test this locally via pre-commit. For example the following change highlights a space that needs removing:

--- /home/runner/work/libretime/libretime/legacy/application/services/MediaService.php
+++ /home/runner/work/libretime/libretime/legacy/application/services/MediaService.php
@@ -135,7 +135,7 @@
      */
     public static function areFilesStuckInPending()
     {
-        $oneHourAgo = gmdate( DEFAULT_TIMESTAMP_FORMAT, floor(hrtime(true)) - self::PENDING_FILE_TIMEOUT_SECONDS);
+        $oneHourAgo = gmdate(DEFAULT_TIMESTAMP_FORMAT, floor(hrtime(true)) - self::PENDING_FILE_TIMEOUT_SECONDS);
         self::$_pendingFiles = CcFilesQuery::create()
             ->filterByDbImportStatus(CcFiles::IMPORT_STATUS_PENDING)
             ->filterByDbUtime($oneHourAgo, Criteria::LESS_EQUAL)

@mp3butcher mp3butcher force-pushed the ubuntu22.04 branch 2 times, most recently from ac2906e to 4e509dd Compare November 28, 2023 13:05
Copy link
Contributor Author

Choose a reason for hiding this comment

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

gmdate clearly wait an int here...
my concern is microtime is used multiple times in libretime.
Do int or float is waited for these calls?
In brief, do I have to change them all to intval(microtime())?...

Copy link
Contributor

Choose a reason for hiding this comment

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

@jooola do you have any insight here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this can be subject of an other pr, as it works perfectely without further changes

@mp3butcher mp3butcher force-pushed the ubuntu22.04 branch 3 times, most recently from 24ec6ec to 831c9c5 Compare November 28, 2023 17:21
@mp3butcher mp3butcher changed the title feat(legacy): update deprecated PHP feat(legacy): update deprecated PHP code Nov 28, 2023
@mp3butcher mp3butcher changed the title feat(legacy): update deprecated PHP code feat(legacy): update deprecated PHP code forbid usage of strftime()-style date formatting (and so remove call to deprecated strftime) Nov 28, 2023
@mp3butcher mp3butcher changed the title feat(legacy): update deprecated PHP code forbid usage of strftime()-style date formatting (and so remove call to deprecated strftime) feat(legacy): update deprecated PHP code Nov 28, 2023
@mp3butcher mp3butcher force-pushed the ubuntu22.04 branch 4 times, most recently from 4f28717 to cac7f6e Compare November 30, 2023 16:14
@mp3butcher mp3butcher force-pushed the ubuntu22.04 branch 2 times, most recently from 98c65c7 to 1d85653 Compare November 30, 2023 17:11
@jooola
Copy link
Contributor

jooola commented Dec 18, 2023

There are a lot of resources in regard to the PHP 8.0 support, I think it's wise to take a look at them and use the existing work of others: #2047

@jooola
Copy link
Contributor

jooola commented Jan 13, 2024

This PR is not testable, the docker dev setup does not work out of the box when bumping the php version to 8.1.

Please make sure to fix this, so this PR is self contained.

@paddatrapper
Copy link
Contributor

I thought the point of this PR was that is isn't upgrading PHP to 8.0. Rather it's a prerequisite for that to happen later

Copy link
Contributor

@paddatrapper paddatrapper left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

codecov bot commented Feb 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (29f73e0) 70.36% compared to head (f86305c) 70.36%.

❗ Current head f86305c differs from pull request most recent head da529fe. Consider uploading reports for the commit da529fe to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2789   +/-   ##
=======================================
  Coverage   70.36%   70.36%           
=======================================
  Files         149      149           
  Lines        4033     4033           
=======================================
  Hits         2838     2838           
  Misses       1195     1195           
Flag Coverage Δ
analyzer 47.00% <100.00%> (ø)
api 93.72% <ø> (ø)
api-client 64.40% <ø> (ø)
playout 47.40% <ø> (ø)
shared 89.09% <ø> (ø)
worker 89.21% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jooola
Copy link
Contributor

jooola commented Feb 2, 2024

All the changes under /legacy/application/models/airtime must come from the Propel Library, as those files as autogenerated. See the properl-gen make target in /legacy/Makefile.

Please propose a change against the propel library and we can then update the files by regenerating them here.

Other than that, the rest looks good.

@jooola
Copy link
Contributor

jooola commented Feb 2, 2024

Maybe enabling https://www.php.net/manual/en/language.types.declarations.php#language.types.declarations.strict in our files is also a good idea?

@mp3butcher
Copy link
Contributor Author

mp3butcher commented Feb 4, 2024

i pushed a commit on libretime/propel1#2 but i'm not fixing this pr since you take over .....

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.

None yet

4 participants