Introduction
As announced here, API Connect Developer Portal will be upgrading to Drupal 10 in API Connect v10.0.5.3.
If your Developer Portal contains custom modules and themes written by yourself or downloaded from elsewhere, you will need to ensure they are Drupal 10 compatible prior to upgrading. This will aid towards a seamless APIC upgrade experience. Luckily there is a module called ‘Upgrade Status’ available to download which provides a wealth of information on your modules and themes and how they can be made Drupal 10 compatible. You can download that here https://www.drupal.org/project/upgrade_status.
If you are unsure what custom modules and themes you have installed on your Developer Portal, please refer to https://community.ibm.com/community/user/integration/blogs/bhavnit-patel/2023/03/23/apic-devportal-what-custom-modules-and-themes before continuing.
Note: Before we start, consider observing what custom modules and themes you have installed and if you even use them. You can save yourself a lot of time by simply removing custom modules and themes that you are not using.
Assuming there are still custom modules and themes you have left that need to be Drupal 10 compatible, let’s move on. Log into your Developer Portal as the administrator and install the Upgrade Status module. Refer to https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=extend-installing-custom-modules on installing modules.
Installing the Upgrade Status module
Once Upgrade Status is installed, navigate to /admin/reports/upgrade-status and you will see something like below:
The ‘DRUPAL CORE AND HOSTING ENVIRONMENT’ section can be ignored. This is managed by APIC and will be resolved for you when you upgrade. However as mentioned in their requirements, your custom modules and themes must be PHP 8.1 compatible prior to upgrading and it is your responsibility to do this. We will provide further guidance on this soon.
Moving down further you will see a list of projects which Upgrade Status believes are not compatible with Drupal 10. They are categorised into sections such as ‘REMOVE’, ‘UPDATE’, ‘COLLABORATE WITH MAINTAINERS’ etc. You don’t need to worry about the modules and themes that you have not manually created or installed yourself. The modules and themes installed within the default Developer Portal will be Drupal 10 compatible when you upgrade APIC:
If you find your custom modules and themes on this page, you can scan them to reveal what changes are required to make them Drupal 10 compatible. Below I have provided an example of scanning a custom module we have installed named ‘custom_icons’:
Select your custom modules and themes and then at the bottom of the page select ‘Scan selected’. Once completed, if your custom module or theme requires changes, you will see a link on the row of them.
Note: In order for Upgrade Status to identify all of the Drupal 10 compatibility issues in your custom modules and themes, you must have them enabled prior to scanning it.
Click on “Export as HTML” to see a clean view:
Updating your module to be Drupal 10 compatible
We’ll use this module as an example to demonstrate how you can read the report and fix your code to be compatible with Drupal 10. Firstly, the report mentions that drupal_get_path() is deprecated. We’ll change our code to use the newer function getPath() which is extension type-specific:
The next change is to add the new version into the “info.yml” file. Drupal/Core/Extension/ExtensionList is still present in Drupal 8 and Drupal 9, so we can keep those and simply add on support for Drupal 10. We should also bump the version number when making a new change to our module:
Import your module into your Developer Portal
Now that we have fixed our module, we can import it into our Developer Portal.
Import using the Developer Portal Toolkit CLI
We can import our module using the Developer Portal Toolkit CLI :
❯ apic login -s $SERVER -r provider/default-idp-2 -u steve
Warning: Using default toolkit credentials.
Enter your API Connect credentials
Password?
Logged into api.fyre-ci-134466-master.fyre.ibm.com successfully
❯ apic -s $SERVER -m portaladmin custom-module:create-import -o ibm -c api-connect-catalog-2 /tmp/custom_icons.zip
Loading File (Large files may take a while)...
201 CREATED - Task ID: wp5fhmm9l74pmkw1
Response Code - 202:
Message(s) -
The status of this task is: QUEUED
Response Code - 202:
Message(s) -
The status of this task is: RUNNING
Response Code - 200:
Message(s) -
2023-02-27 14:39:38: CLI task (custom_module:import) starting.
2023-02-27 14:39:40: Deleting existing custom module /var/aegir/platforms/devportal-9.x-10.0.5.2-20230105-1720/sites/ibm.api-connect-catalog-2.portal.fyre-ci-134466-master.fyre.ibm.com/modules/custom_icons
2023-02-27 14:39:40: Importing custom module custom_icons
2023-02-27 14:40:25: CLI task (custom_module:import) completed successfully.
See https://www.ibm.com/docs/en/api-connect/10.0.5.x?topic=tool-overview-developer-portal-command-line on using the Developer Portal CLI and all the other features it offers.
Import via the Developer Portal UI
Alternatively you can import your updated module by installing it again via the Developer Portal UI (see https://www.ibm.com/docs/en/api-connect/10.0.5.x_lts?topic=extend-installing-custom-modules).
Verifying your module is Drupal 10 compatible
Our updated module has now been imported into our Developer Portal. Come back to the Upgrade Status report page to rescan the module. Once it is Drupal 10 compatible it will now appear at the bottom of the page:
Success! Our project is now Drupal 10 compatible.
Conclusion
You have just read how you can utilise the Upgrade Status module to identify and fix Drupal 10 compatibility problems with your custom modules and themes. This may not cover everything you need to be ready for Drupal 10. As mentioned above, Drupal 10 requires PHP 8.1 and therefore you may need to change your custom modules and themes to support this. Moving forward we advise that you always keep your custom modules and themes up to date, and remove deprecated code within your own written custom modules and themes. This takes the pain away when you need to perform a major Drupal upgrade.
Further Reading
API Connect Drupal 10 announcement: https://community.ibm.com/community/user/integration/blogs/anne-redwood1/2023/02/13/apic-developer-portal-drupal-10
#portal
#developerportal
#APIConnect
#portalcli#drupal