Problem/Motivation

The migration of system.file settings migration (d6_system_file and d7_system_file) assumes that allow_insecure_uploads variable is always set. I checked the most recent Drupal 7 codebase and although I may be wrong, it cannot be set with core UI. file_save_upload() and file_munge_filename() are only reading this variable.

This is a follow up to #2500533: Upgrade path for System 7.x

Proposed resolution

Do not return a source row if the D7 database does not have a allow_insecure_uploads key-value pair in the variable table.

The consequence will be that nothing gets migrated, since there is nothing to migrate.

Which means that the D8|9 default will continue to be used (which is FALSE by default, and this is important for security.)

Remaining tasks

Add a test

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

huzooka created an issue. See original summary.

huzooka’s picture

Version: 9.0.x-dev » 9.1.x-dev
huzooka’s picture

quietone’s picture

If allow_insecure_uploads is not set the migration will skip the row.

Sorry, meant to add that the skip will happen in StaticMap.

Wim Leers’s picture

But a "skipped row" signals there is a row to migrate … even if there literally is nothing to migrate.

If I as an end user see "skipped row", then I think that there's something to migrate, and it was skipped … for an obscure reason:

throw new MigrateSkipRowException(sprintf("No static mapping found for '%s' and no default value provided for destination '%s'.", Variable::export($value), $destination_property));

That message very much sounds like an error/failure, not like a "oh, there's nothing to do here".

If there's nothing to do, I expect to see nothing.

huzooka’s picture

huzooka’s picture

huzooka’s picture

huzooka’s picture

Status: Needs review » Needs work

The last submitted patch, 10: core-migrate_system_file_settings-3151979-10.patch, failed testing. View results

huzooka’s picture

Status: Needs work » Needs review

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

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

#3152789: Add required variables config to Variable migrate source plugin, and if one of those are missing, return zero rows landed a month ago — no blockers left for this! Been using this for months and it works great 👍

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 10: core-migrate_system_file_settings-3151979-10.patch, failed testing. View results

ravi.shankar’s picture

Status: Needs work » Reviewed & tested by the community

Back to RTBC as per comment #14.

alexpott’s picture

It's vital that the default value of allow_insecure_uploads is FALSE. The issue summary states that it is TRUE. It took me a bit of time reading #3152789: Add required variables config to Variable migrate source plugin, and if one of those are missing, return zero rows since that is what we are using here. I'm not that keen on the name variables_required because:

  • It's not a requirement - if the variable is not there then we don't halt the migration
  • It made me do a big double take and think if this is required do we default the value to TRUE?

Anyway that's a separate issue. This works as advertised and if the variable is missing but we do need an issue summary update that details the actual solution and the correct default value.

quietone’s picture

Adding tag for the IS updated asked for in #17. Setting to NW for that.

quietone’s picture

Status: Reviewed & tested by the community » Needs work

Really set to NW

alexpott’s picture

I opened #3182891: The variables_required setting is a tricky name to discuss the naming of variables_required.

Wim Leers’s picture

Wim Leers’s picture

benjifisher’s picture

Status: Needs review » Needs work

This issue still needs an issue summary update, as stated in #17-#19.

If you update the summary, then I will review the issue (unless @quietone beats me to it).

benjifisher’s picture

Title: System file settings migration (d6_system_file and d7_system_file) assumes that allow_insecure_uploads variable is always set » System file settings migration (d6_system_file and d7_system_file) give confusing feedback when allow_insecure_uploads variable is not set

I think this title is clearer. Please revert the change if I misunderstand.

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

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Wim Leers’s picture

Issue summary: View changes
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs issue summary update

The proposed solution simply predates #3182891: The variables_required setting is a tricky name, which is why it was so confusing! 😅

Issue summary updated :)

alexpott’s picture

@Wim Leers atm if the d7 or d6 site is missing this variable what happens? Do they can a migration which sets allow_insecure_uploads to TRUE. If that's true then we need a text to prove this is fixed and this is way more important than a minor.

Wim Leers’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests
Related issues: +#2500533: Upgrade path for System 7.x

#27: Very good point. It's scary that there is not already a test for this, but now is the best time ever to add it if it does not already exist 😊👍

