Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • project/hosting
  • issue/hosting-3189572
  • issue/hosting-3216426
  • issue/hosting-3236801
  • issue/hosting-3302117
  • issue/hosting-3418689
  • issue/hosting-3418693
  • issue/hosting-3419213
  • issue/hosting-3399263
9 results
Show changes
Commits on Source (10)
before_script:
- composer require phplint/phplint
test:
image: bobey/docker-gitlab-ci-runner-php5.6
script:
- echo "Syntax checking PHP files"
- echo "For more information http://www.icosaedro.it/phplint/"
- vendor/bin/phplint ./ --exclude "vendor"
################
# DrupalCI GitLabCI template
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# With thanks to:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
################
################
# Guidelines
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
#
# However, you can modify this template if you have additional needs for your project.
################
################
# Includes
#
# Additional configuration can be provided through includes.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
#
# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml
# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
################
include:
################
# DrupalCI includes:
# As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
# View these include files at https://git.drupalcode.org/project/gitlab_templates/
################
- project: $_GITLAB_TEMPLATES_REPO
# "ref" value can be:
# - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib.
# - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates.
# - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features).
# - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates.
ref: $_GITLAB_TEMPLATES_REF
file:
# - '/includes/include.drupalci.main.yml'
# EXPERIMENTAL: For Drupal 7, remove the above line and uncomment the below.
- '/includes/include.drupalci.main-d7.yml'
- '/includes/include.drupalci.variables.yml'
- '/includes/include.drupalci.workflows.yml'
################
# Pipeline configuration variables
#
# These are the variables provided to the Run Pipeline form that a user may want to override.
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
variables:
SKIP_PHPUNIT: "1"
SKIP_PHPCS: "1"
phpcs_php:
stage: validate
needs: ["composer"]
rules:
- when: on_success
script:
- composer require --dev phpcsstandards/phpcsutils:"^1.0@dev" phpcompatibility/php-compatibility:dev-develop
- vendor/bin/phpcs --basepath=$CI_PROJECT_DIR -s $_WEB_ROOT/sites/all/modules/custom --report-junit=junit.xml --report-full --report-summary --report-source --standard=PHPCompatibility --runtime-set testVersion $PHPCS_PHP_VERSION
allow_failure: false
parallel:
matrix:
- PHPCS_PHP_VERSION: ["7.4"]
artifacts:
expose_as: junit
expire_in: 6 mos
when: always
paths:
- junit.xml
reports:
junit: junit.xml
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
# ((((((((((((, /((((((((((((* /((((((((((((/ ((((((((((((
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
......@@ -24,8 +24,12 @@ function drush_hosting_clone_pre_hosting_task($task) {
}
if (module_exists('hosting_alias')) {
$task->options['aliases'] = str_replace("\n", ",", $task->task_args['aliases']);
$task->options['redirection'] = $task->task_args['redirection'];
if (isset($task->task_args['aliases'])) {
$task->options['aliases'] = str_replace("\n", ",", $task->task_args['aliases']);
}
if (isset($task->task_args['redirection'])) {
$task->options['redirection'] = $task->task_args['redirection'];
}
}
}
}
......
......@@ -30,7 +30,9 @@ function hosting_package_instance_sync($rid, $type) {
->execute();
$map = _hosting_package_plural_map();
// phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
$args = func_get_args();
$rid = array_shift($args);
// We need to pass in $type, since there's a possibility of collision b/w a
// profile's iid, and the nid of a site or platform.
......
......@@ -646,13 +646,21 @@ function hosting_platform_validate($node, &$form) {
);
}
// Make sure the path is unique. Remote servers can't have the same path to a platform that is in use by another server.
$exists = hosting_platform_path_exists($node->publish_path);
// Make sure the path is unique. Remote servers can't have the same path to
// a platform that is in use by another server.
$exists = hosting_platform_path_exists($node->publish_path, isset($node->nid) ? $node->nid : NULL);
if ($exists) {
form_set_error('publish_path',
t('Path is already in use by platform %name. Platform paths must be unique across all servers.',
array('%name' => $result->name))
);
// Ensure that the visitor has access to view the other platform.
if (($other_node = node_load($exists->nid)) && node_access('view', $other_node)) {
form_set_error('publish_path', t('Publish path is already in use by platform: <a href="@link" target="_blank">%name</a>. Platform paths must be unique across all servers.',
array(
'%name' => $other_node->title,
'@link' => url('node/' . $exists->nid),
)));
}
else {
form_set_error('publish_path', t('Publish path is already in use by another platform. Platform paths must be unique across all servers.'));
}
}
if (is_null($node->web_server)) {
......@@ -662,21 +670,29 @@ function hosting_platform_validate($node, &$form) {
}
/**
* Determine whether a given path has already been used with an existing
* platform.
*/
function hosting_platform_path_exists($path) {
$result = db_query("SELECT n.title AS name
FROM {hosting_platform} AS h
INNER JOIN {node} AS n ON n.nid = h.nid
WHERE publish_path = !publish_path
AND h.status >= !h.status",
array(
'!publish_path' => hosting_path_normalize($path),
'!h.status' => HOSTING_PLATFORM_QUEUED,
)
)->fetch();
return $result;
* Determine whether a given path has already been used with another platform.
*
* @param string $path
* The path to check.
* @param int $exclude_nid
* Optionally exclude this platform from the check.
*
* @return mixed
* Either a result object or FALSE.
* The result object will contain the nid and name of the platform that uses
* the path.
*/
function hosting_platform_path_exists($path, $exclude_nid = NULL) {
$query = db_select('hosting_platform', 'h')
->condition('h.publish_path', hosting_path_normalize($path))
->condition('h.status', HOSTING_PLATFORM_LOCKED, '>=');
$query->innerJoin('node', 'n', 'n.nid = h.nid');
$query->addField('n', 'title', 'name');
$query->addField('n', 'nid');
if (!is_null($exclude_nid)) {
$query->condition('h.nid', $exclude_nid, '<>');
}
return $query->execute()->fetch();
}
/**
......
......@@ -131,7 +131,7 @@ function drush_hosting_queued() {
// Get some tasks to run.
if ($tasks = @hosting_get_new_tasks()) {
if ($tasks = @hosting_get_new_tasks(1)) {
drush_log(dt("Found %count tasks in queue. Running...", array(
'%count' => count($tasks),
......
......@@ -152,10 +152,9 @@ function hosting_site_hosting_install_task_rollback($task, $data) {
/**
* Implements hook_hosting_post_disable().
* I am not very fond of the use of bitwise operators with negatives.
*/
function hosting_site_post_hosting_disable_task($task, $data) {
if ($data['context']['backup_file'] && $data->ref->type == 'site') {
if (!empty($data['context']['backup_file']) && $data->ref->type == 'site') {
$platform = node_load($task->ref->platform);
hosting_site_add_backup($task->ref->nid, $platform->web_server, $data['context']['backup_file'], t('Generated before being disabled'), $data['context']['backup_file_size']);
}
......@@ -170,10 +169,9 @@ function hosting_site_post_hosting_disable_task($task, $data) {
/**
* Implements hook_hosting_post_restore().
* I am not very fond of the use of bitwise operators with negatives.
*/
function hosting_site_post_hosting_restore_task($task, $data) {
if ($data['context']['backup_file'] && $task->ref->type == 'site') {
if (!empty($data['context']['backup_file']) && $task->ref->type == 'site') {
$platform = node_load($task->ref->platform);
hosting_site_add_backup($task->ref->nid, $platform->web_server, $data['context']['backup_file'], t('Generated before being restored to a previous version'), $data['context']['backup_file_size']);
}
......@@ -214,7 +212,7 @@ function hosting_site_post_hosting_delete_task($task, $data) {
* This is needed to be able to restore.
*/
function hosting_site_post_hosting_backup_task($task, $data) {
if ($data['context']['backup_file'] && $task->ref->type == 'site') {
if (!empty($data['context']['backup_file']) && $task->ref->type == 'site') {
$platform = node_load($task->ref->platform);
$desc = $task->task_args['description'];
......
......@@ -325,12 +325,12 @@ function hosting_site_views_default_views() {
$handler->display->display_options['defaults']['row_plugin'] = FALSE;
$handler->display->display_options['defaults']['row_options'] = FALSE;
$handler->display->display_options['defaults']['empty'] = FALSE;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'No sites have been created. <a href="/node/add/site">Click here</a> to add one.';
$handler->display->display_options['empty']['area']['format'] = '1';
/* No results behavior: Global: Unfiltered text */
$handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['table'] = 'views';
$handler->display->display_options['empty']['area_text_custom']['field'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['empty'] = TRUE;
$handler->display->display_options['empty']['area_text_custom']['content'] = 'No sites have been created. <a href="/node/add/site">Click here</a> to add one.';
$handler->display->display_options['path'] = 'hosting/sites';
$handler->display->display_options['menu']['type'] = 'normal';
$handler->display->display_options['menu']['title'] = 'Sites';
......@@ -343,13 +343,13 @@ function hosting_site_views_default_views() {
/* Display: Site List Block */
$handler = $view->new_display('block', 'Site List Block', 'block_sites');
$handler->display->display_options['defaults']['empty'] = FALSE;
/* No results behavior: Global: Text area */
$handler->display->display_options['empty']['area']['id'] = 'area';
$handler->display->display_options['empty']['area']['table'] = 'views';
$handler->display->display_options['empty']['area']['field'] = 'area';
$handler->display->display_options['empty']['area']['content'] = 'No sites have been created for this client. <a href="/node/!1/site/add">Click here</a> to add one.';
$handler->display->display_options['empty']['area']['format'] = '1';
$handler->display->display_options['empty']['area']['tokenize'] = TRUE;
/* No results behavior: Global: Unfiltered text */
$handler->display->display_options['empty']['area_text_custom']['id'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['table'] = 'views';
$handler->display->display_options['empty']['area_text_custom']['field'] = 'area_text_custom';
$handler->display->display_options['empty']['area_text_custom']['empty'] = TRUE;
$handler->display->display_options['empty']['area_text_custom']['content'] = 'No sites have been created for this client. <a href="/node/!1/platform-add-site">Click here</a> to add one.';
$handler->display->display_options['empty']['area_text_custom']['tokenize'] = TRUE;
$handler->display->display_options['defaults']['arguments'] = FALSE;
/* Contextual filter: Content: Nid */
$handler->display->display_options['arguments']['nid']['id'] = 'nid';
......
......@@ -11,7 +11,7 @@
function _hosting_task_log($entry) {
$task = drush_get_context('HOSTING_TASK');
if ($task->vid) {
hosting_task_log($task->vid, $entry['type'], $entry['message'], $entry['error'], $entry['timestamp']);
hosting_task_log($task->vid, $entry['type'], $entry['message'], isset($entry['error']) ? $entry['error'] : '', $entry['timestamp']);
}
else {
_hosting_task_log_print($entry);
......@@ -58,6 +58,7 @@ function drush_hosting_task_validate($id, $type = NULL) {
$task_args = array();
// Parse task_arguments passed to drush in the format "name=value"
// phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
$arguments = func_get_args();
$drush_args = array_splice($arguments, 2);
foreach ($drush_args as $i => $arg) {
......
......@@ -34,8 +34,15 @@ function hosting_task_gc_hosting_queues() {
*/
function hosting_task_gc_queue() {
global $user;
// Prevent session information from being saved while queue is running.
$original_session_saving = drupal_save_session();
drupal_save_session(FALSE);
// Switch to the super user.
$old_user = $user;
$user = user_load(1);
$result = hosting_task_gc_list_sites();
while ($site = $result->fetchObject()) {
$query = "SELECT nid FROM {hosting_task} WHERE rid = :nid";
......@@ -45,7 +52,10 @@ function hosting_task_gc_queue() {
watchdog('hosting_task_gc', 'Deleted task node with nid @nid.', array('@nid' => $row->nid));
}
}
// Restore the user.
$user = $old_user;
drupal_save_session($original_session_saving);
// Look for orphaned task log entries.
$query = "SELECT DISTINCT h.vid
......@@ -81,8 +91,27 @@ function hosting_task_gc_list_sites() {
* The number of sites.
*/
function hosting_task_gc_count_sites() {
$query = "SELECT COUNT(DISTINCT s.nid) AS num_sites "
. "FROM {hosting_site} s INNER JOIN {hosting_task} t ON s.nid = t.rid "
. "WHERE s.status = :status";
return db_query($query, array(':status' => HOSTING_SITE_DELETED))->fetchField();
// This query can be super expensive to run, so only run it once every hour.
if ($cache = cache_get(__FUNCTION__)) {
return $cache->data;
}
else {
$query = "SELECT COUNT(DISTINCT s.nid) AS num_sites "
. "FROM {hosting_site} s INNER JOIN {hosting_task} t ON s.nid = t.rid "
. "WHERE s.status = :status";
$result = db_query($query, array(':status' => HOSTING_SITE_DELETED))->fetchField();
cache_set(__FUNCTION__, $result, 'cache', REQUEST_TIME + 3600);
return $result;
}
}
/**
* Implements hook_node_update().
*/
function hosting_task_gc_node_update($node) {
if ($node->type == "site") {
if (isset($node->site_status) && $node->site_status == HOSTING_SITE_DELETED) {
cache_clear_all('hosting_task_gc_count_sites', 'cache');
}
}
}
......@@ -409,7 +409,7 @@ function hosting_ssl_get_keys($client = NULL, $ask_custom = FALSE) {
$result = db_query($query, $args);
while ($obj = $result->fetchObject()) {
if (count($obj->ssl_key)) {
if (strlen($obj->ssl_key)) {
$keys[$obj->cid] = $obj->ssl_key;
}
}
......