Skip to content
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

Remove vendor dependency #5048

Merged
merged 4 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 4 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ jobs:
extensions: mysql, pgsql, ldap

- name: Setup dependencies
run: composer require -n --no-progress mockery/mockery ipl/i18n:@dev
run: |
composer require -n --no-progress mockery/mockery ipl/i18n:@dev
git clone --depth 1 --branch snapshot/nightly https://github.com/Icinga/icinga-php-thirdparty.git vendor/icinga-php-thirdparty

- name: PHPUnit
env:
ICINGAWEB_TEST_MYSQL_PORT: ${{ job.services.mysql.ports['3306'] }}
ICINGAWEB_TEST_PGSQL_PORT: ${{ job.services.pgsql.ports['5432'] }}
ICINGAWEB_LIBDIR: vendor/
run: phpunit -c modules/test/phpunit.xml --verbose
31 changes: 1 addition & 30 deletions library/Icinga/Application/ApplicationBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ abstract class ApplicationBootstrap
/**
* Base directory
*
* Parent folder for at least application, bin, modules, library/vendor and public
* Parent folder for at least application, bin, modules and public
*
* @var string
*/
Expand All @@ -56,13 +56,6 @@ abstract class ApplicationBootstrap
*/
protected $appDir;

/**
* Vendor library directory
*
* @var string
*/
protected $vendorDir;

/**
* Icinga library directory
*
Expand Down Expand Up @@ -161,7 +154,6 @@ protected function __construct($baseDir = null, $configDir = null, $storageDir =
}
$this->baseDir = $baseDir;
$this->appDir = $baseDir . '/application';
$this->vendorDir = $baseDir . '/library/vendor';
if (substr(__DIR__, 0, 8) === 'phar:///') {
$this->libDir = dirname(dirname(__DIR__));
} else {
Expand Down Expand Up @@ -206,15 +198,6 @@ protected function __construct($baseDir = null, $configDir = null, $storageDir =
}
}

set_include_path(
implode(
PATH_SEPARATOR,
array($this->vendorDir, get_include_path())
)
);

Benchmark::measure('Bootstrap, autoloader registered');

Icinga::setApp($this);

require_once dirname(__FILE__) . '/functions.php';
Expand Down Expand Up @@ -328,18 +311,6 @@ public function getApplicationDir($subDir = null)
return $this->getDirWithSubDir($this->appDir, $subDir);
}

/**
* Get the vendor library directory
*
* @param string $subDir Optional sub directory to get
*
* @return string
*/
public function getVendorDir($subDir = null)
{
return $this->getDirWithSubDir($this->vendorDir, $subDir);
}

/**
* Get the configuration directory
*
Expand Down
28 changes: 0 additions & 28 deletions library/Icinga/Application/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Icinga\Application;

use Zend_Loader_Autoloader;

/**
* PSR-4 class loader
*/
Expand Down Expand Up @@ -263,18 +261,6 @@ protected function namespaceHasApplictionDirectory($namespace)
return array_key_exists($namespace, $this->applicationDirectories);
}

/**
* Require ZF autoloader
*
* @return Zend_Loader_Autoloader
*/
protected function requireZendAutoloader()
{
require_once 'Zend/Loader/Autoloader.php';
$this->gotZend = true;
return Zend_Loader_Autoloader::getInstance();
}

/**
* Load the given class or interface
*
Expand All @@ -284,20 +270,6 @@ protected function requireZendAutoloader()
*/
public function loadClass($class)
{
// We are aware of the Zend_ prefix and lazyload it's autoloader.
// Return as fast as possible if we already did so.
if (substr($class, 0, 5) === 'Zend_') {
if (! $this->gotZend) {
$zendLoader = $this->requireZendAutoloader();
if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
// PHP7 seems to remember the autoload function stack before auto-loading. Thus
// autoload functions registered during autoload never get called
return $zendLoader::autoload($class);
}
}
return false;
}

if ($file = $this->getSourceFile($class)) {
if (file_exists($file)) {
require $file;
Expand Down
9 changes: 5 additions & 4 deletions library/Icinga/Exception/IcingaException.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use Exception;
use ReflectionClass;
use Throwable;

class IcingaException extends Exception
{
Expand Down Expand Up @@ -51,11 +52,11 @@ public static function create(array $args)
*
* The format used is: %class% in %path%:%line% with message: %message%
*
* @param Exception $exception
* @param Throwable $exception
*
* @return string
*/
public static function describe(Exception $exception)
public static function describe(Throwable $exception)
{
return sprintf(
'%s in %s:%d with message: %s',
Expand All @@ -70,11 +71,11 @@ public static function describe(Exception $exception)
* Return the same as {@link Exception::getTraceAsString()} for the given exception,
* but show only the types of scalar arguments
*
* @param Exception $exception
* @param Throwable $exception
*
* @return string
*/
public static function getConfidentialTraceAsString(Exception $exception)
public static function getConfidentialTraceAsString(Throwable $exception)
{
$trace = array();

Expand Down
15 changes: 0 additions & 15 deletions library/Icinga/File/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,6 @@
use Icinga\Web\Hook;
use Icinga\Web\Url;

call_user_func(function () {
/**
* @package dompdf
* @link http://dompdf.github.com/
* @author Benj Carson <[email protected]>
* @author Fabien Ménager <[email protected]>
* @author Alexander A. Klimov <[email protected]>
* @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
*/

$baseDir = Icinga::app()->getBaseDir('library/vendor/dompdf');

require_once "$baseDir/vendor/autoload.php";
});

class Pdf
{
protected function assertNoHeadersSent()
Expand Down
2 changes: 0 additions & 2 deletions library/Icinga/Util/LessParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Icinga\Less\Visitor;
use lessc;

require_once 'lessphp/lessc.inc.php';

class LessParser extends lessc
{
public function __construct()
Expand Down
4 changes: 0 additions & 4 deletions library/Icinga/Web/Helper/HtmlPurifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class HtmlPurifier
*/
public function __construct($config = null)
{
require_once 'HTMLPurifier/Bootstrap.php';
require_once 'HTMLPurifier.php';
require_once 'HTMLPurifier.autoload.php';

$purifierConfig = \HTMLPurifier_Config::createDefault();
$purifierConfig->set('Core.EscapeNonASCIICharacters', true);
$purifierConfig->set('Attr.AllowedFrameTargets', array('_blank'));
Expand Down
4 changes: 0 additions & 4 deletions library/Icinga/Web/Helper/Markdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class Markdown
{
public static function line($content, $config = null)
{
require_once 'Parsedown/Parsedown.php';

if ($config === null) {
$config = function (\HTMLPurifier_Config $config) {
$config->set('HTML.Parent', 'span'); // Only allow inline elements
Expand All @@ -25,8 +23,6 @@ public static function line($content, $config = null)

public static function text($content, $config = null)
{
require_once 'Parsedown/Parsedown.php';

if ($config === null) {
$config = function (\HTMLPurifier_Config $config) {
LinkTransformer::attachTo($config);
Expand Down
1 change: 0 additions & 1 deletion library/Icinga/Web/JavaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public static function send($minified = false)
}

if ($minified) {
require_once 'JShrink/Minifier.php';
$out .= Minifier::minify($js, ['flaggedComments' => false]);
$baseOut = Minifier::minify($baseJs, ['flaggedComments' => false]);
$out = ';' . ltrim($baseOut, ';') . "\n" . $out;
Expand Down
25 changes: 0 additions & 25 deletions library/vendor/HTMLPurifier.autoload.php

This file was deleted.

Loading