Problem/Motivation

The system_maintenance migration lists:

source:
  plugin: variable
  variables:
    - site_offline_message
  source_module: system

But site_offline_message hasn't been in use since #201415: Add permission to access site in maintenance mode, which was committed over a decade ago in https://git.drupalcode.org/project/drupal/commit/a9762cd3bf93ac8bbcafec2... 😬

Proposed resolution

Change it to:

source:
  plugin: variable
  variables:
    - maintenance_mode_message
  source_module: system

Remove the variable 'site_offline_message' from the d7 fixture and keep the existing 'maintenance_mode_message', which has the same text so there will be no changes to the existing migration test.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Status: Active » Needs review
FileSize
592 bytes

Discovered & fixed this together with @gabesullice.

Status: Needs review » Needs work

The last submitted patch, 3: 3096676-2.patch, failed testing. View results

quietone’s picture

Issue tags: +DrupalSouth 2019

The d7 fixture has a 'site_offline_message' and a 'maintenance_mode_message'. I asked larowlan about this and he thought the site_offline_message is D6 only. And he confirmed this later and posted this in slack

@quietone confirming that site_offline_message is a D6 thing, check update_fix_d7_requirements in D7, this runs at the start of updating from Drupal 6 to Drupal 7 and does this:

// Rename 'site_offline_message' variable to 'maintenance_mode_message'
    // and 'site_offline' variable to 'maintenance_mode'.
    // Old variable is removed in update for system.module, see
    // system_update_7072().
    if ($message = variable_get('site_offline_message', NULL)) {
      variable_set('maintenance_mode_message', $message);

So, ideally we need to remove system_maintenance.yml and create a d6_system_maintenance.yml and a d7_system_maintenance.yml but we don't yet have a way to deprecate migration ymls.

quietone’s picture

Status: Needs work » Needs review
FileSize
3.33 KB

So a d6 and d7 version of the system_maintenance migration is needed. This patch does that but there is still the problem of deprecating system_maintenance.yml.

Wim Leers’s picture

Hm … tricky!

I think that what you're saying is that any existing migration that is referencing the system_maintenance migration should continue to work as-is. But it should not be discovered automatically anymore.

We could then also remove all migration tags from the system_maintenance migration, and instead let the D6 and D7 successors be discovered by the Drupal 6 and Drupal 7 tags respectively instead?

Wim Leers’s picture

RE: deprecating migrations: #3039240: Create a way to declare a plugin as deprecated seems to be the relevant issue.

mikelutz’s picture

Title: system_maintenance migration has been wrong for a decade :D » system_maintenance migrations uses incorrect maintenance mode variable in Drupal 7 migrations
mikelutz’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

We need to explicitly test that the message is migrated.

quietone’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

These messages are already tested in d6/MigrateSystemConfigurationTest and d7/MigrateSystemConfigurationTest. The text of the messages didn't not change so no change was needed to the tests.

mikelutz’s picture

Status: Needs review » Reviewed & tested by the community

My mistake. So the migration was wrong, but the fixture was also wrong, and unfortunatly, in this business two wrongs can definitely make a right... :-(

No real way to add a failing test in this case, as we need to assume the fixture is right.'

Thanks for pointing that out. RTBC

quietone’s picture

Issue summary: View changes

Updated the IS to explain why the test didn't change.

alexpott’s picture

Version: 8.9.x-dev » 8.8.x-dev
Status: Reviewed & tested by the community » Needs review

At the moment this patch removes core/modules/system/migrations/system_maintenance.yml - can we actually do that and preserve BC? As far as I know most people use migrate plus which copies such templates to config therefore won't be affected.

I looked at #3039240: Create a way to declare a plugin as deprecated and I was wondering where the discussion of the use of deprecating migrations is?

heddn’s picture

Could we add a test where we run a migration with the template, then remove it and see what happens when we try to rerun the migration again? Could be manual or automated testing.

DamienMcKenna’s picture

Would renaming the yml files run afoul of the BC standard and require waiting for #3039240: Create a way to declare a plugin as deprecated?

mikelutz’s picture

Technically the files can be renamed, it's the plugin ids that we can't remove. If someone is expecting a migration plugin_id to exist, and it disappears then that's a bc break. #3039240: Create a way to declare a plugin as deprecated is an attempt to let us find a way to remove them during major version updates.

mikelutz’s picture

Assigned: Unassigned » mikelutz
Status: Needs review » Needs work

For now, we do need to preserve the system_maintenance migration somehow or postpone on #3039240: Create a way to declare a plugin as deprecated, but I think we can refactor, given that 3039240 would require us to keep it in a deprecated state anyway. I'll put this on my task list.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Status: Needs work » Needs review
FileSize
3.18 KB
1.28 KB

Refactoring so the deprecation can be avoided. This works if 'site_offline_message' and 'maintenance_mode_message' are mutually exclusive. If they both exist in a database then 'site_offline_message' (from Drupal 6) will be used.

quietone’s picture

Assigned: mikelutz » Unassigned

Ready for review.

heddn’s picture

I like it. Not sure about the need for explicit test coverage or not.

quietone’s picture

I was hoping that wouldn't be necessary but since you asked I have altered the existing test. What this does is add the Drupal 6 variable name to the Drupal 7 text fixture, thus verifying that if both exist in a Drupal 7 site for some reason then the correct message is migrated. I realize that this patch removes the d6 variable from the d7 fixture and the test adds it back in. That keeps the d7 fixture 'correct' and makes it easier to see what is being tested. I doubt that a d6 site would have a d7 variable name so only the d7 test is modified. I think this is sufficient and avoids creating a new test.

Oh, I changed the order of the variables in the callback so that the d7 one is the default. And then did so in the source plugin so they are in alpha order.

quietone’s picture

Version: 8.9.x-dev » 9.2.x-dev

Updating version

heddn’s picture

Status: Needs review » Reviewed & tested by the community

All feedback addressed.

catch’s picture

  • catch committed c494a61 on 9.2.x
    Issue #3096676 by quietone, Wim Leers, mikelutz, heddn, gabesullice,...

  • catch committed 3917a3f on 9.1.x
    Issue #3096676 by quietone, Wim Leers, mikelutz, heddn, gabesullice,...
catch’s picture

Version: 9.2.x-dev » 9.1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.