Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make plugin Drupal version aware to fix Maintenance Mode for Drupal 8+ #11

Open
christopher-hopper opened this issue May 3, 2018 · 2 comments

Comments

@christopher-hopper
Copy link

Problem / Motivation

Some common Drupal / Drush tasks have different implementations when moving to a new Major Drupal version. The best example I can give is this:

# Drupal 7: Enable maintenance mode
drush variable-set maintenance_mode 1

# Drupal 8: Enable maintenance mode
drush state-set system.maintenance_mode 1

Suggested Solutions

Have this robo task plugin for drush be aware of the Drupal version by inspecting it and storing it. Then for certain tasks that differ depending on the version, do a SEMVER check like:

<?php


    /**
     * Enables the maintenance mode.
     *
     * @return $this
     */
    public function maintenanceOn()
    {
        $this->printTaskInfo('Turn maintenance mode on');

        // Implement a version lookup method.
        $version = $this->getDrupalCoreVersion();

        if (\Composer\Semver\Semver::satisfies($version, '<8.0')) {
            return $this->drush('variable-set --exact maintenance_mode 1');
        }
        if (\Composer\Semver\Semver::satisfies($version, '>=8.0')) {
            return $this->drush('state-set --exact maintenance_mode 1');
        }
    }

@boedah
Copy link
Owner

boedah commented Dec 11, 2018

Thx @christopher-hopper.
That seems like a nice addition.

  • which other methods in robo-drush depend on the Drupal version?
  • how to get the Drupal version? (I think best would be to parse it out of a drush st call)
  • maybe add the possibility to force the Drupal version in robo-drush to avoid the calls to fetch the Drupal version of the site?
  • are you interested in providing a PR?

@tassilogroeper
Copy link

A simple but efficient way would be to simple use \Drupal::VERSION or \Drupal::CORE_COMPATIBILITY. Inside a Try catch block and defaults to drupal-7, since in Drupal 7 this Class does not exist... Put into the __construct and you are good to go.

Only question is, are you willing to go down that road, since there is actually no explicit dependency to Drupal in Drush, Robo nor this Task.

https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/constant/Drupal%3A%3ACORE_COMPATIBILITY/8.8.x
https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/constant/Drupal%3A%3AVERSION/8.8.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants