Dealing with deprecations

Поделиться
HTML-код
  • Опубликовано: 9 сен 2024

Комментарии • 10

  • @whocares2723
    @whocares2723 2 года назад +5

    For any kind of depreciations, there is always an alternative. The reason why things get deprecated and then get removed is because a lot of the features that gets deprecated are unsafe to use or too old and obsolete.

  • @sle6423
    @sle6423 2 года назад +2

    I thought deprecations and notices were distinct things, at least when it came to error reporting?

  • @garetclaborn
    @garetclaborn Год назад

    I mean many fair points presented -- howwwweeever haha.. For all the breaking changes PHP has made since the 5.6 days, we haven't got the sort of tradeoffs that would justify them at minor versions.
    Feature priority is quite mysterious.. for instance the many, many, many times hopes have been dashed with RFCs attempting to bring in operator overloading, objects as keys and proper type casting. Originally coming from other languages; I strongly think these three features should have been top priority long before any of the PSR, traits or attributes were thought of. Nothing drives me to consider porting projects more than these.
    That, and I surely wish PHP deprecation habits were more along the lines of the Khronos group's. Perhaps alternatively if it were just more predictable; such as at X.5 versions, function signature changes may occur and at X.7 versions type changes may occur. Anything more systematic would be handy.

  • @Nodsaibot
    @Nodsaibot 2 года назад +2

    yeah we dont want 1gb error logs, better to disable notices

    • @garetclaborn
      @garetclaborn Год назад

      It would be nice if there was a separate alert system.
      One thing you can do is
      $catch_deprecated = function(
      int $error_code,
      string $message,
      string $offending_file,
      int $offending_line,
      array $active_variables
      ){
      $DebugMode=false;
      static $caught = [ ];
      $alert_dir = '/srv/myproject/alerts/'.$error_code .'/';
      $log_dir = '/srv/myproject/log/'.$error_code .'/';
      if( $DebugMode ){
      file_put_contents( $log_dir . 'deprecated.log', PHP_EOL.$message.PHP_EOL, , FILE_APPEND | LOCK_EX);
      }
      if( empty( $caught[ $message ] ) ){
      $caught[ $message ] = true;
      touch( $alert_dir . 'DEPRECATED-' . $message );
      }
      };
      set_error_handler( callback: $catch_deprecated, error_levels: E_DEPRECATED );
      With this, or something very close, you end up with only a single file per error thrown unless you activate debug mode to see the full error output.

  • @bx_h23
    @bx_h23 2 года назад +1

    What chair are you using? 🔥

  • @nowieszco868
    @nowieszco868 Год назад +2

    Well, deprecations = more work for us 😅

    • @peristiloperis7789
      @peristiloperis7789 Год назад

      Not if companies start to realize that php changes can cost too much money and time. I was ok with php until it made my website useless for 20 days after an update to php 7.4.

  • @alexios4392
    @alexios4392 2 года назад +1

    I remember a lot of deprecations in WordPress code.

  • @peristiloperis7789
    @peristiloperis7789 Год назад

    From the developpers' point of view changes may be great, but they are terrible for business. A language update should not break applications, but that's exactly what PHP is doing at the moment. I'm a developper and a businessman and I will never use PHP in my projects again.