\Drupal\Tests\system\Kernel\Migrate\d7\MigrateSystemConfigurationTest is the existing test. It was added in [#2500533. But that is indeed testing with

->values(array(
  'name' => 'allow_insecure_uploads',
  'value' => 'i:1;',
))

We need a test where that variable does not exist in the Drupal 7 DB.

Wim Leers’s picture

Title: System file settings migration (d6_system_file and d7_system_file) give confusing feedback when allow_insecure_uploads variable is not set » Follow-up for #2500533: system file settings migration (d6_system_file and d7_system_file) give confusing feedback when allow_insecure_uploads variable is not set

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs work » Postponed (maintainer needs more info)

Question on the testing. Seems the testing mentioned in #28 moved to the aggregator module that sound right? And is the test to check if allow_insecure_uploads is not set?

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Needs review
Issue tags: -migrate-d7-d9

The migration of system.file settings migration (d6_system_file and d7_system_file) assumes that allow_insecure_uploads variable is always set.

I disagree. When the variable is not set the value on the row is NULL and, in this case, the static map plugin throws a MigrateSkipRowException. The row is not migrated and the destination is not changed.

Drush shows this as 'ignored'.

$ ddev drush mim d7_system_file
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
 [notice] Processed 1 item (0 created, 0 updated, 0 failed, 1 ignored) in 0.2 seconds (390.7/min) - done with 'd7_system_file'

In #6 this is considered a problem because the user thinks there is a row to migrate, when there wasn't.

I then applied that patch, rebuilt cache and re-ran the migration.

$ ddev drush mim d7_system_file
    0 [░░░░░░░░░░░░░░░░░░░░░░░░░░░░]
 [notice] Processed 0 items (0 created, 0 updated, 0 failed, 0 ignored) in 0 seconds (0/min) - done with 'd7_system_file'

The user no longer has an ignored row. That seems to be the desired result, a change in what the user sees. I do not see that as a bug. Currently, the migration will migrate the source value when the variable is set and will do nothing when the variable is not set. With the patch the migration will do the same thing.

This is tagged for tests. I do not think that is necessary because we would only be testing that the Variable source plugin is not returning a row. And that is already tested.

For myself, I do not see the need for this change (unless I am missing something). But what I don't like is that this would change the messages of the 2 system_file migrations. And, worse, it would make these 2 migrations behave different from the other 47 migrations that are using the Variable source plugin.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)

Seems to be back n forth if this is needed or should be done. Before reviewing is this something that could be finalized?

quietone’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Needs subsystem maintainer review

I think this needs the opinion of another migration maintainer, changing status and adding tag.

quietone’s picture

Title: Follow-up for #2500533: system file settings migration (d6_system_file and d7_system_file) give confusing feedback when allow_insecure_uploads variable is not set » Make allow_insecure_uploads a required variable in system file migrations
Issue summary: View changes
rohan-sinha’s picture

i checked the senerios and studied the older issue with patch, looks that it is already done in d6 and d7 file system, coming back to the " When the variable is not set the value on the row is NULL and, in this case, the static map plugin throws a MigrateSkipRowException " please elaborate more so I can work on this issue, thanks.

benjifisher’s picture

Status: Needs review » Closed (works as designed)
Issue tags: -Needs tests, -Needs subsystem maintainer review

The issue summary suggests that the proposed change affects the result of the migration. In fact, it only affects the messages from the migration. See #34 for detailed manual testing.

In #17, #18, and #23 we asked for an update to the issue summary to clarify this, and in #24 I changed the title for the same reason.

The summary was updated in #26, but only the "Proposed resolution" section. The "Problem/Motivation" still suggests that there is a problem with the result of the migration.

In short, it has been about 2.5 years and no one has taken the trouble to explain the point of this change in the issue summary. This issue is more of a distraction than it is worth, so I am closing it. Given the issue summary, I think that "works as designed" is appropriate.

benjifisher’s picture

I repeated some of the manual testing from #34, to confirm the "works as designed" resolution. I installed fresh Drupal 7 and Drupal 10 sites (using the latest 7.x and 10.1.x branches). I enabled the migrate_drupal_ui module and configured it, starting at /upgrade.

I did not test the proposed patch.

Here is what I got:

$ ddev drush ms d7_system_file
 ---------------- -------- ------- ---------- ------------- --------------- 
  Migration ID     Status   Total   Imported   Unprocessed   Last Imported  
 ---------------- -------- ------- ---------- ------------- --------------- 
  d7_system_file   Idle     1       0          1                            
 ---------------- -------- ------- ---------- ------------- --------------- 
$ ddev drush cget system.file allow_insecure_uploads
'system.file:allow_insecure_uploads': false

$ ddev drush mim d7_system_file
 1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
 [notice] Processed 1 item (0 created, 0 updated, 0 failed, 1 ignored) in 0.1 seconds (1188.4/min) - done with 'd7_system_file'
$ ddev drush cget system.file allow_insecure_uploads
'system.file:allow_insecure_uploads': false