Skip to content

Commit

Permalink
Remove requiring vendor dependencies
Browse files Browse the repository at this point in the history
Also avoid autoloading vendor.
  • Loading branch information
raviks789 authored and nilmerg committed Aug 9, 2023
1 parent 50bd5cf commit 8a17c56
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 90 deletions.
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
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
2 changes: 0 additions & 2 deletions modules/doc/library/Doc/Renderer/DocSectionRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Icinga\Module\Doc\Renderer;

require_once 'Parsedown/Parsedown.php';

use DOMDocument;
use DOMXPath;
use Parsedown;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ class Zend_View_Helper_EscapeComment extends Zend_View_Helper_Abstract
public function escapeComment($comment)
{
if (self::$purifier === null) {
require_once 'HTMLPurifier/Bootstrap.php';
require_once 'HTMLPurifier.php';
require_once 'HTMLPurifier.autoload.php';

$config = HTMLPurifier_Config::createDefault();
$config->set('Core.EscapeNonASCIICharacters', true);
$config->set('HTML.Allowed', 'a[href]');
Expand Down

0 comments on commit 8a17c56

Please sign in to comment.