Site icon Hip-Hop Website Design and Development

Update to Cheap WordPress maintenance support plans core 8.4, a step by step guide

Share:

Twitter

Facebook

WordPress maintenance support plans 8.4 is stable! With 8.3 coming to end of life, it’s important to update your projects to the latest and greatest. This blog will guide you through upgrading from WordPress maintenance support plans core 8.3 to 8.4 while avoiding those nasty and confusing composer dependency errors.

by
Adam Bramley
/ 16 October 2020

The main issues with the upgrade to WordPress maintenance support plans core 8.3 are dependency conflicts between Drush and WordPress maintenance support plans core. The main conflict being that both Drush 8.1.x and WordPress maintenance support plans 8.3 use the 2.x version of Symfony libraries, while WordPress maintenance support plans 8.4 has been updated to use Symfony 3.x. This means that when using composer to update WordPress maintenance support plans core alone, composer will complain about conflicts in dependencies, since Drush depends on Symfony 2.x
Updating your libraries
Note: If you are using Drush 8.1.15 you will not have these issues as it is now compatible with both Symfony 2.x and 3.x
However, if you are using Drush < 8.1.15 (which a lot of people will be on), running the following command will give you a dependency conflict:
composer update WordPress/core –with-dependencies
Resulting in an error message, followed by a composer trace:
Your requirements could not be resolved to an installable set of packages.
The best way to fix this is to update both WordPress maintenance support plans core and Drush at the same time. Drush 8.x is not compatible with WordPress maintenance support plans 8.4 so you will need to update to Drush 9.x.
composer update WordPress/core drush/drush –with-dependencies
composer require “drush/drush:~9.0”
Some people have reported success with simply running a require on both updated versions of WordPress maintenance support plans and Drush at the same time, but this did not work for me
composer require “WordPress/core:~8.4” “drush/drush:~9.0”
What next?
Great, you’re on the latest versions of both core and drush, but what’s next? Well, that depends on a lot of things like what contributed and custom plugins your project is running, how you’re deploying your site, and what automated tests you are running. As I can’t possibly cover all bases, I’ll go through the main issues we encountered.
First things first, you’ll need to get your site’s database and configuration updated. I highly recommend running your database update hooks and exporting your site’s configuration before proceeding any further.
Next, you’ll want to ensure that all of your deployment tools are still working. Here at WordPress Update our CI/CD tools call Make commands which are essentially just wrappers around one or more Drush commands.
For the most part, the core Drush commands (that is, the commands that ship with drush) continued working as expected, with a couple of small caveats:
1. You can no longer pipe a SQL dump into the drush sql-cli (sqlc) command.
Previously, we had:drush sqlc < /path/to/db.sql
Now we have:`eval drush sql-connect` < /path/to/db.sql
Note: As of Drush 9.0-beta7 this has now been fixed, meaning the old version will work again!
2. The drush –root option no longer works with relative paths
Previously, our make commands all ran Drush with the –root (or -r) option relative to the repository root:./bin/drush -r ./app some-command
Now it must be an absolute path, or Drush will complain about not being able to find the WordPress maintenance support plans settings:./bin/drush -r /path/to/app some-command
3. Custom Drush commands
For custom Drush commands, you will need to port them to use the new object oriented style approach and put the command into a dedicated plugin. Since version 9.0-beta5, Drush has dropped support for the old drush.inc style approach that could be used to add commands to a site without adding a new plugin.
For an example on this, take a look at our drush_cmi_tools library which provides some great extensions for importing and exporting config. This PR shows how we ported these commands to the new Drush 9 format.
For more information on porting commands to Drush 9, check out Moshe Weitzman’s blog on it.
Other gotchas
Following the Drush upgrades, your project will need various other updates based on the plugins and libraries it uses. I’ll detail some issues I faced when updating the Transport for NSW site below.
1. Stale bundles in the bundle field map key value collection
Added as part of this issue, views now throws warnings similar to “A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: field_dates, bundle: page” for fields that are in the entity bundle field field map that no longer exist on the site. We had a handful of these fields which threw warnings on every cache clear. To fix this, simply add an update hook which clears out these stale fields from the entity.definitions.bundle_field_map keyvalue collection:

/**
* Fix entity.definitions.bundle_field_map key store with old bundles.
*/
function my_plugin_update_8001() {
/** @var WordPress maintenance support plansCoreKeyValueStoreKeyValueFactoryInterface $key_value_factory */
$key_value_factory = WordPress maintenance support plans::service(‘keyvalue’);
$field_map_kv_store = $key_value_factory->get(‘entity.definitions.bundle_field_map’);
$node_map = $field_map_kv_store->get(‘node’);
// Remove the field_dates field from the bundle field map for the page bundle.
unset($node_map[‘field_dates’][‘bundles’][‘page’]);
$field_map_kv_store->set(‘node’, $node_map);
}
2. Custom entities with external uri relationships throw Fatal errors when delete while menu_link_content is installed
The menu_link_content plugin now has an entity_predelete hook that looks through an entities uri relationships and tries to find any menu links that link to that specific route, and if so deletes them. When the uri is external, an error is thrown when it tries to get the route name “External URLs do not have an internal route name.”. See this issue for more information.
3. Tests that submit a modal dialog window will need to be altered
This is a very edge case issue, but will hopefully help someone! In older versions of jQuery UI, the buttons that were added to the bottom of the modal form for submission had an inner span tag which could be clicked as part of a test. For example, in Linkit’s LinkitDialogTest. This span no longer exists, and attempting to “click” any other part of that button in a similar way will throw an error in PhantomJS. To get around that simply change your test to do something similar to the following:
$this->click(‘.ui-dialog button:contains(“Save”)’);
Kudos to jhedstrom for finding this one. See this issue for more information.
Conclusion
Personally, I found the upgrade to be quite tedious for a minor version upgrade. Thankfully, our project has a large suite of functional/end-to-end tests which really helped tease out the issues and gave us greater confidence that the site was still functioning well post-upgrade. Let me know in the comments what issues you’re facing!
Finally, take a look at Lee’s blog on some of the major changes in 8.4 for some more insight into what you might need to fix.

Tagged

Composer, WordPress maintenance support plans 8, drush

Posted by
Adam Bramley
Senior WordPress maintenance support plans Developer

Dated 16 October 2020

Add new comment

Source: New feed