n98-magerun2 v4.8.0 released

Published by Christian Münch on

Release v4.8.0 (M2) - Background shows Hoensbroek Castle

After five month of hard work, we are proud to present the latest n98-magerun2 release. The codename of the release is Hoensbroek. The castle in the picture is next to the Hyvä company.

It’s one of the bigger releases with a lot of community contributions. We have several first time contributors. That shows us that the Magento Community is alive! 🧡

OK, let’s see what’s new …

Hyvä Support / Improved sys:info and sys:check command

We started to implement first Hyvä specific logics in n98-magerun2. The first features should assist you to find misconfigurations in your shop. So we provide informations about Hyvä in the sys:info and sys:check command. Hyvä related information are only available if the Hyvä Theme Package can be found in your shop.

sys:info Command

The sys:info command is now able to analyse the composer.json and composer.lock file of your installation. So we can display new information about installed Magento/Adobe Commerce related packages. That’s also important to provide a quick overview about important packages.

We lookup installed feature packages liks this:

  • Magento Composer Root Update Plugin
  • Magento Composer Dependency Version Audit Plugin
  • Magento Coding Standard Package
  • Magento Functional Testing Framework
  • MSI Packages
  • Sample Data Packages
  • Hyva Default Theme
  • Hyva Theme Module

Also the Admin User Count and the Composer Package Count and Search Engine are newly available.

n98-magerun2.phar sys:check in a shop with installed Hyvä Theme

It’s possible to use the information as well for scripting.

if [ $(n98-magerun2.phar sys:info "Hyva Default Theme") == "installed" ]; then 
  // do something
fi

Due to the higher number of rows in the table we added a new –sort option to the command. The table rows are then sorted by the name column in ascending order.

sys:check Command

The sys:check command got a internal refactoring. We added a internal registry to the command to hold informations which are used for several checks to speed up the process. There are still potentials to speed up the command.

If the Hyvä Theme is installed in your shop then we append a new check group “hyva” to the output.

The checks are currently covering most of the possible Hyvä setup issues:

  • Check that all required Hyvä Base Packages are installed. If not, we show the missing packages as error.
  • Check for missing GraphQL paclages which are used by Hyvä. Every missing packages is then listed as warning.
  • Check for incompatible captchas. This setting is checked for every website.
  • Check for know incompatible Magento Moduls (depending on the used Magento Version)

If everything is fine then you should see a result like this:

All Hyvä related settings can be extend by your shop config.
See bundled config for a reference.

Magerun Scripts

Environment Variable Support

To optimize automations we added support for ENV variables in Magerun Scripts.
ENV variables can be accessed like other script variables, but with a env. prefix.

Examples:

!echo ${env.PATH}
config:set foo/bar/zoz ${env.FOO_BAR_ZOZ}

Please note that variables are case-sensitive.

Script Repo Performance

If you use the script:repo command to organize Magerun Scripts then you will be happy that we increased the performance which was produced by searching the scripts in too many directories. To add additional directories you can extend the list by a custom YAML config. See bundled config.yaml for a reference.

Further Improvements

db:dump Command

During a DB dump with mysqldump we have to handle the definer of triggers, functions and procedures. That to prevent issues which you would face if the definer (user) is not available on the machine where you try to import the dump file. In previous versions of Magerun we filtered the generated SQL. Sadfully the used regex is not covering all possible conditions. The new behavior is that we replace the definer with CURRENT_USER. If no definer is defined in a SQL statement, the current user is implicit also the definer.

db:import Command

There is a new option –skip-authorization-entry-creation to skip automatic correction of missing authorization entries.

config:env:set Command

Add –input-format=json option was added. So you can store a JSON string as config in the Magento core_config_data table without any hassle.

That helps to store values where the data type matters. One example is the queue.consumers_wait_for_message option settings which has to be a integer. If the –input-format=json option is set, then we encode the value with json_encode which results in integer instead of a quoted string in the env.php file.

n98-magerun2.phar config:env:set --input-format=json queue.consumers_wait_for_messages 0

dev:console

New $dh (Development Helper) variable is available. The helper provides convenient debugging functions for common tasks. It’s also helpful to investigate issues on a production environment. The dev:console can be initialized in different Magento application areas (option –area).

dev:console – new $dh variable

Dependency Updates

Thanks to Github Dependabot service, we updated nearly every 3rd party package. That’s also important as preperation for upcoming PHP 8.0 and PHP 8.1 support. A list of upgraded vendors is listed in the Changelog.

The dev devepenencies are upgraded. So the internal tests are now compatible with PHPUnit 9 which is also the version used in the latest Magento version. The php-cs-fixer package is now on v3, because the 2.x was an outdated version.

Infrastructure / QA

To speed-up the Pull Request process, we greatly refactored the Github Actions to find possible incompatiblities. That’s super important to trust the Depedabot service. We had to fight here with some strage caching issues. If you are interested in details, feel free to review our Github Action Workflows in the .github directory of the Github repo.

One great feature of n98-magerun2 is that Magento Core Commands can be executed. Sometimes, changes in n98-magerun2 can break this feature. With this release we started to run Core Commands as part of our own test suite. It’s a kind of smoke testing. We start the Core Commands and check if the result is expected.

Changelog

  • Add: #884: Hyvä Support for sys:info and sys:check command (by Christian Münch)
  • Add: #875: Environment variable support in Magerun scripts (by Christian Münch)
  • Add: #874: Experimental MySQL SSL support (by Karsten Deubert)
  • Add: #867: PHPUnit 9 compatibility (by Karsten Deubert)
  • Add: New test suite to run core command tests (by Christian Münch)
  • Add: Magento 2.4.3 to installer and test pipeline (by Christian Münch)
  • Imp: #835: Replace the definer instead of trying to remove it (by Alin Alexandru)
  • Imp: #820: Optimize script repo performance by exclude lists (by Christian Münch)
  • Imp: #806: Implement input format json for config:env:set command (by Pieter Hoste)
  • Imp: #805: Skip authorization creation during db:import if option is specified (by Luca Gallinari)
  • Imp: #620: dev:console: Provide convenience functions to dump entities (by Alexander Menk)
  • Imp: Error handling in PDO (by Alexander Menk)
  • Imp: Updated dependencies – dev: captainhook, phpunit, vfsstream, php-cs-fixer – application: composer, symfony, phing, psysh, symfony-console-autocomplete, twig
  • Imp: Refactoring of Github Actions (Composer 2, Test Pull Requests)
  • Fix: #888: Check if file name was provided for db import command (by Torben Höhn)
  • Fix: #828: Error on db:import –drop (by Alexander Menk)
  • Fix: #824: Restore terminal mode after import (by Jeroen Vermeulen)

Upgrading

Two options:


3 Comments

Anton Fries · April 12, 2022 at 16:23

Is magerun2 already compatible with PHP 8.1? Upgrading today to Magento 2.4.4

    Christian Münch · April 12, 2022 at 20:48

    The 4.9.x is not compatible.
    The upcoming release 5.0.0 will be compatible.
    Expect the release in the next hours. Last tests are ongoing.

n98-magerun2 v4.9.0 released | magerun.net · December 22, 2021 at 11:30

[…] the big 4.8.0 release we publish the (hopefully) last release of the year. Codename of the release is Oudenaarde a […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.