Commit 64bbc6fb authored by heddn's avatar heddn Committed by heddn
Browse files

Issue #3092353 by heddn: Backport D8 features to D7

parent be98ba80
......@@ -109,12 +109,8 @@ class AutomaticUpdatesPsa {
if (empty($version_string)) {
return;
}
$module_directory = drupal_get_path('module', 'automatic_updates');
include_once $module_directory . '/semver/src/Constraint/ConstraintInterface.php';
include_once $module_directory . '/semver/src/Constraint/Constraint.php';
include_once $module_directory . '/semver/src/Constraint/EmptyConstraint.php';
include_once $module_directory . '/semver/src/Constraint/MultiConstraint.php';
include_once $module_directory . '/semver/src/VersionParser.php';
$project_root = drupal_get_path('module', 'automatic_updates');
require_once $project_root . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$parser = new VersionParser();
$psa_constraint = $parser->parseConstraints($version_string);
$contrib_constraint = $parser->parseConstraints($current_version);
......
......@@ -152,7 +152,7 @@ class ModifiedFilesService {
* TRUE if file path is ignored, else FALSE.
*/
protected static function isIgnoredPath($file_path) {
$paths = variable_get('automatic_updates_ignored_paths', "sites/all/modules/custom/*\nsites/all/themes/custom/*");
$paths = variable_get('automatic_updates_ignored_paths', "sites/all/modules/*\nsites/all/themes/*");
if (drupal_match_path($file_path, $paths)) {
return TRUE;
}
......
......@@ -11,12 +11,8 @@ class BlacklistPhp72Versions implements ReadinessCheckerInterface {
* {@inheritdoc}
*/
public static function run() {
$module_directory = drupal_get_path('module', 'automatic_updates');
include_once $module_directory . '/semver/src/Constraint/ConstraintInterface.php';
include_once $module_directory . '/semver/src/Constraint/Constraint.php';
include_once $module_directory . '/semver/src/Constraint/EmptyConstraint.php';
include_once $module_directory . '/semver/src/Constraint/MultiConstraint.php';
include_once $module_directory . '/semver/src/VersionParser.php';
$project_root = drupal_get_path('module', 'automatic_updates');
require_once $project_root . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$messages = [];
$parser = new VersionParser();
$unsupported_constraint = static::getUnsupportedVersionConstraint();
......
......@@ -91,7 +91,7 @@ class MissingProjectInfo implements ReadinessCheckerInterface {
* TRUE if file path is ignored, else FALSE.
*/
protected static function isIgnoredPath($file_path) {
$paths = variable_get('automatic_updates_ignored_paths', "sites/all/modules/custom/*\nsites/all/themes/custom/*");
$paths = variable_get('automatic_updates_ignored_paths', "sites/all/modules/*\nsites/all/themes/*");
if (drupal_match_path($file_path, $paths)) {
return TRUE;
}
......
<?php
/**
* Error if opcode caching is enabled and updates are executed via CLI.
*/
class OpcodeCache implements ReadinessCheckerInterface {
/**
* {@inheritdoc}
*/
public static function run() {
$messages = [];
if (self::isCli() && self::hasOpcodeFileCache()) {
$messages[] = t('Automatic updates cannot run via CLI when opcode file cache is enabled.');
}
return $messages;
}
/**
* Determine if PHP is running via CLI.
*
* @return bool
* TRUE if CLI, FALSE otherwise.
*/
protected static function isCli() {
return PHP_SAPI === 'cli';
}
/**
* Determine if opcode cache is enabled.
*
* If opcache.validate_timestamps is disabled or enabled with
* opcache.revalidate_freq greater then 2, then a site is considered to have
* opcode caching. The default php.ini setup is
* opcache.validate_timestamps=TRUE and opcache.revalidate_freq=2.
*
* @return bool
* TRUE if opcode file cache is enabled, FALSE otherwise.
*/
protected static function hasOpcodeFileCache() {
if (!ini_get('opcache.validate_timestamps')) {
return TRUE;
}
if (ini_get('opcache.revalidate_freq') > 2) {
return TRUE;
}
return FALSE;
}
}
......@@ -39,7 +39,7 @@ function automatic_updates_admin_form() {
'#type' => 'textarea',
'#title' => t('Paths to ignore for readiness checks'),
'#description' => t('Paths relative to %drupal_root. One path per line.', ['%drupal_root' => DRUPAL_ROOT]),
'#default_value' => variable_get('automatic_updates_ignored_paths', "sites/all/modules/custom/*\nsites/all/themes/custom/*"),
'#default_value' => variable_get('automatic_updates_ignored_paths', "sites/all/modules/*\nsites/all/themes/*"),
'#states' => [
'visible' => [
':input[name="automatic_updates_enable_readiness_checks"]' => ['checked' => TRUE],
......
{
"name": "drupal/automatic_updates",
"type": "drupal-module",
"description": "Drupal Automatic Updates",
"keywords": ["Drupal"],
"license": "GPL-2.0-or-later",
"homepage": "https://www.drupal.org/project/automatic_updates",
"minimum-stability": "dev",
"support": {
"issues": "https://www.drupal.org/project/issues/automatic_updates",
"source": "http://cgit.drupalcode.org/automatic_updates"
},
"require": {
"ext-json": "*",
"ext-zip": "*",
"drupal/php-signify": "^1.0@dev",
"composer/semver": "^1.0@dev",
"drupal/core-version": "^8.7"
},
"config": {
"platform": {
"php": "5.6.0"
}
}
}
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3e128df353797177029795564bde59cd",
"packages": [
{
"name": "composer/semver",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/composer/semver.git",
"reference": "37e4db276f38376a63ea67e96b09571d74312779"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/composer/semver/zipball/37e4db276f38376a63ea67e96b09571d74312779",
"reference": "37e4db276f38376a63ea67e96b09571d74312779",
"shasum": ""
},
"require": {
"php": "^5.3.2 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^4.5 || ^5.0.5"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.x-dev"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com",
"homepage": "http://robbast.nl"
}
],
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"keywords": [
"semantic",
"semver",
"validation",
"versioning"
],
"time": "2019-04-14T09:35:30+00:00"
},
{
"name": "drupal/core-version",
"version": "8.7.x-dev",
"source": {
"type": "git",
"url": "https://github.com/drupal/core-version.git",
"reference": "ad6bca9d42ef0492a709dc821da489e0e995f994"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/drupal/core-version/zipball/ad6bca9d42ef0492a709dc821da489e0e995f994",
"reference": "ad6bca9d42ef0492a709dc821da489e0e995f994",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
},
"type": "library",
"autoload": {
"psr-4": {
"Drupal\\Component\\Version\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"GPL-2.0-or-later"
],
"description": "Utility classes for process Drupal specific version information.",
"homepage": "https://www.drupal.org/project/drupal",
"keywords": [
"drupal"
],
"time": "2018-10-22T05:21:49+00:00"
},
{
"name": "drupal/php-signify",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/drupal/php-signify.git",
"reference": "1baaf6e9da6164dd091e45f65a64fbd515080264"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/drupal/php-signify/zipball/1baaf6e9da6164dd091e45f65a64fbd515080264",
"reference": "1baaf6e9da6164dd091e45f65a64fbd515080264",
"shasum": ""
},
"require": {
"paragonie/sodium_compat": "^1.10",
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Drupal\\Signify\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Drupal Association",
"homepage": "https://www.drupal.org/association"
}
],
"description": "Signify-compliant signature verification",
"keywords": [
"cryptography",
"security",
"signify"
],
"time": "2019-10-04T21:34:22+00:00"
},
{
"name": "paragonie/random_compat",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/paragonie/random_compat.git",
"reference": "51813fbc2dc6a9ea8b3ae1d97a688532768e3bc4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/51813fbc2dc6a9ea8b3ae1d97a688532768e3bc4",
"reference": "51813fbc2dc6a9ea8b3ae1d97a688532768e3bc4",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"require-dev": {
"phpunit/phpunit": "4.*|5.*"
},
"suggest": {
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
},
"type": "library",
"autoload": {
"files": [
"lib/random.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com",
"homepage": "https://paragonie.com"
}
],
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
"keywords": [
"csprng",
"polyfill",
"pseudorandom",
"random"
],
"time": "2019-10-18T21:30:25+00:00"
},
{
"name": "paragonie/sodium_compat",
"version": "v1.12.0",
"source": {
"type": "git",
"url": "https://github.com/paragonie/sodium_compat.git",
"reference": "8228b286d6b8fe24825f42ce02403f72656ac826"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/paragonie/sodium_compat/zipball/8228b286d6b8fe24825f42ce02403f72656ac826",
"reference": "8228b286d6b8fe24825f42ce02403f72656ac826",
"shasum": ""
},
"require": {
"paragonie/random_compat": ">=1",
"php": "^5.2.4|^5.3|^5.4|^5.5|^5.6|^7|^8"
},
"require-dev": {
"phpunit/phpunit": "^3|^4|^5|^6|^7"
},
"suggest": {
"ext-libsodium": "PHP < 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security.",
"ext-sodium": "PHP >= 7.0: Better performance, password hashing (Argon2i), secure memory management (memzero), and better security."
},
"type": "library",
"autoload": {
"files": [
"autoload.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"ISC"
],
"authors": [
{
"name": "Paragon Initiative Enterprises",
"email": "security@paragonie.com"
},
{
"name": "Frank Denis",
"email": "jedisct1@pureftpd.org"
}
],
"description": "Pure PHP implementation of libsodium; uses the PHP extension if it exists",
"keywords": [
"Authentication",
"BLAKE2b",
"ChaCha20",
"ChaCha20-Poly1305",
"Chapoly",
"Curve25519",
"Ed25519",
"EdDSA",
"Edwards-curve Digital Signature Algorithm",
"Elliptic Curve Diffie-Hellman",
"Poly1305",
"Pure-PHP cryptography",
"RFC 7748",
"RFC 8032",
"Salpoly",
"Salsa20",
"X25519",
"XChaCha20-Poly1305",
"XSalsa20-Poly1305",
"Xchacha20",
"Xsalsa20",
"aead",
"cryptography",
"ecdh",
"elliptic curve",
"elliptic curve cryptography",
"encryption",
"libsodium",
"php",
"public-key cryptography",
"secret-key cryptography",
"side-channel resistant"
],
"time": "2019-10-19T15:30:42+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "dev",
"stability-flags": {
"drupal/php-signify": 20,
"composer/semver": 20
},
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"ext-json": "*",
"ext-zip": "*"
},
"platform-dev": [],
"platform-overrides": {
"php": "5.6.0"
}
}
#!/bin/bash
rm -fv composer.lock
composer install --no-dev -o
composer dump-autoload --no-dev --classmap-authoritative
rm -rfv vendor/drupal/php-signify/sh
rm -rfv vendor/drupal/php-signify/tests
rm -rfv vendor/paragonie/random_compat/other
rm -rfv vendor/paragonie/random_compat/tests
rm -rfv vendor/composer/semver/tests
find ./vendor -name .git -type d -prune -exec rm -rf {} \;
find ./vendor -type f -name '.*' -delete
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit521321008fc462c9f6b48808ceb7ed29::getLoader();
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.