Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
A small improvement to the output text here can go a long way to determine why a migration failed on the source side. Add a common reason why this would fail Is the module enabled?
Comment | File | Size | Author |
---|---|---|---|
#42 | interdiff-2549801-42.txt | 1.13 KB | balagan |
#42 | MissingException-2549801-42.patch | 3.78 KB | balagan |
#36 | interdiff-2549801-28-36.txt | 1.44 KB | quietone |
#36 | 2549801-36.patch | 3.71 KB | quietone |
#28 | interdiff-2549801-17-28.txt | 5.65 KB | quietone |
Comments
Comment #2
lostkangaroo CreditAttribution: lostkangaroo commentedComment #3
quietone CreditAttribution: quietone commentedNice. I do like getting an idea of how to fix the problem but I think a statement is better than a question. Still, I'm just not sure what is 'proper' language to use here.
My current favorite is something like this:
"Migration d6_contact_settings did not meet the requirements. Missing source provider. Ensure the 'contact' module is installed"
Comment #4
lostkangaroo CreditAttribution: lostkangaroo at APQC commentedI'll go for that, my only concern is that version checking also happens. So we would need to add that information if available.
Migration d6_contact_settings did not meet the requirements. Missing source provider. Ensure the 'contact' module with minimum version x.x is enabled.
That should work since "with minimum version x.x" removed is the same as #3. Not sure how translations would handle this one or if it matters.
Comment #5
quietone CreditAttribution: quietone commentedSomething like this?
Comment #8
phenaproximaComment #9
neclimdulLooks good!
Unfortunately that failure means we can't use that for our tests. Writing an explicit tests shouldn't be a big deal though.
Comment #10
phenaproximaI'd maybe remove the words "Missing source provider". It's a strange way of saying "module not installed". What's also unclear is that the module is missing from the source database rather than the destination. Maybe something like "Enable the contact module in your source database"?
Comment #11
mikeryanWell, the reason the "source provider" is missing is simply because it's not being used in the source site - I think telling them to enable a module they don't need is counter-productive. I'd argue against making suggestions and just tell what the situation - "The module @provider_name is not enabled in the source database" or something like that.
Comment #12
phenaproximaYeah, that's fine with me -- I'm merely against alien terminology like "source provider" to refer to a Drupal module.
Comment #13
neclimdulSure ok, all valid points.
I tried to come up with a better one but after I fiddled with it I realized I'd word for word written what Mike wrote in #11. Only thing I might change is "database" to "site" since people tend to think of modules being enabled on a site not in the database but I'm sort of just coloring the bikeshed there.
Comment #14
pingers CreditAttribution: pingers at University of Adelaide commentedI've made the string change, but needs tests...
Comment #15
quietone CreditAttribution: quietone commentedFor the tests, it seems that pluginDefinition['requirements_met'], pluginDefinition['source_provider'], and pluginDefinition['minimum_schema_version'] need to be initialized. But I'm not sure how to do that.
Comment #16
phenaproxima@quietone: In a test, you can pass the plugin definition directly to the plugin's constructor. The first three arguments to any plugin are the configuration, plugin ID, and plugin definition.
Comment #17
quietone CreditAttribution: quietone commented@phenapromixa, worked on using a kernel test as you suggested, but couldn't instantiate the plugin because it's abstract. So, I decided to revisit using a Unit test and fixed my previous errors. But is this the right place or should this test be a kernel test?
Also, there is a unit test Drupal6SqlBaseTest.php but not one for D7. Shouldn't there be one for D7? But then the tests in Drupal6SqlBaseTest could be used for both, they aren't D6 specific. Unless I am missing something.
Comment #18
martins.kajins CreditAttribution: martins.kajins at Wunder commentedComment #19
martins.kajins CreditAttribution: martins.kajins at Wunder commentedLocally patch applied.
I tested and there were few fails.
Comment #21
martins.kajins CreditAttribution: martins.kajins at Wunder commentedMy previous comment was about patch #17
Comment #22
phenaproximaI hate to do this...but the file hash is unchanged, so if you want to disable Contact in the D6 dump, you need to do it using Drupal 6.
That said, it's not necessary to change the dump files in any way if you're writing a unit test, because unit tests do not use the dump files. So this change should be reverted.
This property is not needed -- see the next comment.
There's not much point to this setUp() method -- the plugin is fully created in testCheckRequirements() anyway. The whole method can be removed, along with the $base property.
Not sure why this is defined as its own variable, because it's only used once when instantiating the plugin.
Should be getMock().
This should not pass $this->migrationConfiguration. The plugin's $configuration parameter refers to plugin-specific configuration, not migration configuration. (Remember, the migration is already passed in as the fourth argument :) An empty array will work here.
Not sure why there is a wrapper around checkRequirements(), which is a public method to begin with.
None of these are ever called by the test, so I don't think we need them. It's OK for TestDrupalSqlBase to be empty.
Comment #23
quietone CreditAttribution: quietone commentedI have not yet addressed all the issues in #22.
#5. Can't figure out how to use getMock.
#8. Removing any of those methods in a fatal error. I used Drupal6SqlBaseTest.php as an example.
HP Fatal error: Class Drupal\Tests\migrate_drupal\Unit\source\TestDrupalSqlBase contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Drupal\migrate\Plugin\MigrateSourceInterface::fields) in /opt/sites/md8/core/modules/migrate_drupal/tests/src/Unit/source/DrupalSqlBaseTest.php on line 81
PHP Stack trace:
Going for a walk ... in the rain.
Comment #25
phenaproximaIt looks like you had it exactly right; it just needs to be getMock() and not getmock().
To extend the abstract class, you only need to implement fields(), which in this case can return an empty array. As far as I can tell there is no need to override the protected methods as well unless you're planning to call them directly from outside the class.
Comment #26
quietone CreditAttribution: quietone commentedI seem to have forgotten about this issue. But here's a new patch which I think addresses all of phenaproxima's issues in 22.
Comment #28
quietone CreditAttribution: quietone commentedOops, that was the wrong patch.
Comment #29
benjy CreditAttribution: benjy at PreviousNext commentedLets just use a bit of reflection to set the database rather than an entire mock class? Unless the getIds() call is needed to return empty as well, that would probably justify leaving the test class.
Comment #31
benjy CreditAttribution: benjy at PreviousNext commentedNW for 29
Comment #32
scuba_flyI looked at this but that would mean changing the DrupalSqlBase class to set a database?
Comment #33
scuba_flyAs discussed with penyaskito and benjy we would have to change the DrupalSqlBase class not to be abstract anymore in other to use reflection. So we decided to would be better to let the extra TestDrupalSqlBase to be there.
I'm going to test the patch now when I'm done I'll set it to be RTBC
Comment #34
scuba_flyI tested this with a Drupal 7 to 8 Migration using the action module as source.
After applying the patch I get the message "The module action is not enabled in the source site. source_provider: action." when trying to run the migration.
Thanks to penyaskito for mentoring me on the drupal dev days Milan.
So it works! RTBC
Comment #35
alexpottNot needed any more
Should have an @covers and best practices have changed here... https://thephp.cc/news/2016/02/questioning-phpunit-best-practices
Needs a new line in-between
Comment #36
quietone CreditAttribution: quietone commented1-3. Fixed
Also, removed the summary line adding an @coversDefaultClass based on this
"Only PHPUnit tests MAY skip the PHPDoc summary line if their PHPDoc specifies a @coversDefaultClass. See PHPUnit @coversDefaultClass annotation documentation" on https://www.drupal.org/node/2116043. Hope that is correct.
Comment #37
quietone CreditAttribution: quietone commented@scuba_fly, sorry! I didn't check to see if this was assigned.
Comment #38
scuba_fly@quietone No problem. I'll try to review your new patch if I can later. But busy at te moment so Unassigning it for now.
Comment #39
penyaskitoCould we use RequirementsException::class instead of the class name as a string?
Could we include the full exception message, or at least include the text changed in this issue and the missing source_provider module name so we ensure that it's shown to users?
Thanks for working on this!
Comment #40
balagan CreditAttribution: balagan commentedComment #41
balagan CreditAttribution: balagan commentedI note it here just in case I don't succeed with the patch, that there is a typo in it too: 'is not enable' should be 'is not enabled'.
Comment #42
balagan CreditAttribution: balagan commentedAttached a patch and interdiff according to penyaskito's suggestions.
Comment #43
balagan CreditAttribution: balagan commentedComment #44
neclimdulIs there a standards change discussing and documenting this change other then the blog post? I'd like to discuss it since we're pretty well committed to the annotation.
Comment #45
neclimdulPrevious comment isn't really relevant to getting this committed as the test works the same way either way. +1, this is long overdue.
Comment #48
quietone CreditAttribution: quietone commentedTests are passing. Back to RTBC.
Comment #50
quietone CreditAttribution: quietone commentedNo, tests are passing. Back to RTBC.
Comment #51
alexpottCommitted and pushed 7d6e615 to 8.3.x and a3c47f3 to 8.2.x. Thanks!
The array thing
['source_provider' => $this->pluginDefinition['source_provider']
is just not needed. let's remove that dead code here. Fixed on commit.Comment #54
neclimdulI had assumed that was left to provide a way to explicitly check the missing requirement(s) when catching the exception which is why it was left.
Comment #55
neclimdulThis is fine. I opened a follow up issue so we can discuss the addition of a test for the case. #2790111: DrupalSqlBase doesn't include missing source in requirements exception