-
Notifications
You must be signed in to change notification settings - Fork 6
d9 compatiblity #23
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
Open
manuel-work
wants to merge
22
commits into
8.x-1.x
Choose a base branch
from
test-drush
base: 8.x-1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
d9 compatiblity #23
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
aa2612b
Issue #3017760: initial auto-generation of drush 9 commands
malcomio 4dbc823
fix coding standards issues mentioned by codesniffer
malcomio e55727b
basic conversion of dbsa command
malcomio c084954
basic conversion of dbsg command
malcomio a6d5995
coding standards fixes
malcomio e008514
coding standards fixes
malcomio faf216e
get options from I/O
malcomio 1b3157c
add drush back in dev dependencies
malcomio 495b9e0
make file optional in analyze command
malcomio ddaa339
Merge pull request #9 from malcomio/drush9
manuee e6ef174
#3017760 - Support drush 9 - Address review comments from #9
vijaycs85 8a3196f
Docblock update suggested by @manuee
manuee 59081d1
Docblock update.
manuee 7fc7771
Merge pull request #12 from vijaycs85/3017760
manuee 5e2aec7
Bumped Drush to 10.2.2 + Upgraded merge-yaml to 2.0.0-alpha1
suzymasri cfee75e
Testing Drush
suzymasri 7e92249
Removed UNISH_DRUPAL_MAJOR_VERSION
suzymasri 7762c40
Teesting autoload real path
suzymasri 3a94cec
Changed MergeYaml version
suzymasri 8a535be
Unwanted file
suzymasri 0b12305
Modified .travis.yml
suzymasri 57aaab8
D9 deprecation fixes
suzymasri File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -4,12 +4,13 @@ | |||
language: php | ||||
|
||||
php: | ||||
- 7.1 | ||||
- 7.3 | ||||
|
||||
matrix: | ||||
fast_finish: true | ||||
|
||||
dist: trusty | ||||
services: | ||||
- mysql | ||||
|
||||
# Skip tests for tags. | ||||
if: tag IS blank | ||||
|
@@ -30,11 +31,14 @@ before_install: | |||
install: | ||||
- composer global require drupal/coder --prefer-dist -vvv || exit 1 | ||||
- phpcs --config-set installed_paths "$COMPOSER_VENDOR_PATH/drupal/coder/coder_sniffer" | ||||
- phpenv config-add travis.php.ini | ||||
- php -ini | grep memory_limit | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can probably go.
Suggested change
|
||||
|
||||
before_script: | ||||
- composer install -vvv | ||||
- cd "$TRAVIS_BUILD_DIR/vendor/drush/drush"; composer install | ||||
|
||||
- cd "$TRAVIS_BUILD_DIR/vendor/"; rm -rf drush; git clone --branch 10.2.2 https://github.com/drush-ops/drush.git drush | ||||
- cd "$TRAVIS_BUILD_DIR/vendor/drush"; composer install | ||||
|
||||
script: | ||||
- phpcs --standard=Drupal --ignore=vendor/* --warning-severity=0 . | ||||
- php "$TRAVIS_BUILD_DIR/vendor/drush/drush/vendor/bin/phpunit" --configuration "$TRAVIS_BUILD_DIR/vendor/drush/drush/tests" "$TRAVIS_BUILD_DIR/drush/tests" | ||||
- php "$TRAVIS_BUILD_DIR/vendor/drush/vendor/bin/phpunit" --configuration "$TRAVIS_BUILD_DIR/vendor/drush/tests" "$TRAVIS_BUILD_DIR/drush/tests" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: 'Database Sanitize' | ||
type: module | ||
description: 'Provides drush commands for yaml sanitization files checks and generation.' | ||
core: 8.x | ||
core_version_requirement: ^8 || ^9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
services: | ||
database_sanitize.commands: | ||
class: \Drupal\database_sanitize\Commands\DatabaseSanitizeCommands | ||
arguments: ['@database_sanitize'] | ||
tags: | ||
- { name: drush.command } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
<?php | ||
|
||
namespace Drupal\database_sanitize\Commands; | ||
|
||
use Drupal\database_sanitize\DatabaseSanitize; | ||
use Drush\Commands\DrushCommands; | ||
|
||
/** | ||
* Drush commands for Database Sanitize. | ||
*/ | ||
class DatabaseSanitizeCommands extends DrushCommands { | ||
|
||
/** | ||
* The sanitizer service instance. | ||
* | ||
* @var \Drupal\database_sanitize\DatabaseSanitize | ||
*/ | ||
protected $sanitizer; | ||
|
||
/** | ||
* DatabaseSanitizeCommands constructor. | ||
* | ||
* @param \Drupal\database_sanitize\DatabaseSanitize $sanitizer | ||
*/ | ||
public function __construct(DatabaseSanitize $sanitizer) { | ||
$this->sanitizer = $sanitizer; | ||
} | ||
|
||
/** | ||
* Analyze existing yml files. | ||
* | ||
* Compares existing database.sanitize.yml files on the site installation | ||
* against existing database tables. | ||
* | ||
* @param array $options | ||
* An associative array of options whose values come from cli, aliases, | ||
* config, etc. | ||
* | ||
* @option file | ||
* The full path to a sanitize YML file. | ||
* @option list | ||
* List the table names. | ||
* | ||
* @command db:sanitize-analyze | ||
* @aliases dbsa,db-sanitize-analyze | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function analyze(array $options = ['file' => NULL, 'list' => NULL]) { | ||
$file = $options['file']; | ||
if (!empty($file) && !file_exists($file)) { | ||
throw new \Exception(dt('File @file does not exist', ['@file' => $file])); | ||
} | ||
|
||
$missing_tables = $this->sanitizer->getUnspecifiedTables($file); | ||
|
||
if (!$missing_tables) { | ||
\Drupal::logger('database_sanitize')->log('success', (dt('All database tables are already specified in sanitize YML files'))); | ||
return; | ||
} | ||
|
||
\Drupal::logger('database_sanitize')->log('warning', (dt('There are @count tables not defined on sanitize YML files', ['@count' => count($missing_tables)]))); | ||
|
||
if (!empty($options['list'])) { | ||
\Drupal::logger('database_sanitize')->log('warning', (implode("\n", $missing_tables))); | ||
} | ||
} | ||
|
||
/** | ||
* Generates Sanitization entries for tables not specified on sanitize YML files.. | ||
* | ||
* @param array $options | ||
* An associative array of options whose values come from cli, aliases, | ||
* config, etc. | ||
* | ||
* @option file | ||
* The full path to a sanitize YML file. | ||
* @option machine-name | ||
* The machine name to export the tables under. | ||
* | ||
* @command db:sanitize-generate | ||
* @aliases dbsg,db-sanitize-generate | ||
* | ||
* @return Consolidation\OutputFormatters\Formatters\YamlFormatter | ||
* | ||
* @throws \Exception | ||
*/ | ||
public function generate(array $options = ['file' => NULL, 'machine-name' => NULL]) { | ||
$machine_name = $options['machine-name']; | ||
if (empty($machine_name)) { | ||
$machine_name = $this->io()->ask('Please provide the machine name to export the tables under'); | ||
} | ||
|
||
if (empty($options['file'])) { | ||
$options['file'] = $this->io()->ask('Please provide the full path to a sanitize YML file'); | ||
} | ||
|
||
$yml_file_path = $options['file']; | ||
$missing_tables = $this->sanitizer->getUnspecifiedTables($yml_file_path); | ||
if (!$missing_tables) { | ||
\Drupal::logger('database_sanitize')->log('success', (dt('All database tables are already specified in sanitize YML files'))); | ||
return []; | ||
} | ||
|
||
$content = [ | ||
'sanitize' => [ | ||
$machine_name => [], | ||
], | ||
]; | ||
foreach ($missing_tables as $table) { | ||
$content['sanitize'][$machine_name][$table] = [ | ||
'description' => "Sanitization entry for {$table}. Generated by drush db-sanitize-generate.", | ||
'query' => "TRUNCATE TABLE {$table}", | ||
]; | ||
} | ||
|
||
return $content; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
memory_limit = -1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we won't use Travis then we can remove this as well. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this file at all?