WorryFree Computers   »   [go: up one dir, main page]

Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Upgrading Legacy to the Latest PHP Version

Upgrading Legacy to the Latest PHP Version

Your application runs on an old PHP version that is about to go out of support. How to upgrade without breaking the application? You will need the right tools for detecting and fixing those issues, as well as a way to verify that the application is still working correctly. In this presentation, I will share the strategy that I employed when upgrading millions of lines of untested code.

Anna Filina

May 17, 2024
Tweet

More Decks by Anna Filina

Other Decks in Programming

Transcript

  1. I Stand With Ukraine • 4M lines of code •

    As low as PHP 4 • register_globals • undefined vars • dead libraries (pre-composer) • removed extensions
  2. I Stand With Ukraine Anna Filina • Coding since 1997.

    • PHP, Java, C#, Flash, etc. • Legacy archaeology. • Test automation. • Mentoring. • Filina Consulting.
  3. I Stand With Ukraine FILE: /www/src/app/controllers/MyController.php ------------------------------------------------------------------ FOUND 1 ERROR

    AFFECTING 1 LINE ------------------------------------------------------------------ 166 | ERROR | Using 'break' outside of a loop or switch structure | | is invalid and will throw a fatal error since PHP | | 7.0 ------------------------------------------------------------------
  4. I Stand With Ukraine • php.net: docs, release notes, migration

    guides. • php-legacy-docs.zend.com • phplift.com (WIP) • exakat.readthedocs.io (compatibility rulesets) • Experimentation. • PHP source code.
  5. I Stand With Ukraine final class Php56 { public static

    function each(array &$array) { if (current($array) === false) { return false; } $key = key($array); $value = current($array); next($array); return [ 1 => $value, 'value' => $value, 0 => $key, 'key' => $key, ]; } }
  6. I Stand With Ukraine • Can we keep using libmcrypt?

    • New mcrypt extension does not behave the same.
  7. I Stand With Ukraine public function testCanDecrypt() { //... $decrypted

    = $security->decrypt($encrypted); self::assertEquals($original, $decrypted); }
  8. I Stand With Ukraine • Connection object needs to be

    available. • Connection object now a mysqli type. • Field metadata represented differently. • Different methods for unbuffered queries.
  9. I Stand With Ukraine Make changes Write tests Execute on

    legacy & upgrade First test passes on upgrade
  10. I Stand With Ukraine • Login: critical + simple •

    Reservations: critical + complex • Reporting: medium + complex • FAQ: low + simple • PDF: low + complex
  11. I Stand With Ukraine Takeaways • Write high-level tests •

    Discover issues with PHPCompatibility • Research the rest based on failed tests • Consider many solutions (don’t decide too quickly) • Make decisions that can be changed later