Skip to content
Snippets Groups Projects
Commit 680f1b48 authored by Gareth Alexander's avatar Gareth Alexander
Browse files

Resolve #2237493 "Port to drupal 8 & 9"

parent 625a0595
No related branches found
No related tags found
1 merge request!1Resolve #2237493 "Port to drupal 8 & 9"
CONTENTS OF THIS FILE
---------------------
......@@ -19,4 +18,4 @@ INSTALLATION
------------
This module is installed in the usual way. See
http://drupal.org/documentation/install/modules-themes/modules-7.
https://www.drupal.org/docs/user_guide/en/extend-module-install.html.
{
"name": "drupal/pasc",
"description": "An interactive checklist of performance and scalability optimization tasks for Drupal.",
"type": "drupal-module",
"homepage": "http://drupal.org/project/pasc",
"license": "GPL-2.0-or-later",
"require": {
"drupal/checklistapi": "^2.0"
},
"minimum-stability": "dev",
"support": {
"issues": "https://www.drupal.org/project/issues/pasc",
"source": "https://git.drupalcode.org/project/pasc"
}
}
name = Performance and Scalability Checklist
description = An interactive checklist of performance and scalability optimization tasks for Drupal.
core = 7.x
dependencies[] = checklistapi
package = Performance and scalability
configure = admin/config/development/pasc
name: Performance and Scalability Checklist
type: module
description: An interactive checklist of performance and scalability optimization tasks for Drupal.
package: 'Performance and scalability'
core_version_requirement: ^8 || ^9
dependencies:
- checklistapi
configure: checklistapi.checklists.pasc
......@@ -9,5 +9,7 @@
* Implements hook_uninstall().
*/
function pasc_uninstall() {
variable_del('checklistapi_checklist_pasc');
\Drupal::configFactory()
->getEditable("checklistapi.progress.pasc")
->delete();
}
pasc.checklist:
title: Performance and Scalability Checklist
description: Performance and Scalability Checklist.
route_name: checklistapi.checklists.pasc
parent: system.admin_config_development
......@@ -5,290 +5,307 @@
* Code for the pasc module.
*/
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_checklistapi_checklist_info().
*/
function pasc_checklistapi_checklist_info() {
$modules_page = array('#text' => t('Enable'), '#path' => 'admin/modules');
$modules_page = [
'#text' => t('Enable'),
'#url' => Url::fromRoute('system.modules_list', [], ['absolute' => TRUE]),
];
$definitions = array();
$definitions['pasc'] = array(
$definitions = [];
$definitions['pasc'] = [
'#title' => t('Performance and scalability checklist'),
'#description' => t('Track performance and scalability optimization tasks.'),
'#path' => 'admin/config/development/pasc',
'#help' => t("<p>This checklist will help you optimize the software stack your web site operates on, from Apache up to your Drupal theme. It assumes you're running Apache and MySQL. Details may vary if you're using Nginx or PostgreSQL, for example. There are viable alternatives to some of the recommendations below. Additionally, some recommendations may not be strictly necessary in your case, and there's <em>certainly</em> <em>more</em> you can do than what's listed here if you really need to squeeze every last bit of performance out of your site. This list represents the most widely-observed best practices suitable for most medium-sized Drupal sites. Follow it so far as it suits your particular needs.</p>"),
// Tune Apache.
'tune_apache' => array(
'tune_apache' => [
'#title' => t('Tune Apache'),
'disable_unused_apache_modules' => array(
'disable_unused_apache_modules' => [
'#title' => t('Disable unused Apache modules.'),
),
'enable_gzip_compression' => array(
],
'enable_gzip_compression' => [
'#title' => t('Enable gzip compression.'),
'instructions' => array(
'instructions' => [
'#text' => t('Gzip Components'),
'#path' => 'http://developer.yahoo.com/performance/rules.html#gzip',
),
),
'install_varnish_cache' => array(
'#url' => Url::fromUri('http://developer.yahoo.com/performance/rules.html#gzip'),
],
],
'install_varnish_cache' => [
'#title' => t('Install and configure the <em>Varnish</em> reverse proxy cache.'),
'#description' => t("If you don't have the ability to install software on your server and your performance needs are minimal, try the <a href=\"http://drupal.org/project/boost\">Boost</a> Drupal module instead."),
'download_site' => array(
'download_site' => [
'#text' => t('Download'),
'#path' => 'https://www.varnish-cache.org/',
),
'wiki_page' => array(
'#url' => Url::fromUri('https://www.varnish-cache.org/'),
],
// @TODO Update content
'wiki_page' => [
'#text' => t('Configure Varnish 3 for Drupal 7'),
'#path' => 'https://fourkitchens.atlassian.net/wiki/display/TECH/Configure+Varnish+3+for+Drupal+7',
),
),
'install_varnish_module' => array(
'#url' => Url::fromUri('https://fourkitchens.atlassian.net/wiki/display/TECH/Configure+Varnish+3+for+Drupal+7'),
],
],
'install_varnish_module' => [
'#title' => t('Install the <em>Varnish HTTP Accelerator Integration</em> Drupal module.'),
'#default_value' => module_exists('varnish'),
'project_page' => array(
'#default_value' => \Drupal::moduleHandler()->moduleExists('varnish'),
'project_page' => [
'#text' => t('Download'),
'#path' => 'http://drupal.org/project/varnish',
),
'#url' => Url::fromUri('http://drupal.org/project/varnish'),
],
'modules_page' => $modules_page,
),
'install_expire_module' => array(
],
'install_expire_module' => [
'#title' => t('Install the <em>Cache Expiration</em> Drupal module.'),
'#default_value' => module_exists('expire'),
'project_page' => array(
'#default_value' => \Drupal::moduleHandler()->moduleExists('expire'),
'project_page' => [
'#text' => t('Download'),
'#path' => 'http://drupal.org/project/expire',
),
'#url' => Url::fromUri('http://drupal.org/project/expire'),
],
'modules_page' => $modules_page,
),
),
],
],
// Tune MySQL.
'tune_mysql' => array(
'tune_mysql' => [
'#title' => t('Tune MySQL'),
'use_innodb_engine' => array(
'use_innodb_engine' => [
'#title' => t('Use the InnoDB storage engine.'),
'documentation_page' => array(
// @TODO Update content
'documentation_page' => [
'#text' => t('Converting Tables from Other Storage Engines to InnoDB'),
'#path' => 'http://dev.mysql.com/doc/refman/5.6/en/converting-tables-to-innodb.html',
),
),
'install_memcached' => array(
'#url' => Url::fromUri('http://dev.mysql.com/doc/refman/5.6/en/converting-tables-to-innodb.html'),
],
],
'install_memcached' => [
'#title' => t('Install the <em>Memcached</em> memory object cache.'),
'download_site' => array(
'download_site' => [
'#text' => t('Download'),
'#path' => 'http://memcached.org/',
),
),
'install_memcache_extension' => array(
'#url' => Url::fromUri('http://memcached.org/'),
],
],
'install_memcache_extension' => [
'#title' => t('Install the <em>memcache</em> extension for PHP.'),
'#default_value' => extension_loaded('memcache'),
'download_site' => array(
'download_site' => [
'#text' => t('Download'),
'#path' => 'http://pecl.php.net/package/memcache',
),
),
'install_memcache_module' => array(
'#url' => Url::fromUri('http://pecl.php.net/package/memcache'),
],
],
'install_memcache_module' => [
'#title' => t('Install the <em>Memcache API and Integration</em> Drupal module.'),
'#default_value' => module_exists('memcache'),
'project_page' => array(
'#default_value' => \Drupal::moduleHandler()->moduleExists('memcache'),
'project_page' => [
'#text' => t('Download'),
'#path' => 'http://drupal.org/project/memcache',
),
'#url' => Url::fromUri('http://drupal.org/project/memcache'),
],
'modules_page' => $modules_page,
),
'install_db_maintenance' => array(
],
'install_db_maintenance' => [
'#title' => t('Install the <em>DB Maintenance</em> Drupal module.'),
'#description' => t('This module regularly optimizes administrator-selected database tables.'),
'#default_value' => module_exists('db_maintenance'),
'project_page' => array(
'#default_value' => \Drupal::moduleHandler()->moduleExists('db_maintenance'),
'project_page' => [
'#text' => t('Download'),
'#path' => 'http://drupal.org/project/db_maintenance',
),
'#url' => Url::fromUri('http://drupal.org/project/db_maintenance'),
],
'modules_page' => $modules_page,
),
'configure_db_maintenance' => array(
'#title' => t('Configure the <em>DB Maintenance</em> Drupal module.'),
'config_page' => array(
'#text' => t('Configure'),
'#path' => 'admin/config/system/db_maintenance',
),
),
),
],
],
// Tune PHP.
'tune_php' => array(
'tune_php' => [
'#title' => t('Tune PHP'),
'disable_unused_php_extensions' => array(
'disable_unused_php_extensions' => [
'#title' => t('Disable unused PHP extensions.'),
),
'install_memcache_extension' => array(
],
'install_memcache_extension' => [
'#title' => t('Install the <em>APC (Alternative PHP Cache)</em> opcode cache.'),
'#default_value' => extension_loaded('apc'),
'download_site' => array(
'download_site' => [
'#text' => t('Download'),
'#path' => 'http://pecl.php.net/package/APC',
),
),
'tune_apc' => array(
'#url' => Url::fromUri('http://pecl.php.net/package/APC'),
],
],
'tune_apc' => [
'#title' => t('Tune APC.'),
'#description' => t("It's very important that you allot APC enough memory to cache your entire codebase or it can actually <em>slow your server down</em>."),
),
),
],
],
// Tune Drupal.
'tune_drupal' => array(
'tune_drupal' => [
'#title' => t('Tune Drupal'),
'disable_unused_drupal_modules' => array(
'disable_unused_drupal_modules' => [
'#title' => t('Disable unused Drupal modules.'),
'#description' => t('Bootstrapping unused modules wastes CPU cycles and RAM.'),
'modules_page' => array(
'modules_page' => [
'#text' => t('Modules'),
'#path' => 'admin/modules',
),
),
'enable_page_caching' => array(
'#url' => Url::fromRoute('system.modules_list', [], ['absolute' => TRUE]),
],
],
'enable_page_caching' => [
'#title' => t('Enable page caching.'),
'#default_value' => variable_get('cache', 0),
'performance_page' => array(
'#default_value' => \Drupal::config('system.performance')->get('cache.page.use_internal'),
'performance_page' => [
'#text' => t('Performance'),
'#path' => 'admin/config/development/performance',
),
),
'enable_block_caching' => array(
'#title' => t('Enable block caching.'),
'#default_value' => variable_get('block_cache', 0),
'performance_page' => array(
'#url' => Url::fromRoute('system.performance_settings', [], ['absolute' => TRUE]),
],
],
'enable_block_caching' => [
'#title' => t('Compress cached pages.'),
'#default_value' => \Drupal::config('system.performance')->get('response.gzip'),
'performance_page' => [
'#text' => t('Performance'),
'#path' => 'admin/config/development/performance',
),
),
'configure_views_caching' => array(
'#url' => Url::fromRoute('system.performance_settings', [], ['absolute' => TRUE]),
],
],
'configure_views_caching' => [
'#title' => t('Configure Views caching.'),
),
'use_solr_search' => array(
],
'use_solr_search' => [
'#title' => t('[Optional] Use <em>Apache Solr</em> instead of core search.'),
'#description' => t("Relational databases aren't designed to be search backends. Because core search depends on the database it's comparatively slow, and it adds strain to most Drupal sites' biggest bottleneck."),
'solr_website' => array(
'solr_website' => [
'#text' => t('Apache Solr website'),
'#path' => 'http://lucene.apache.org/solr/',
),
'apachesolr_project_page' => array(
'#url' => Url::fromUri('http://lucene.apache.org/solr/'),
],
'apachesolr_project_page' => [
'#text' => t('Apache Solr Search integration module'),
'#path' => 'http://drupal.org/project/apachesolr',
),
),
'install_fast_404_module' => array(
'#url' => Url::fromUri('http://drupal.org/project/apachesolr'),
],
],
'install_fast_404_module' => [
'#title' => t('[Optional] Install the <em>Fast 404</em> Drupal module.'),
'#description' => t("Drupal 404 pages are expensive. This module will make sure you aren't generating them unnecessarily."),
'#default_value' => module_exists('fast_404'),
'project_page' => array(
'#default_value' => \Drupal::moduleHandler()->moduleExists('fast_404'),
'project_page' => [
'#text' => t('Download'),
'#path' => 'http://drupal.org/project/fast_404',
),
'#url' => Url::fromUri('http://drupal.org/project/fast_404'),
],
'modules_page' => $modules_page,
),
),
],
],
// Optimize the front end.
'optimize_front_end' => array(
'optimize_front_end' => [
'#title' => t('Optimize the front end'),
'enable_css_aggregation' => array(
'enable_css_aggregation' => [
'#title' => t('Enable CSS file aggregation and compression.'),
'#default_value' => variable_get('preprocess_css', 0),
'performance_page' => array(
'#default_value' => \Drupal::config('system.performance')->get('css.preprocess'),
'performance_page' => [
'#text' => t('Performance'),
'#path' => 'admin/config/development/performance',
),
),
'enable_javascript_aggregation' => array(
'#url' => Url::fromRoute('system.performance_settings', [], ['absolute' => TRUE]),
],
],
'enable_javascript_aggregation' => [
'#title' => t('Enable JavaScript file aggregation.'),
'#default_value' => variable_get('preprocess_js', 0),
'performance_page' => array(
'#default_value' => \Drupal::config('system.performance')->get('js.preprocess'),
'performance_page' => [
'#text' => t('Performance'),
'#path' => 'admin/config/development/performance',
),
),
'install_speedy' => array(
'#url' => Url::fromRoute('system.performance_settings', [], ['absolute' => TRUE]),
],
],
'install_speedy' => [
'#title' => t('Install the <em>Speedy</em> Drupal module.'),
'#default_value' => module_exists('speedy'),
'project_page' => array(
'#default_value' => \Drupal::moduleHandler()->moduleExists('speedy'),
'project_page' => [
'#text' => t('Download'),
'#path' => 'http://drupal.org/project/speedy',
),
'#url' => Url::fromUri('http://drupal.org/project/speedy'),
],
'modules_page' => $modules_page,
),
'run_yslow' => array(
],
'run_yslow' => [
'#title' => t('Run YSlow.'),
'product_page' => array(
'product_page' => [
'#text' => t('YSlow'),
'#path' => 'http://yslow.org/',
),
),
'run_google_pagespeed' => array(
'#url' => Url::fromUri('http://yslow.org/'),
],
],
'run_google_pagespeed' => [
'#title' => t('Run Google PageSpeed.'),
'product_page' => array(
'product_page' => [
'#text' => t('PageSpeed Tools'),
'#path' => 'https://developers.google.com/speed/pagespeed/',
),
),
'use_a_cdn' => array(
'#url' => Url::fromUri('https://developers.google.com/speed/pagespeed/'),
],
],
'use_a_cdn' => [
'#title' => t('[Optional] Serve static files from a Content Delivery Network (CDN).'),
'wikipedia_page' => array(
'wikipedia_page' => [
'#text' => t('Content delivery network Wikipedia page'),
'#path' => 'http://en.wikipedia.org/wiki/Content_delivery_network',
),
'cdn_module' => array(
'#url' => Url::fromUri('http://en.wikipedia.org/wiki/Content_delivery_network'),
],
'cdn_module' => [
'#text' => t('CDN Drupal module'),
'#path' => 'http://drupal.org/project/cdn',
),
),
),
'#url' => Url::fromUri('http://drupal.org/project/cdn'),
],
],
],
// Other resources.
'additional_resources' => array(
'additional_resources' => [
'#title' => t('Additional resources'),
),
],
];
);
return $definitions;
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function pasc_form_checklistapi_checklist_form_alter(&$form, &$form_state, $form_id) {
function pasc_form_checklistapi_checklist_form_alter(&$form, FormStateInterface $form_state) {
if ($form['#checklist']->id == 'pasc') {
$form['checklistapi']['tune_apache']['additional_resources'] = array(
'#markup' => theme('item_list', array(
'items' => array(
l(t('Apache Performance Tuning'), 'http://httpd.apache.org/docs/current/misc/perf-tuning.html'),
), 'title' => t('Additional resources:'),
)),
);
$form['checklistapi']['tune_mysql']['additional_resources'] = array(
'#markup' => theme('item_list', array(
'items' => array(
l(t('High Performance MySQL'), 'http://www.highperfmysql.com/'),
), 'title' => t('Additional resources:'),
)),
);
$form['checklistapi']['optimize_front_end']['additional_resources'] = array(
'#markup' => theme('item_list', array(
'items' => array(
l(t('High Performance Web Sites'), 'http://stevesouders.com/hpws/'),
l(t('Even Faster Web Sites'), 'http://stevesouders.com/efws/'),
), 'title' => t('Additional resources:'),
)),
);
$form['checklistapi']['additional_resources']['links'] = array(
'#markup' => theme('item_list', array(
'items' => array(
l(t('High Performance Drupal group'), 'http://groups.drupal.org/high-performance'),
l(t('Drupalize.me Drupal Performance and Scalability Series'), 'http://drupalize.me/videos/drupal-performance-scalability'),
l(t('Tag1 Consulting online book'), 'http://books.tag1consulting.com/scalability'),
),
)),
);
$options = [
'#theme' => 'item_list',
'#items' => [
Link::fromTextAndUrl(t('Apache Performance Tuning'), Url::fromUri('http://httpd.apache.org/docs/current/misc/perf-tuning.html')),
],
'#title' => t('Apache:'),
];
$form['additional_resources']['tune_apache'] = [
'#markup' => \Drupal::service('renderer')->render($options),
];
$options = [
'#theme' => 'item_list',
'#items' => [
Link::fromTextAndUrl(t('High Performance MySQL'), Url::fromUri('http://www.highperfmysql.com/')),
],
'#title' => t('MySQL:'),
];
$form['additional_resources']['tune_mysql'] = [
'#markup' => \Drupal::service('renderer')->render($options),
];
$options = [
'#theme' => 'item_list',
'#items' => [
Link::fromTextAndUrl(t('High Performance Web Sites'), Url::fromUri('http://stevesouders.com/hpws/')),
Link::fromTextAndUrl(t('Even Faster Web Sites'), Url::fromUri('http://stevesouders.com/efws/')),
],
'#title' => t('Fast Web Sites:'),
];
$form['additional_resources']['optimize_front_end'] = [
'#markup' => \Drupal::service('renderer')->render($options),
];
$options = [
'#theme' => 'item_list',
'#items' => [
Link::fromTextAndUrl(t('High Performance Drupal group'), Url::fromUri('http://groups.drupal.org/high-performance')),
Link::fromTextAndUrl(t('Drupalize.me Drupal Performance and Scalability Series'), Url::fromUri('http://drupalize.me/videos/drupal-performance-scalability')),
Link::fromTextAndUrl(t('Tag1 Consulting online book'), Url::fromUri('http://books.tag1consulting.com/scalability')),
],
'#title' => t('Drupal:'),
];
$form['additional_resources']['links'] = [
'#markup' => \Drupal::service('renderer')->render($options),
];
}
}
checklistapi.checklists.pasc:
path: '/admin/config/development/pasc'
defaults:
_title: 'Performance and Scalability Checklist'
_form: '\Drupal\checklistapi\Form\ChecklistapiChecklistForm'
checklist_id: pasc
op: any
requirements:
_checklistapi_access: 'TRUE'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment