Skip to content
Snippets Groups Projects
Commit e8e50522 authored by Adam G-H's avatar Adam G-H
Browse files

Issue #3275508 by phenaproxima: Create a validator to warn if xdebug is on

parent e1262969
No related branches found
No related tags found
No related merge requests found
...@@ -129,6 +129,10 @@ services: ...@@ -129,6 +129,10 @@ services:
- '@string_translation' - '@string_translation'
tags: tags:
- { name: event_subscriber } - { name: event_subscriber }
automatic_updates.validator.xdebug:
class: Drupal\automatic_updates\Validator\XdebugValidator
tags:
- { name: event_subscriber }
automatic_updates.validator.target_release: automatic_updates.validator.target_release:
class: \Drupal\automatic_updates\Validator\UpdateReleaseValidator class: \Drupal\automatic_updates\Validator\UpdateReleaseValidator
tags: tags:
......
...@@ -9,12 +9,19 @@ ...@@ -9,12 +9,19 @@
* Implements hook_requirements(). * Implements hook_requirements().
*/ */
function package_manager_requirements() { function package_manager_requirements() {
$requirements = [];
if (!class_exists('PhpTuf\ComposerStager\Domain\Beginner')) { if (!class_exists('PhpTuf\ComposerStager\Domain\Beginner')) {
return [ $requirements['package_manager_composer_dependencies'] = [
'package_manager' => [ 'description' => t('External dependencies for Package Manager are not available. Composer must be used to download the module with dependencies.'),
'description' => t('External dependencies for Package Manager are not available. Composer must be used to download the module with dependencies.'), 'severity' => REQUIREMENT_ERROR,
'severity' => REQUIREMENT_ERROR, ];
], }
if (extension_loaded('xdebug')) {
$requirements['package_manager_xdebug'] = [
'description' => t('Xdebug is enabled, which may have a negative performance impact on Package Manager and any modules that use it.'),
'severity' => REQUIREMENT_WARNING,
]; ];
} }
return $requirements;
} }
<?php
namespace Drupal\automatic_updates\Validator;
use Drupal\automatic_updates\Event\ReadinessCheckEvent;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Flags a warning if Xdebug is enabled.
*/
class XdebugValidator implements EventSubscriberInterface {
use StringTranslationTrait;
/**
* Flags a warning if Xdebug is enabled.
*
* @param \Drupal\automatic_updates\Event\ReadinessCheckEvent $event
* The event object.
*/
public function checkForXdebug(ReadinessCheckEvent $event): void {
if (extension_loaded('xdebug')) {
$event->addWarning([
$this->t('Xdebug is enabled, which may cause timeout errors during automatic updates.'),
]);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
return [
ReadinessCheckEvent::class => 'checkForXdebug',
];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment