Problem/Motivation

Went to install this module and got

Error: Call to undefined function variable_set() in /app/web/modules/contrib/commerce_simplenews_checkout/commerce_simplenews_checkout.install on line 13 #0 /app/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(815): commerce_simplenews_checkout_install(false)
#1 /app/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(451): Drupal\Core\Extension\ModuleInstaller->invoke('commerce_simple...', 'install', Array)
#2 /app/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php(229): Drupal\Core\Extension\ModuleInstaller->doInstall(Array, Array, false)
#3 /app/vendor/drush/drush/src/Commands/pm/PmCommands.php(101): Drupal\Core\Extension\ModuleInstaller->install(Array, true)
#4 [internal function]: Drush\Commands\pm\PmCommands->install(Array, Array)
#5 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(276): call_user_func_array(Array, Array)
#6 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(212): Consolidation\AnnotatedCommand\CommandProcessor->runCommandCallback(Array, Object(Consolidation\AnnotatedCommand\CommandData))
#7 /app/vendor/consolidation/annotated-command/src/CommandProcessor.php(175): Consolidation\AnnotatedCommand\CommandProcessor->validateRunAndAlter(Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#8 /app/vendor/consolidation/annotated-command/src/AnnotatedCommand.php(389): Consolidation\AnnotatedCommand\CommandProcessor->process(Object(Symfony\Component\Console\Output\ConsoleOutput), Array, Array, Object(Consolidation\AnnotatedCommand\CommandData))
#9 /app/vendor/symfony/console/Command/Command.php(341): Consolidation\AnnotatedCommand\AnnotatedCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 /app/vendor/symfony/console/Application.php(1117): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 /app/vendor/drush/drush/src/Application.php(201): Symfony\Component\Console\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#12 /app/vendor/symfony/console/Application.php(356): Drush\Application->doRunCommand(Object(Consolidation\AnnotatedCommand\AnnotatedCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 /app/vendor/symfony/console/Application.php(195): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /app/vendor/drush/drush/src/Runtime/Runtime.php(113): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /app/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun(Array, Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /app/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run(Array)
#17 /app/vendor/bin/drush.php(119): include('/app/vendor/dru...')
#18 {main}

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

generalredneck created an issue. See original summary.

generalredneck’s picture

Status: Active » Needs review

Root cause: commerce_simplenews_checkout.install still had unported Drupal 7 code (variable_set(), variable_del(), db_query() against a {variable} table that doesn't exist in D8+) in hook_install()/hook_uninstall(). The actual pane logic is already properly ported to a modern @CommerceCheckoutPane plugin (src/Plugin/Commerce/CheckoutPane/SimplenewsSubscription.php). The .install hooks and the legacy .module file (D7 hook_commerce_checkout_pane_info(), RulesTokenEvaluator, global $user, etc.) are dead code nothing else calls, confirmed by checking that modern Commerce discovers checkout panes via plugin annotations, not that D7 hook.

Fix: MR strips the dead hook_install()/hook_uninstall() bodies. I didn't bother getting rid of the other dead code, but probably should be done.

anybody’s picture

Thank you @generalredneck nice catch!
Would you like to co-maintain the module eventually? We're not using it any more.

anybody’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

generalredneck’s picture

I was looking at that. I saw that another person had put in the issue to create the "D8" version. I'm definitely going to be using it for my business for at least the next 4 years and have my hands on both several commerce and simplenews issues.

If your game I can take the reigns as I have many minimally maintained lightly used modules under my belt.

This one needs a ci pipeline testing and cleanup.

anybody’s picture

@generalredneck thanks - I made you maintainer. Happy coding :) Yes, correct. Tests would be great.

Status: Fixed » Closed (fixed)

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