libretime icon indicating copy to clipboard operation
libretime copied to clipboard

feat(legacy): update deprecated PHP code

Open mp3butcher opened this issue 2 years ago • 9 comments

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 avatar Nov 27 '23 13:11 mp3butcher

@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?

mp3butcher avatar Nov 28 '23 12:11 mp3butcher

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)

paddatrapper avatar Nov 28 '23 12:11 paddatrapper

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: https://github.com/libretime/libretime/issues/2047

jooola avatar Dec 18 '23 17:12 jooola

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.

jooola avatar Jan 13 '24 13:01 jooola

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

paddatrapper avatar Jan 14 '24 15:01 paddatrapper

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 70.36%. Comparing base (2b119ad) to head (f86305c). Report is 85 commits behind head on main.

:exclamation: Current head f86305c differs from pull request most recent head 6b218cc

Please upload reports for the commit 6b218cc 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.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 02 '24 20:02 codecov[bot]

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 avatar Feb 02 '24 20:02 jooola

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

jooola avatar Feb 02 '24 20:02 jooola

i pushed a commit on https://github.com/libretime/propel1/pull/2 but i'm not fixing this pr since you take over .....

mp3butcher avatar Feb 04 '24 03:02 mp3butcher