From 423c58d710b6bd7c87e9df2d1e0d244ec3b55338 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 14:58:50 +0200 Subject: [PATCH 01/30] Remove deprecated class `Icinga/Util/String` --- library/Icinga/Util/String.php | 159 --------------------------------- 1 file changed, 159 deletions(-) delete mode 100644 library/Icinga/Util/String.php diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php deleted file mode 100644 index 1a879077c..000000000 --- a/library/Icinga/Util/String.php +++ /dev/null @@ -1,159 +0,0 @@ - $maxLength) { - return substr($string, 0, $maxLength - strlen($ellipsis)) . $ellipsis; - } - - return $string; - } - - /** - * Add ellipsis in the center of a string when a string is longer than max length - * - * @param string $string - * @param int $maxLength - * @param string $ellipsis - * - * @return string - */ - public static function ellipsisCenter($string, $maxLength, $ellipsis = '...') - { - $start = ceil($maxLength / 2.0); - $end = floor($maxLength / 2.0); - if (strlen($string) > $maxLength) { - return substr($string, 0, $start - strlen($ellipsis)) . $ellipsis . substr($string, - $end); - } - - return $string; - } - - /** - * Find and return all similar strings in $possibilites matching $string with the given minimum $similarity - * - * @param string $string - * @param array $possibilities - * @param float $similarity - * - * @return array - */ - public static function findSimilar($string, array $possibilities, $similarity = 0.33) - { - if (empty($string)) { - return array(); - } - - $matches = array(); - foreach ($possibilities as $possibility) { - $distance = levenshtein($string, $possibility); - if ($distance / strlen($string) <= $similarity) { - $matches[] = $possibility; - } - } - - return $matches; - } - - /** - * Test whether the given string ends with the given suffix - * - * @param string $string The string to test - * @param string $suffix The suffix the string must end with - * - * @return bool - */ - public static function endsWith($string, $suffix) - { - $stringSuffix = substr($string, -strlen($suffix)); - return $stringSuffix !== false ? $stringSuffix === $suffix : false; - } - - /** - * Generates an array of strings that constitutes the cartesian product of all passed sets, with all - * string combinations concatenated using the passed join-operator. - * - *
-     *  cartesianProduct(
-     *      array(array('foo', 'bar'), array('mumble', 'grumble', null)),
-     *      '_'
-     *  );
-     *     => array('foo_mumble', 'foo_grumble', 'bar_mumble', 'bar_grumble', 'foo', 'bar')
-     * 
- * - * @param array $sets An array of arrays containing all sets for which the cartesian - * product should be calculated. - * @param string $glue The glue used to join the strings, defaults to ''. - * - * @returns array The cartesian product in one array of strings. - */ - public static function cartesianProduct(array $sets, $glue = '') - { - $product = null; - foreach ($sets as $set) { - if (! isset($product)) { - $product = $set; - } else { - $newProduct = array(); - foreach ($product as $strA) { - foreach ($set as $strB) { - if ($strB === null) { - $newProduct []= $strA; - } else { - $newProduct []= $strA . $glue . $strB; - } - } - } - $product = $newProduct; - } - } - return $product; - } -} From 3113dc06acaab9846efaf993b1eedd19d13bbd5d Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:00:11 +0200 Subject: [PATCH 02/30] Remove deprecated class `Icinga/Util/Translator` --- library/Icinga/Util/Translator.php | 184 ----------------------------- 1 file changed, 184 deletions(-) delete mode 100644 library/Icinga/Util/Translator.php diff --git a/library/Icinga/Util/Translator.php b/library/Icinga/Util/Translator.php deleted file mode 100644 index 15b3c727e..000000000 --- a/library/Icinga/Util/Translator.php +++ /dev/null @@ -1,184 +0,0 @@ -translateInDomain($domain, $text, $context); - } - - /** - * Translate a plural string - * - * Falls back to the default domain in case the string cannot be translated using the given domain - * - * @param string $textSingular The string in singular form to translate - * @param string $textPlural The string in plural form to translate - * @param integer $number The amount to determine from whether to return singular or plural - * @param string $domain The primary domain to use - * @param string|null $context Optional parameter for context based translation - * - * @return string The translated string - */ - public static function translatePlural($textSingular, $textPlural, $number, $domain, $context = null) - { - return StaticTranslator::$instance->translatePluralInDomain( - $domain, - $textSingular, - $textPlural, - $number, - $context - ); - } - - /** - * Emulated pgettext() - * - * @link http://php.net/manual/de/book.gettext.php#89975 - * - * @param $text - * @param $domain - * @param $context - * - * @return string - */ - public static function pgettext($text, $domain, $context) - { - return StaticTranslator::$instance->translateInDomain($domain, $text, $context); - } - - /** - * Emulated pngettext() - * - * @link http://php.net/manual/de/book.gettext.php#89975 - * - * @param $textSingular - * @param $textPlural - * @param $number - * @param $domain - * @param $context - * - * @return string - */ - public static function pngettext($textSingular, $textPlural, $number, $domain, $context) - { - return StaticTranslator::$instance->translatePluralInDomain( - $domain, - $textSingular, - $textPlural, - $number, - $context - ); - } - - /** - * Register a new gettext domain - * - * @param string $name The name of the domain to register - * @param string $directory The directory where message catalogs can be found - * - * @return void - */ - public static function registerDomain($name, $directory) - { - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - $translator->addTranslationDirectory($directory, $name); - } - - /** - * Set the locale to use - * - * @param string $localeName The name of the locale to use - * - * @return void - */ - public static function setupLocale($localeName) - { - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - $translator->setLocale($localeName); - } - - /** - * Split and return the language code and country code of the given locale or the current locale - * - * @param string $locale The locale code to split, or null to split the current locale - * - * @return object An object with a 'language' and 'country' attribute - */ - public static function splitLocaleCode($locale = null) - { - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - if ($locale === null) { - $locale = $translator->getLocale(); - } - - return (new Locale())->parseLocale($locale); - } - - /** - * Return a list of all locale codes currently available in the known domains - * - * @return array - */ - public static function getAvailableLocaleCodes() - { - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - return $translator->listLocales(); - } - - /** - * Return the preferred locale based on the given HTTP header and the available translations - * - * @param string $header The HTTP "Accept-Language" header - * - * @return string The browser's preferred locale code - */ - public static function getPreferredLocaleCode($header) - { - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - return (new Locale())->getPreferred($header, $translator->listLocales()); - } -} From 8fc50645c4a2dfe1b8094cca7d11dc2408ed64d1 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:01:51 +0200 Subject: [PATCH 03/30] AesCrypt: Remove deprecated methods `encryptToBase64()` and `decryptFromBase64()` --- library/Icinga/Crypt/AesCrypt.php | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/library/Icinga/Crypt/AesCrypt.php b/library/Icinga/Crypt/AesCrypt.php index b2ba0eaca..8e9d45348 100644 --- a/library/Icinga/Crypt/AesCrypt.php +++ b/library/Icinga/Crypt/AesCrypt.php @@ -244,22 +244,6 @@ class AesCrypt return $decrypt; } - /** - * Decode from Base64 and decrypt the given string - * - * @param string $data - * - * @return string The base64 decoded and decrypted string - * - * @deprecated Use decrypt() instead as it also returns a base64 decoded string - * - * @throws RuntimeException If decryption fails - */ - public function decryptFromBase64($data) - { - return $this->decrypt(base64_decode($data)); - } - /** * Encrypt the given string * @@ -284,22 +268,6 @@ class AesCrypt return $encrypt; } - /** - * Encrypt the given string and encode to Base64 - * - * @param string $data - * - * @return string encrypted and base64 encoded string - * - * @deprecated Use encrypt() instead as it also returns a base64 encoded string - * - * @throws RuntimeException If encryption fails - */ - public function encryptToBase64($data) - { - return base64_encode($this->encrypt($data)); - } - /** * Decrypt the given string with non Authenticated encryption (AE) cipher method * From b1f723318fba86d3eac0173c40460c371103a219 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:08:16 +0200 Subject: [PATCH 04/30] Web: Remove deprecated method `getMenu()` --- library/Icinga/Application/Web.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 3cf6faeac..1631422e1 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -20,7 +20,6 @@ use Icinga\User; use Icinga\Util\DirectoryIterator; use Icinga\Util\TimezoneDetect; use Icinga\Web\Controller\Dispatcher; -use Icinga\Web\Menu; use Icinga\Web\Navigation\Navigation; use Icinga\Web\Notification; use Icinga\Web\Session; @@ -284,18 +283,6 @@ class Web extends EmbeddedWeb return $navigation; } - /** - * Return the app's menu - * - * @deprecated Instantiate the returned class directly instead of using this method. - * - * @return Menu - */ - public function getMenu() - { - return new Menu(); - } - /** * Dispatch public interface */ From 479bec6fb436a33f1691191d5d7e04718ec6f3c0 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:14:44 +0200 Subject: [PATCH 05/30] ApplicationBootstrap: Remove deprecated method `listLocales()` --- .../Icinga/Application/ApplicationBootstrap.php | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 66f710b19..3e1078d86 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -766,19 +766,4 @@ abstract class ApplicationBootstrap $localedir = $this->getLocaleDir(); return $localedir !== false && file_exists($localedir) && is_dir($localedir); } - - /** - * List all available locales - * - * @return array Locale list - * - * @deprecated Use {@see \ipl\I18n\GettextTranslator::listLocales()} instead - */ - public function listLocales() - { - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - return $translator->listLocales(); - } } From 55d23a531ff02ec46f7af1fa460c55c56d47a33f Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:17:10 +0200 Subject: [PATCH 06/30] Module: Remove deprecated method `registerHook()` --- library/Icinga/Application/Modules/Module.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/library/Icinga/Application/Modules/Module.php b/library/Icinga/Application/Modules/Module.php index a4af34220..97650659f 100644 --- a/library/Icinga/Application/Modules/Module.php +++ b/library/Icinga/Application/Modules/Module.php @@ -1388,22 +1388,6 @@ class Module return $this->includeScript($this->configScript); } - /** - * Register a hook - * - * @param string $name Name of the hook - * @param string $class Class of the hook w/ namespace - * @param string $key - * - * @return $this - * - * @deprecated Deprecated since 2.1.1. Use {@link provideHook()} instead - */ - protected function registerHook($name, $class, $key = null) - { - return $this->provideHook($name, $class, $key); - } - protected function slashesToNamespace($class) { $list = explode('/', $class); From a9af8f2e1aca1e1328c0a445e630175aa5b14cfa Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:23:05 +0200 Subject: [PATCH 07/30] Url: Remove deprecated methods `setBaseUrl()` and `getBaseUrl()` --- library/Icinga/Web/Url.php | 69 -------------------------------------- 1 file changed, 69 deletions(-) diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index 5a4192a68..f4fcba381 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -367,75 +367,6 @@ class Url return $this->scheme; } - /** - * Set the baseUrl for this url - * - * @deprecated Please create a new url from scratch instead - * - * @param string $baseUrl The url path to use as the url base - * - * @return $this - */ - public function setBaseUrl($baseUrl) - { - $urlParts = parse_url($baseUrl); - if (isset($urlParts["host"])) { - $this->setHost($urlParts["host"]); - } - if (isset($urlParts["port"])) { - $this->setPort($urlParts["port"]); - } - if (isset($urlParts['scheme'])) { - $this->setScheme($urlParts['scheme']); - } - if (isset($urlParts['user'])) { - $this->setUsername($urlParts['user']); - } - if (isset($urlParts['pass'])) { - $this->setPassword($urlParts['pass']); - } - if (isset($urlParts['path'])) { - $this->setBasePath($urlParts['path']); - } - - return $this; - } - - /** - * Return the baseUrl for this url - * - * @deprecated - * - * @return string - */ - public function getBaseUrl() - { - if (! $this->isExternal()) { - return $this->getBasePath(); - } - - $urlString = ''; - if ($this->getScheme()) { - $urlString .= $this->getScheme() . '://'; - } - if ($this->getPassword()) { - $urlString .= $this->getUsername() . ':' . $this->getPassword() . '@'; - } elseif ($this->getUsername()) { - $urlString .= $this->getUsername() . '@'; - } - if ($this->getHost()) { - $urlString .= $this->getHost(); - } - if ($this->getPort()) { - $urlString .= ':' . $this->getPort(); - } - if ($this->getBasePath()) { - $urlString .= $this->getBasePath(); - } - - return $urlString; - } - /** * Set the relative path of this url, without query parameters * From 58ac2a97c27eb96aeb74a851ef9f2e5560bd698e Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:24:21 +0200 Subject: [PATCH 08/30] InlinPie: Remove deprecated method `disableNoScript()` --- library/Icinga/Web/Widget/Chart/InlinePie.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/library/Icinga/Web/Widget/Chart/InlinePie.php b/library/Icinga/Web/Widget/Chart/InlinePie.php index de1bbea7c..21b4ca490 100644 --- a/library/Icinga/Web/Widget/Chart/InlinePie.php +++ b/library/Icinga/Web/Widget/Chart/InlinePie.php @@ -134,15 +134,6 @@ class InlinePie extends AbstractWidget return $this; } - /** - * Do not display the NoScript fallback html - * - * @deprecated noop - */ - public function disableNoScript() - { - } - /** * Set the class to define the * From 577d97a45013458396c889fca87c5d4c905c4999 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:38:33 +0200 Subject: [PATCH 09/30] DataView: Move `sort()` body to `order()` and remove `sort()` and `fromRequest()` --- .../library/Monitoring/DataView/DataView.php | 56 ++++--------------- 1 file changed, 11 insertions(+), 45 deletions(-) diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index cd0542289..42ec1e75e 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -123,23 +123,6 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ abstract public function getColumns(); - /** - * Create view from request - * - * @param Request $request - * @param array $columns - * - * @return static - * @deprecated Use $backend->select()->from($viewName) instead - */ - public static function fromRequest($request, array $columns = null) - { - $view = new static(MonitoringBackend::instance($request->getParam('backend')), $columns); - $view->applyUrlFilter($request); - - return $view; - } - protected function getHookedColumns() { $columns = array(); @@ -200,7 +183,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite } } - $view->sort($params['sort'], $order); + $view->order($params['sort'], $order); } return $view; } @@ -324,18 +307,14 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite } /** - * Sort the rows, according to the specified sort column and order + * Sort result set either by the given column (and direction) or the sort defaults * - * @param string $column Sort column - * @param string $order Sort order, one of the SORT_ constants + * @param string $column + * @param string $direction * - * @return $this - * @throws QueryException If the sort column is not allowed - * @see DataView::SORT_ASC - * @see DataView::SORT_DESC - * @deprecated Use DataView::order() instead + * @return $this */ - public function sort($column = null, $order = null) + public function order($column = null, $direction = null) { $sortRules = $this->getSortRules(); if ($column === null) { @@ -356,16 +335,16 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite } else { $sortColumns = array( 'columns' => array($column), - 'order' => $order + 'order' => $direction ); }; } - $order = $order === null ? (isset($sortColumns['order']) ? $sortColumns['order'] : static::SORT_ASC) : $order; - $order = (strtoupper($order) === static::SORT_ASC) ? 'ASC' : 'DESC'; + $direction = $direction === null ? ($sortColumns['order'] ?? static::SORT_ASC) : $direction; + $direction = (strtoupper($direction) === static::SORT_ASC) ? 'ASC' : 'DESC'; foreach ($sortColumns['columns'] as $column) { - list($column, $direction) = $this->query->splitOrder($column); + list($column, $order) = $this->query->splitOrder($column); if (! $this->isValidFilterTarget($column)) { throw new QueryException( mt('monitoring', 'The sort column "%s" is not allowed in "%s".'), @@ -373,7 +352,7 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite get_class($this) ); } - $this->query->order($column, $direction !== null ? $direction : $order); + $this->query->order($column, $order !== null ? $order : $direction); } $this->isSorted = true; return $this; @@ -389,19 +368,6 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite return array(); } - /** - * Sort result set either by the given column (and direction) or the sort defaults - * - * @param string $column - * @param string $direction - * - * @return $this - */ - public function order($column = null, $direction = null) - { - return $this->sort($column, $direction); - } - /** * Whether an order is set * From eb768b4fce69252c53fbc29b464d8c3f3f35c985 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:40:47 +0200 Subject: [PATCH 10/30] Remove deprecated method `ApplicationBootstrap::setupZendAutoloader()` and its uses --- library/Icinga/Application/ApplicationBootstrap.php | 11 ----------- library/Icinga/Application/EmbeddedWeb.php | 1 - library/Icinga/Application/Web.php | 1 - 3 files changed, 13 deletions(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 3e1078d86..b55049548 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -434,17 +434,6 @@ abstract class ApplicationBootstrap return $this; } - /** - * Register the Zend Autoloader - compat only - does nothing - * - * @deprecated - * @return $this - */ - public function setupZendAutoloader() - { - return $this; - } - /** * Setup module manager * diff --git a/library/Icinga/Application/EmbeddedWeb.php b/library/Icinga/Application/EmbeddedWeb.php index 763ced121..8d03e1133 100644 --- a/library/Icinga/Application/EmbeddedWeb.php +++ b/library/Icinga/Application/EmbeddedWeb.php @@ -65,7 +65,6 @@ class EmbeddedWeb extends ApplicationBootstrap protected function bootstrap() { return $this - ->setupZendAutoloader() ->setupErrorHandling() ->loadLibraries() ->loadConfig() diff --git a/library/Icinga/Application/Web.php b/library/Icinga/Application/Web.php index 1631422e1..4ce9b45a6 100644 --- a/library/Icinga/Application/Web.php +++ b/library/Icinga/Application/Web.php @@ -81,7 +81,6 @@ class Web extends EmbeddedWeb protected function bootstrap() { return $this - ->setupZendAutoloader() ->setupLogging() ->setupErrorHandling() ->loadLibraries() From a3afc1cf5db8a326d4f761eb6c3939e303f8211a Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:45:32 +0200 Subject: [PATCH 11/30] loader.js: Remove deprecated method ` addUrlFlag()` --- public/js/icinga/loader.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index 5e4e01bf8..81d77a4c3 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -443,21 +443,6 @@ return true; }, - /** - * Add the specified flag to the given URL - * - * @param {string} url - * @param {string} flag - * - * @returns {string} - * - * @deprecated since version 2.8.0. Use {@link Icinga.Utils.addUrlFlag()} instead - */ - addUrlFlag: function(url, flag) - { - return this.icinga.utils.addUrlFlag(url, flag); - }, - /** * Process the X-Icinga-Redirect HTTP Response Header * From aded6a055ef079bb0a6b785f6626325a8f8005fd Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:48:05 +0200 Subject: [PATCH 12/30] DbConnection: Remove deprecated method `getConnection()` --- library/Icinga/Data/Db/DbConnection.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/library/Icinga/Data/Db/DbConnection.php b/library/Icinga/Data/Db/DbConnection.php index 4622c6ce7..fc6814db3 100644 --- a/library/Icinga/Data/Db/DbConnection.php +++ b/library/Icinga/Data/Db/DbConnection.php @@ -268,14 +268,6 @@ class DbConnection implements Selectable, Extensible, Updatable, Reducible, Insp return new static(ResourceFactory::getResourceConfig($name)); } - /** - * @deprecated Use Connection::getDbAdapter() instead - */ - public function getConnection() - { - return $this->dbAdapter; - } - /** * Getter for the table prefix * From 8f0ac0492d3c2ed81ec70497bd0346d1b68d88a9 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:50:38 +0200 Subject: [PATCH 13/30] Replace deprecated method `DbConnection::getConnection()` with `DbConnection::getDbAdapter()` --- library/Icinga/Test/BaseTestCase.php | 4 ++-- .../library/Icinga/Test/BaseTestCaseTest.php | 20 +++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/library/Icinga/Test/BaseTestCase.php b/library/Icinga/Test/BaseTestCase.php index 4509315ec..6702df02f 100644 --- a/library/Icinga/Test/BaseTestCase.php +++ b/library/Icinga/Test/BaseTestCase.php @@ -305,7 +305,7 @@ namespace Icinga\Test { ); } - $resource->getConnection()->exec($sqlData); + $resource->getDbAdapter()->exec($sqlData); } /** @@ -324,7 +324,7 @@ namespace Icinga\Test { return; } - $adapter = $resource->getConnection(); + $adapter = $resource->getDbAdapter(); try { $adapter->getConnection(); diff --git a/test/php/library/Icinga/Test/BaseTestCaseTest.php b/test/php/library/Icinga/Test/BaseTestCaseTest.php index 5c06ad966..92a8d2f77 100644 --- a/test/php/library/Icinga/Test/BaseTestCaseTest.php +++ b/test/php/library/Icinga/Test/BaseTestCaseTest.php @@ -25,7 +25,7 @@ class BaseTestCaseTest extends BaseTestCase public function testWhetherMySqlProviderAnnotationSetsUpZendDbAdapter($resource) { $this->setupDbProvider($resource); - $this->assertInstanceOf('Zend_Db_Adapter_Pdo_Mysql', $resource->getConnection()); + $this->assertInstanceOf('Zend_Db_Adapter_Pdo_Mysql', $resource->getDbAdapter()); } /** @@ -43,7 +43,7 @@ class BaseTestCaseTest extends BaseTestCase public function testWhetherCreatingTablesWithMySqlAdapterWorks($resource) { $this->setupDbProvider($resource); - $adapter = $resource->getConnection(); + $adapter = $resource->getDbAdapter(); $adapter->exec('CREATE TABLE test(uid INT NOT NULL PRIMARY KEY);'); $tables = $adapter->listTables(); @@ -58,7 +58,7 @@ class BaseTestCaseTest extends BaseTestCase { $this->setupDbProvider($resource); - $tables = $resource->getConnection()->listTables(); + $tables = $resource->getDbAdapter()->listTables(); $this->assertCount(0, $tables); } @@ -68,7 +68,7 @@ class BaseTestCaseTest extends BaseTestCase public function testWhetherPgSqlProviderAnnotationSetsUpZendDbAdapter($resource) { $this->setupDbProvider($resource); - $this->assertInstanceOf('Zend_Db_Adapter_Pdo_Pgsql', $resource->getConnection()); + $this->assertInstanceOf('Zend_Db_Adapter_Pdo_Pgsql', $resource->getDbAdapter()); } /** @@ -86,7 +86,7 @@ class BaseTestCaseTest extends BaseTestCase public function testWhetherCreatingTablesWithPgSqlAdapterWorks($resource) { $this->setupDbProvider($resource); - $adapter = $resource->getConnection(); + $adapter = $resource->getDbAdapter(); $adapter->exec('CREATE TABLE test(uid INT NOT NULL PRIMARY KEY);'); $tables = $adapter->listTables(); @@ -101,7 +101,7 @@ class BaseTestCaseTest extends BaseTestCase { $this->setupDbProvider($resource); - $tables = $resource->getConnection()->listTables(); + $tables = $resource->getDbAdapter()->listTables(); $this->assertCount(0, $tables); } @@ -111,7 +111,7 @@ class BaseTestCaseTest extends BaseTestCase public function testWhetherOciProviderAnnotationSetsUpZendDbAdapter($resource) { $this->setupDbProvider($resource); - $this->assertInstanceOf('Zend_Db_Adapter_Pdo_Oci', $resource->getConnection()); + $this->assertInstanceOf('Zend_Db_Adapter_Pdo_Oci', $resource->getDbAdapter()); } /** @@ -129,7 +129,7 @@ class BaseTestCaseTest extends BaseTestCase public function testWhetherCreatingTablesWithOciAdapterWorks($resource) { $this->setupDbProvider($resource); - $adapter = $resource->getConnection(); + $adapter = $resource->getDbAdapter(); $adapter->exec('CREATE TABLE test(uid INT NOT NULL PRIMARY KEY);'); $tables = $adapter->listTables(); @@ -144,7 +144,7 @@ class BaseTestCaseTest extends BaseTestCase { $this->setupDbProvider($resource); - $tables = $resource->getConnection()->listTables(); + $tables = $resource->getDbAdapter()->listTables(); $this->assertCount(0, $tables); } @@ -176,7 +176,7 @@ class BaseTestCaseTest extends BaseTestCase $this->loadSql($resource, $tempFile); - $count = (int) $resource->getConnection()->fetchOne('SELECT COUNT(*) as cntX from dummyData;'); + $count = (int) $resource->getDbAdapter()->fetchOne('SELECT COUNT(*) as cntX from dummyData;'); $this->assertSame(20, $count); $this->assertTrue(unlink($tempFile)); From b47298fffea1a9cb28753f9276c1fd04f3b2240c Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:52:36 +0200 Subject: [PATCH 14/30] SimpleQuery: Remove deprecated method `paginate()` --- library/Icinga/Data/SimpleQuery.php | 40 ----------------------------- 1 file changed, 40 deletions(-) diff --git a/library/Icinga/Data/SimpleQuery.php b/library/Icinga/Data/SimpleQuery.php index 251fcca25..1ef0c275b 100644 --- a/library/Icinga/Data/SimpleQuery.php +++ b/library/Icinga/Data/SimpleQuery.php @@ -5,13 +5,10 @@ namespace Icinga\Data; use Iterator; use IteratorAggregate; -use Zend_Paginator; -use Icinga\Application\Icinga; use Icinga\Application\Benchmark; use Icinga\Data\Filter\Filter; use Icinga\Exception\IcingaException; use Icinga\Exception\ProgrammingError; -use Icinga\Web\Paginator\Adapter\QueryAdapter; class SimpleQuery implements QueryInterface, Queryable, Iterator { @@ -517,43 +514,6 @@ class SimpleQuery implements QueryInterface, Queryable, Iterator return $this->limitOffset; } - /** - * Paginate data - * - * Auto-detects pagination parameters from request when unset - * - * @param int $itemsPerPage Number of items per page - * @param int $pageNumber Current page number - * - * @return Zend_Paginator - * - * @deprecated Use Icinga\Web\Controller::setupPaginationControl() and/or Icinga\Web\Widget\Paginator instead - */ - public function paginate($itemsPerPage = null, $pageNumber = null) - { - trigger_error( - 'SimpleQuery::paginate() is deprecated. Use Icinga\Web\Controller::setupPaginationControl()' - . ' and/or Icinga\Web\Widget\Paginator instead', - E_USER_DEPRECATED - ); - - if ($itemsPerPage === null || $pageNumber === null) { - // Detect parameters from request - $request = Icinga::app()->getRequest(); - if ($itemsPerPage === null) { - $itemsPerPage = $request->getParam('limit', 25); - } - if ($pageNumber === null) { - $pageNumber = $request->getParam('page', 0); - } - } - $this->limit($itemsPerPage, $pageNumber * $itemsPerPage); - $paginator = new Zend_Paginator(new QueryAdapter($this)); - $paginator->setItemCountPerPage($itemsPerPage); - $paginator->setCurrentPageNumber($pageNumber); - return $paginator; - } - /** * Retrieve an array containing all rows of the result set * From bba77b52e7029984f656fbeff7ac30804257c13d Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:53:24 +0200 Subject: [PATCH 15/30] LdapConnection: Remove deprecated method `connect()` --- library/Icinga/Protocol/Ldap/LdapConnection.php | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/library/Icinga/Protocol/Ldap/LdapConnection.php b/library/Icinga/Protocol/Ldap/LdapConnection.php index 3d7db67e4..a1d6a2edf 100644 --- a/library/Icinga/Protocol/Ldap/LdapConnection.php +++ b/library/Icinga/Protocol/Ldap/LdapConnection.php @@ -321,18 +321,6 @@ class LdapConnection implements Selectable, Inspectable return $this->encrypted; } - /** - * Establish a connection - * - * @throws LdapException In case the connection could not be established - * - * @deprecated The connection is established lazily now - */ - public function connect() - { - $this->getConnection(); - } - /** * Perform a LDAP bind on the current connection * From 49bea363459ebe8a845f160156ecd7c089c3c549 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:54:42 +0200 Subject: [PATCH 16/30] MonitoringBackend: Remove deprecated method `createBackedn()` --- .../Monitoring/Backend/MonitoringBackend.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php index 164687623..5400957bd 100644 --- a/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php +++ b/modules/monitoring/library/Monitoring/Backend/MonitoringBackend.php @@ -197,23 +197,6 @@ class MonitoringBackend implements Selectable, Queryable, ConnectionInterface } } - /** - * Create a backend - * - * @deprecated - * - * @param string $backendName Name of the backend or null for creating the default backend which is the first INI - * configuration entry not being disabled - * - * @return Backend - * @throws ConfigurationError When no backend has been configured or all backends are disabled or the - * configuration for the requested backend does either not exist or it's disabled - */ - public static function createBackend($name = null) - { - return self::instance($name); - } - /** * Get this backend's internal resource * From 60756afa34bc15c0f2b32ed84965ad10805043b6 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:55:30 +0200 Subject: [PATCH 17/30] Replace `MonitoringBackend::createBackend()` with `MonitoringBackend::instance()` --- modules/monitoring/application/clicommands/ListCommand.php | 3 +-- .../monitoring/application/controllers/ConfigController.php | 4 ++-- modules/monitoring/library/Monitoring/Controller.php | 2 +- modules/monitoring/test/php/regression/Bug7043Test.php | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/modules/monitoring/application/clicommands/ListCommand.php b/modules/monitoring/application/clicommands/ListCommand.php index 5cf804a77..9020c6ec2 100644 --- a/modules/monitoring/application/clicommands/ListCommand.php +++ b/modules/monitoring/application/clicommands/ListCommand.php @@ -25,8 +25,7 @@ class ListCommand extends Command public function init() { - $this->app->setupZendAutoloader(); - $this->backend = Backend::createBackend($this->params->shift('backend')); + $this->backend = Backend::instance($this->params->shift('backend')); $this->dumpSql = $this->params->shift('showsql'); } diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index 92444b654..7c4e4315e 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -215,7 +215,7 @@ class ConfigController extends Controller $form->setTitle(sprintf($this->translate('Edit Command Transport %s'), $transportName)); $form->setIniConfig($this->Config('commandtransports')); $form->setInstanceNames( - Backend::createBackend()->select()->from('instance', array('instance_name'))->fetchColumn() + Backend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() ); $form->setOnSuccess(function (TransportConfigForm $form) use ($transportName) { try { @@ -259,7 +259,7 @@ class ConfigController extends Controller $form->setTitle($this->translate('Create New Command Transport')); $form->setIniConfig($this->Config('commandtransports')); $form->setInstanceNames( - Backend::createBackend()->select()->from('instance', array('instance_name'))->fetchColumn() + Backend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() ); $form->setOnSuccess(function (TransportConfigForm $form) { try { diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index dc3c75973..5af6ebb63 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -28,7 +28,7 @@ class Controller extends IcingaWebController protected function moduleInit() { - $this->backend = Backend::createBackend($this->_getParam('backend')); + $this->backend = Backend::instance($this->_getParam('backend')); $this->view->url = Url::fromRequest(); } diff --git a/modules/monitoring/test/php/regression/Bug7043Test.php b/modules/monitoring/test/php/regression/Bug7043Test.php index ba9291be6..949925f7c 100644 --- a/modules/monitoring/test/php/regression/Bug7043Test.php +++ b/modules/monitoring/test/php/regression/Bug7043Test.php @@ -53,7 +53,7 @@ class Bug7043Test extends BaseTestCase ) ))); - $defaultBackend = Backend::createBackend(); + $defaultBackend = Backend::instance(); $this->assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set'); } From be1ff03dd359506d7e288c1f02ff32438f02ac72 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 2 May 2022 15:58:14 +0200 Subject: [PATCH 18/30] MonitoredObject: Remove deprecated methods `matches()` and `fromParams()` --- .../Monitoring/Object/MonitoredObject.php | 37 ------------------- 1 file changed, 37 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php index c83b014dc..91fd9e760 100644 --- a/modules/monitoring/library/Monitoring/Object/MonitoredObject.php +++ b/modules/monitoring/library/Monitoring/Object/MonitoredObject.php @@ -234,30 +234,6 @@ abstract class MonitoredObject implements Filterable // Left out on purpose. Interface is deprecated. } - /** - * Return whether this object matches the given filter - * - * @param Filter $filter - * - * @return bool - * - * @throws ProgrammingError In case the object cannot be found - * - * @deprecated Use $filter->matches($object) instead - */ - public function matches(Filter $filter) - { - if ($this->properties === null && $this->fetch() === false) { - throw new ProgrammingError( - 'Unable to apply filter. Object %s of type %s not found.', - $this->getName(), - $this->getType() - ); - } - - return $filter->matches($this); - } - /** * Require the object's type to be one of the given types * @@ -951,17 +927,4 @@ abstract class MonitoredObject implements Filterable throw new InvalidPropertyException('Can\'t access property \'%s\'. Property does not exist.', $name); } - - /** - * @deprecated - */ - public static function fromParams(UrlParams $params) - { - if ($params->has('service') && $params->has('host')) { - return new Service(MonitoringBackend::instance(), $params->get('host'), $params->get('service')); - } elseif ($params->has('host')) { - return new Host(MonitoringBackend::instance(), $params->get('host')); - } - return null; - } } From 846a90301d85f06fbc8e8dcb11b2e09762161001 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Tue, 3 May 2022 14:45:41 +0200 Subject: [PATCH 19/30] DbQuery: Replace deprecated method `renderFilter()` and remove it --- library/Icinga/Data/Db/DbQuery.php | 45 +----------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index 29dcefeb2..fea82179b 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -179,55 +179,12 @@ class DbQuery extends SimpleQuery protected function applyFilterSql($select) { - $where = $this->renderFilter($this->filter); + $where = $this->getDatasource()->renderFilter($this->filter); if ($where !== '') { $select->where($where); } } - /** - * @deprecated Use DbConnection::renderFilter() instead! - */ - protected function renderFilter($filter, $level = 0) - { - $str = ''; - if ($filter instanceof FilterChain) { - if ($filter instanceof FilterAnd) { - $op = ' AND '; - } elseif ($filter instanceof FilterOr) { - $op = ' OR '; - } elseif ($filter instanceof FilterNot) { - $op = ' AND '; - $str .= ' NOT '; - } else { - throw new QueryException( - 'Cannot render filter: %s', - $filter - ); - } - $parts = array(); - if (! $filter->isEmpty()) { - foreach ($filter->filters() as $f) { - $filterPart = $this->renderFilter($f, $level + 1); - if ($filterPart !== '') { - $parts[] = $filterPart; - } - } - if (! empty($parts)) { - if ($level > 0) { - $str .= ' (' . implode($op, $parts) . ') '; - } else { - $str .= implode($op, $parts); - } - } - } - } else { - $str .= $this->whereToSql($filter->getColumn(), $filter->getSign(), $filter->getExpression()); - } - - return $str; - } - protected function escapeForSql($value) { // bindParam? bindValue? From 8301cae1a9a995624372243d0630f02346b8ce8b Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 13 May 2022 14:41:07 +0200 Subject: [PATCH 20/30] migrate: Remove `dashboard sections` command --- .../clicommands/DashboardCommand.php | 127 ------------------ 1 file changed, 127 deletions(-) delete mode 100644 modules/migrate/application/clicommands/DashboardCommand.php diff --git a/modules/migrate/application/clicommands/DashboardCommand.php b/modules/migrate/application/clicommands/DashboardCommand.php deleted file mode 100644 index 36a12fc5e..000000000 --- a/modules/migrate/application/clicommands/DashboardCommand.php +++ /dev/null @@ -1,127 +0,0 @@ -getMethod('launchConfigScript'); - $launchConfigScriptMethod->setAccessible(true); - // Calling getDashboard() results in Url::fromPath() getting called as well == the CLI's death - $paneItemsProperty = $moduleReflection->getProperty('paneItems'); - $paneItemsProperty->setAccessible(true); - - /** @var GettextTranslator $translator */ - $translator = StaticTranslator::$instance; - - $locales = $translator->listLocales(); - $modules = Icinga::app()->getModuleManager()->getLoadedModules(); - foreach ($this->listDashboardConfigs() as $path) { - Logger::info('Migrating dashboard config: %s', $path); - - $config = Config::fromIni($path); - foreach ($modules as $module) { - if (! $module->hasLocales()) { - // Modules without any translations are not affected - continue; - } - - $launchConfigScriptMethod->invoke($module); - - foreach ($locales as $locale) { - if ($locale === 'en_US') { - continue; - } - - try { - $translator->setLocale($locale); - } catch (Exception $e) { - Logger::debug('Ignoring locale "%s". Reason: %s', $locale, $e->getMessage()); - continue; - } - - foreach ($paneItemsProperty->getValue($module) as $paneName => $container) { - /** @var DashboardContainer $container */ - foreach ($config->toArray() as $section => $options) { - if (strpos($section, '.') !== false) { - list($paneTitle, $dashletTitle) = explode('.', $section, 2); - } else { - $paneTitle = $section; - $dashletTitle = null; - } - - if (mt($module->getName(), $paneName) !== $paneTitle) { - continue; - } - - $dashletName = null; - if ($dashletTitle !== null) { - foreach ($container->getDashlets() as $name => $url) { - if (mt($module->getName(), $name) === $dashletTitle) { - $dashletName = $name; - break; - } - } - - if ($dashletName === null) { - $dashletName = $dashletTitle; - } - } - - $newSection = $paneName . ($dashletName ? '.' . $dashletName : ''); - $config->removeSection($section); - $config->setSection($newSection, $options); - - Logger::info('Migrated section "%s" to "%s"', $section, $newSection); - } - } - } - } - - $config->saveIni(); - } - } - - protected function listDashboardConfigs() - { - $dashboardConfigPath = Config::resolvePath('dashboards'); - - try { - $dashboardConfigDir = opendir($dashboardConfigPath); - } catch (Exception $e) { - Logger::error('Cannot access dashboard configuration: %s', $e); - exit(1); - } - - while ($entry = readdir($dashboardConfigDir)) { - $userDashboardPath = join(DIRECTORY_SEPARATOR, [$dashboardConfigPath, $entry, 'dashboard.ini']); - if (is_file($userDashboardPath)) { - yield $userDashboardPath; - } - } - } -} From e179f9cf3fee6aa0c2114c0a2871f6967db5b833 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Fri, 6 May 2022 10:42:31 +0200 Subject: [PATCH 21/30] Update `80-Upgrading.md` --- doc/80-Upgrading.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index 44dc60575..c8844e444 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -16,6 +16,41 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. In package installations this file can be found in `/usr/share/doc/icingaweb2/schema/*-upgrades/` (Debian/Ubuntu: `/usr/share/icingaweb2/etc/schema/*-upgrades/`). +**Framework changes affecting third-party code** + +* All the following deprecated php classes and methods are removed: + + **Methods:** ++ `Url::setBaseUrl()`: Please create a new url from scratch instead. ++ `Url::getBaseUrl()`: Use either `Url::getBasePath()` or `Url::getAbsoluteUrl()` now. ++ `ApplicationBootstrap::setupZendAutoloader()`: Since it does nothing. All uses removed. ++ `ApplicationBootstrap::listLocales()`: Use `\ipl\I18n\GettextTranslator::listLocales()` instead. ++ `Module::registerHook()`: Use `provideHook()` instead. ++ `Web::getMenu()`: Instantiate the menu class `new Menu()` directly instead. ++ `AesCrypt::encryptToBase64()`: Use `AesCrypt::encrypt()` instead as it also returns a base64 encoded string. ++ `AesCrypt::decryptFromBase64()`: Use `AesCrypt::decrypt()` instead as it also returns a base64 decoded string. ++ `InlinePie::disableNoScript()`: Empty method. ++ `SimpleQuery::paginate()`: Use `Icinga\Web\Controller::setupPaginationControl()` and/or `Icinga\Web\Widget\Paginator` instead. ++ `LdapConnection::connect()`: The connection is established lazily now. ++ `MonitoredObject::matches()`: Use `$filter->matches($object)` instead. ++ `MonitoredObject::fromParams()` ++ `DataView::fromRequest()`: Use `$backend->select()->from($viewName)` instead. ++ `DataView::sort()`: Use `DataView::order()` instead. ++ `MonitoringBackend::createBackend()`: Use `MonitoringBackend::instance()` instead. ++ `DbConnection::getConnection()`: Use `Connection::getDbAdapter()` instead. ++ `DbQuery::renderFilter()`: Use `DbConnection::renderFilter()` instead. + + **Classes:** ++ `Icinga\Util\String`: Use `Icinga\Util\StringHelper` instead. ++ `Icinga\Util\Translator`: Use `\ipl\I18n\StaticTranslator::$instance` or `\ipl\I18n\Translation` instead. ++ `Icinga\Module\Migrate\Clicommands\DashboardCommand` + + +* All the following deprecated js classes and methods are removed: + + **Methods:** ++ `loader::addUrlFlag()`: Use `Icinga.Utils.addUrlFlag()` instead. + ## Upgrading to Icinga Web 2 2.10.x **General** From 46a21d9709d6fa68274f244b70a94acfa2ac1c51 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 13 May 2022 14:13:57 +0200 Subject: [PATCH 22/30] Drop method `DbQuery::whereToSql()` It's been used by `DbQuery::renderFilter()` rather exclusively. So if removing one, both need to go. --- doc/80-Upgrading.md | 1 + library/Icinga/Data/Db/DbQuery.php | 101 +++++------------- .../Query/HostcommentdeletionhistoryQuery.php | 13 +-- .../Ido/Query/HostcommenthistoryQuery.php | 15 ++- .../Ido/Query/HostdowntimeendhistoryQuery.php | 15 +-- .../Query/HostdowntimestarthistoryQuery.php | 17 ++- .../Query/HostflappingstarthistoryQuery.php | 15 ++- .../Ido/Query/HostnotificationQuery.php | 33 +++--- .../Ido/Query/HoststatehistoryQuery.php | 20 ++-- .../ServicecommentdeletionhistoryQuery.php | 13 +-- .../Ido/Query/ServicecommenthistoryQuery.php | 15 ++- .../Query/ServicedowntimeendhistoryQuery.php | 15 +-- .../ServicedowntimestarthistoryQuery.php | 17 ++- .../ServiceflappingstarthistoryQuery.php | 17 ++- .../Ido/Query/ServicenotificationQuery.php | 33 +++--- .../Ido/Query/ServicestatehistoryQuery.php | 20 ++-- 16 files changed, 138 insertions(+), 222 deletions(-) diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index c8844e444..ca9fbd164 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -39,6 +39,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `MonitoringBackend::createBackend()`: Use `MonitoringBackend::instance()` instead. + `DbConnection::getConnection()`: Use `Connection::getDbAdapter()` instead. + `DbQuery::renderFilter()`: Use `DbConnection::renderFilter()` instead. ++ `DbQuery::whereToSql()`: Use `DbConnection::renderFilter()` instead. **Classes:** + `Icinga\Util\String`: Use `Icinga\Util\StringHelper` instead. diff --git a/library/Icinga/Data/Db/DbQuery.php b/library/Icinga/Data/Db/DbQuery.php index fea82179b..25acd8905 100644 --- a/library/Icinga/Data/Db/DbQuery.php +++ b/library/Icinga/Data/Db/DbQuery.php @@ -7,13 +7,10 @@ use DateInterval; use DateTime; use DateTimeZone; use Exception; +use Icinga\Data\Filter\Filter; use Zend_Db_Expr; use Zend_Db_Select; use Icinga\Application\Logger; -use Icinga\Data\Filter\FilterAnd; -use Icinga\Data\Filter\FilterChain; -use Icinga\Data\Filter\FilterNot; -use Icinga\Data\Filter\FilterOr; use Icinga\Data\SimpleQuery; use Icinga\Exception\ProgrammingError; use Icinga\Exception\QueryException; @@ -116,6 +113,23 @@ class DbQuery extends SimpleQuery return parent::where($condition, $value); } + public function addFilter(Filter $filter) + { + $this->expressionsToTimestamp($filter); + return parent::addFilter($filter); + } + + private function expressionsToTimestamp(Filter $filter) + { + if ($filter->isChain()) { + foreach ($filter->filters() as $child) { + $this->expressionsToTimestamp($child); + } + } elseif ($this->isTimestamp($filter->getColumn())) { + $filter->setExpression($this->valueToTimestamp($filter->getExpression())); + } + } + protected function dbSelect() { return clone $this->select; @@ -210,20 +224,16 @@ class DbQuery extends SimpleQuery protected function valueToTimestamp($value) { - // We consider integers as valid timestamps. Does not work for URL params - if (! is_string($value) || ctype_digit($value)) { - return $value; + if (ctype_digit($value)) { + $value = (int) $value; + } elseif (is_string($value)) { + $value = strtotime($value); } - $value = strtotime($value); - if (! $value) { - /* - NOTE: It's too late to throw exceptions, we might finish in __toString - throw new QueryException(sprintf( - '"%s" is not a valid time expression', - $value - )); - */ + + if (is_int($value)) { + $value = $this->timestampForSql($value); } + return $value; } @@ -258,7 +268,7 @@ class DbQuery extends SimpleQuery } } - return $this->escapeForSql($dateTime->format('Y-m-d H:i:s')); + return $dateTime->format('Y-m-d H:i:s'); } /** @@ -279,63 +289,6 @@ class DbQuery extends SimpleQuery return false; } - public function whereToSql($col, $sign, $expression) - { - if ($this->isTimestamp($col)) { - $expression = $this->valueToTimestamp($expression); - } - - if (is_array($expression)) { - $comp = []; - $pattern = []; - foreach ($expression as $value) { - if (strpos($value, '*') === false) { - $comp[] = $value; - } else { - $pattern[] = $this->whereToSql($col, $sign, $value); - } - } - $sql = $pattern; - if ($sign === '=') { - if (! empty($comp)) { - $sql[] = $col . ' IN (' . $this->escapeForSql($comp) . ')'; - } - $operator = 'OR'; - } elseif ($sign === '!=') { - if (! empty($comp)) { - $sql[] = sprintf('(%1$s NOT IN (%2$s) OR %1$s IS NULL)', $col, $this->escapeForSql($comp)); - } - $operator = 'AND'; - } else { - throw new QueryException( - 'Unable to render array expressions with operators other than equal or not equal' - ); - } - - return '(' . implode(" $operator ", $sql) . ')'; - } elseif ($sign === '=' && $expression !== null && strpos($expression, '*') !== false) { - if ($expression === '*') { - return $col . ' IS NOT NULL'; - } - - return $col . ' LIKE ' . $this->escapeForSql($this->escapeWildcards($expression)); - } elseif ($sign === '!=' && $expression !== null && strpos($expression, '*') !== false) { - if ($expression === '*') { - return $col . ' IS NULL'; - } - - return sprintf( - '(%1$s NOT LIKE %2$s OR %1$s IS NULL)', - $col, - $this->escapeForSql($this->escapeWildcards($expression)) - ); - } elseif ($sign === '!=') { - return sprintf('(%1$s %2$s %3$s OR %1$s IS NULL)', $col, $sign, $this->escapeForSql($expression)); - } else { - return sprintf('%s %s %s', $col, $sign, $this->escapeForSql($expression)); - } - } - /** * Get the count query * diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentdeletionhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentdeletionhistoryQuery.php index e9021f2ec..b602f8a69 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentdeletionhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommentdeletionhistoryQuery.php @@ -8,16 +8,13 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; */ class HostcommentdeletionhistoryQuery extends HostcommenthistoryQuery { - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(hch.deletion_time)') { - return 'hch.deletion_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'hch.deletion_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommenthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommenthistoryQuery.php index ddfc4c026..d7a25e054 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommenthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostcommenthistoryQuery.php @@ -40,7 +40,7 @@ class HostcommenthistoryQuery extends IdoQuery 'object_type' => '(\'host\')', 'output' => "('[' || hch.author_name || '] ' || hch.comment_data)", 'state' => '(-1)', - 'timestamp' => 'UNIX_TIMESTAMP(hch.comment_time)', + 'timestamp' => 'hch.comment_time', 'type' => "(CASE hch.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'dt_comment' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END)" ), 'hostgroups' => array( @@ -68,16 +68,13 @@ class HostcommenthistoryQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(hch.comment_time)') { - return 'hch.comment_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'hch.comment_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeendhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeendhistoryQuery.php index 16857e00a..8df59c7b3 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeendhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimeendhistoryQuery.php @@ -8,18 +8,13 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; */ class HostdowntimeendhistoryQuery extends HostdowntimestarthistoryQuery { - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(hdh.actual_end_time)') { - return 'hdh.actual_end_time ' . $sign . ' ' . $this->timestampForSql( - $this->valueToTimestamp($expression) - ); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'hdh.actual_end_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php index 5d0517884..ae3df5ffa 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostdowntimestarthistoryQuery.php @@ -40,7 +40,7 @@ class HostdowntimestarthistoryQuery extends IdoQuery 'object_type' => '(\'host\')', 'output' => "('[' || hdh.author_name || '] ' || hdh.comment_data)", 'state' => '(-1)', - 'timestamp' => 'UNIX_TIMESTAMP(hdh.actual_start_time)', + 'timestamp' => 'hdh.actual_start_time', 'type' => "('dt_start')" ), 'hostgroups' => array( @@ -68,18 +68,13 @@ class HostdowntimestarthistoryQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(hdh.actual_start_time)') { - return 'hdh.actual_start_time ' . $sign . ' ' . $this->timestampForSql( - $this->valueToTimestamp($expression) - ); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'hdh.actual_start_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostflappingstarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostflappingstarthistoryQuery.php index c09e4ac8a..3532b72f5 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostflappingstarthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostflappingstarthistoryQuery.php @@ -40,7 +40,7 @@ class HostflappingstarthistoryQuery extends IdoQuery 'object_type' => '(\'host\')', 'output' => '(hfh.percent_state_change || \'\')', 'state' => '(-1)', - 'timestamp' => 'UNIX_TIMESTAMP(hfh.event_time)', + 'timestamp' => 'hfh.event_time', 'type' => '(\'flapping\')' ), 'hostgroups' => array( @@ -68,16 +68,13 @@ class HostflappingstarthistoryQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(hfh.event_time)') { - return 'hfh.event_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'hfh.event_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php index ff54b3eac..052873f77 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HostnotificationQuery.php @@ -3,6 +3,9 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; +use Icinga\Data\Filter\Filter; +use Icinga\Data\Filter\FilterExpression; + /** * Query for host notifications */ @@ -37,7 +40,7 @@ class HostnotificationQuery extends IdoQuery 'history' => array( 'output' => null, 'state' => 'hn.state', - 'timestamp' => 'UNIX_TIMESTAMP(hn.start_time)', + 'timestamp' => 'hn.start_time', 'type' => ' CASE hn.notification_reason WHEN 1 THEN \'notification_ack\' @@ -60,7 +63,7 @@ class HostnotificationQuery extends IdoQuery 'notification_output' => 'hn.output', 'notification_reason' => 'hn.notification_reason', 'notification_state' => 'hn.state', - 'notification_timestamp' => 'UNIX_TIMESTAMP(hn.start_time)', + 'notification_timestamp' => 'hn.start_time', 'object_type' => '(\'host\')' ), 'servicegroups' => array( @@ -76,18 +79,24 @@ class HostnotificationQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + protected function requireFilterColumns(Filter $filter) { - if ($col === 'UNIX_TIMESTAMP(hn.start_time)') { - return 'hn.start_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } elseif ($col === $this->columnMap['history']['output']) { - return parent::whereToSql('hn.output', $sign, $expression); - } else { - return parent::whereToSql($col, $sign, $expression); + if ($filter instanceof FilterExpression && $filter->getColumn() === 'output') { + $this->requireColumn($filter->getColumn()); + $filter->setColumn('hn.output'); + return null; } + + return parent::requireFilterColumns($filter); + } + + public function isTimestamp($field) + { + if (! parent::isTimestamp($field)) { + return $field === 'hn.start_time'; + } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php index 565804e3b..7321d1a87 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatehistoryQuery.php @@ -73,26 +73,18 @@ class HoststatehistoryQuery extends IdoQuery 'object_type' => '(\'host\')', 'output' => '(CASE WHEN hh.state_type = 1 THEN hh.output ELSE \'[ \' || hh.current_check_attempt || \'/\' || hh.max_check_attempts || \' ] \' || hh.output END)', 'state' => 'hh.state', - 'timestamp' => 'UNIX_TIMESTAMP(hh.state_time)', + 'timestamp' => 'hh.state_time', 'type' => "(CASE WHEN hh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)" ), ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(hh.state_time)') { - return 'hh.state_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } elseif ($col === $this->columnMap['statehistory']['type'] - && ! is_array($expression) - && array_key_exists($expression, $this->types) - ) { - return 'hh.state_type ' . $sign . ' ' . $this->types[$expression]; - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'hh.state_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentdeletionhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentdeletionhistoryQuery.php index c5ad15553..1f134b2a2 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentdeletionhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommentdeletionhistoryQuery.php @@ -8,16 +8,13 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; */ class ServicecommentdeletionhistoryQuery extends ServicecommenthistoryQuery { - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(sch.deletion_time)') { - return 'sch.deletion_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'sch.deletion_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php index afa7772f0..0a3183552 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicecommenthistoryQuery.php @@ -44,7 +44,7 @@ class ServicecommenthistoryQuery extends IdoQuery 'service_host' => 'so.name1 COLLATE latin1_general_ci', 'service_host_name' => 'so.name1', 'state' => '(-1)', - 'timestamp' => 'UNIX_TIMESTAMP(sch.comment_time)', + 'timestamp' => 'sch.comment_time', 'type' => "(CASE sch.entry_type WHEN 1 THEN 'comment' WHEN 2 THEN 'dt_comment' WHEN 3 THEN 'flapping' WHEN 4 THEN 'ack' END)" ), 'hostgroups' => array( @@ -69,16 +69,13 @@ class ServicecommenthistoryQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(sch.comment_time)') { - return 'sch.comment_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'sch.comment_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeendhistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeendhistoryQuery.php index 4ee2b6c54..0c7049f3d 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeendhistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimeendhistoryQuery.php @@ -8,18 +8,13 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; */ class ServicedowntimeendhistoryQuery extends ServicedowntimestarthistoryQuery { - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(sdh.actual_end_time)') { - return 'sdh.actual_end_time ' . $sign . ' ' . $this->timestampForSql( - $this->valueToTimestamp($expression) - ); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'sdh.actual_end_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php index 932d854a0..be096ec9b 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicedowntimestarthistoryQuery.php @@ -44,7 +44,7 @@ class ServicedowntimestarthistoryQuery extends IdoQuery 'service_host' => 'so.name1 COLLATE latin1_general_ci', 'service_host_name' => 'so.name1', 'state' => '(-1)', - 'timestamp' => 'UNIX_TIMESTAMP(sdh.actual_start_time)', + 'timestamp' => 'sdh.actual_start_time', 'type' => "('dt_start')" ), 'hostgroups' => array( @@ -69,18 +69,13 @@ class ServicedowntimestarthistoryQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(sdh.actual_start_time)') { - return 'sdh.actual_start_time ' . $sign . ' ' . $this->timestampForSql( - $this->valueToTimestamp($expression) - ); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'sdh.actual_start_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServiceflappingstarthistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServiceflappingstarthistoryQuery.php index f6f67f709..842166b25 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServiceflappingstarthistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServiceflappingstarthistoryQuery.php @@ -43,7 +43,7 @@ class ServiceflappingstarthistoryQuery extends IdoQuery 'service_description' => 'so.name2', 'service_host_name' => 'so.name1', 'state' => '(-1)', - 'timestamp' => 'UNIX_TIMESTAMP(sfh.event_time)', + 'timestamp' => 'sfh.event_time', 'type' => "('flapping')" ), 'hostgroups' => array( @@ -68,18 +68,13 @@ class ServiceflappingstarthistoryQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(sfh.event_time)') { - return 'sfh.event_time ' . $sign . ' ' . $this->timestampForSql( - $this->valueToTimestamp($expression) - ); - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'sfh.event_time'; } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php index 4188ee614..12e512da5 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicenotificationQuery.php @@ -3,6 +3,9 @@ namespace Icinga\Module\Monitoring\Backend\Ido\Query; +use Icinga\Data\Filter\Filter; +use Icinga\Data\Filter\FilterExpression; + /** * Query for service notifications */ @@ -28,7 +31,7 @@ class ServicenotificationQuery extends IdoQuery 'history' => array( 'output' => null, 'state' => 'sn.state', - 'timestamp' => 'UNIX_TIMESTAMP(sn.start_time)', + 'timestamp' => 'sn.start_time', 'type' => ' CASE sn.notification_reason WHEN 1 THEN \'notification_ack\' @@ -60,7 +63,7 @@ class ServicenotificationQuery extends IdoQuery 'notification_output' => 'sn.output', 'notification_reason' => 'sn.notification_reason', 'notification_state' => 'sn.state', - 'notification_timestamp' => 'UNIX_TIMESTAMP(sn.start_time)', + 'notification_timestamp' => 'sn.start_time', 'object_type' => '(\'service\')', 'service' => 'so.name2 COLLATE latin1_general_ci', 'service_description' => 'so.name2', @@ -76,18 +79,24 @@ class ServicenotificationQuery extends IdoQuery ) ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + protected function requireFilterColumns(Filter $filter) { - if ($col === 'UNIX_TIMESTAMP(sn.start_time)') { - return 'sn.start_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } elseif ($col === $this->columnMap['history']['output']) { - return parent::whereToSql('sn.output', $sign, $expression); - } else { - return parent::whereToSql($col, $sign, $expression); + if ($filter instanceof FilterExpression && $filter->getColumn() === 'output') { + $this->requireColumn($filter->getColumn()); + $filter->setColumn('sn.output'); + return null; } + + return parent::requireFilterColumns($filter); + } + + public function isTimestamp($field) + { + if (! parent::isTimestamp($field)) { + return $field === 'sn.start_time'; + } + + return true; } /** diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php index 8c0a89763..a1bab89ce 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatehistoryQuery.php @@ -74,26 +74,18 @@ class ServicestatehistoryQuery extends IdoQuery 'service_host' => 'so.name1 COLLATE latin1_general_ci', 'service_host_name' => 'so.name1', 'state' => 'sh.state', - 'timestamp' => 'UNIX_TIMESTAMP(sh.state_time)', + 'timestamp' => 'sh.state_time', 'type' => "(CASE WHEN sh.state_type = 1 THEN 'hard_state' ELSE 'soft_state' END)" ), ); - /** - * {@inheritdoc} - */ - public function whereToSql($col, $sign, $expression) + public function isTimestamp($field) { - if ($col === 'UNIX_TIMESTAMP(sh.state_time)') { - return 'sh.state_time ' . $sign . ' ' . $this->timestampForSql($this->valueToTimestamp($expression)); - } elseif ($col === $this->columnMap['statehistory']['type'] - && ! is_array($expression) - && array_key_exists($expression, $this->types) - ) { - return 'sh.state_type ' . $sign . ' ' . $this->types[$expression]; - } else { - return parent::whereToSql($col, $sign, $expression); + if (! parent::isTimestamp($field)) { + return $field === 'sh.state_time'; } + + return true; } /** From f8e1137060fa4683dab0163ca2a6c0e949baf903 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 13 May 2022 15:10:34 +0200 Subject: [PATCH 23/30] Remove restriction macro `user:local_name` --- doc/06-Security.md | 3 --- doc/80-Upgrading.md | 5 ++++- library/Icinga/Authentication/AdmissionLoader.php | 5 +---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/doc/06-Security.md b/doc/06-Security.md index 33fe6ccc0..b8d7cf2f5 100644 --- a/doc/06-Security.md +++ b/doc/06-Security.md @@ -159,9 +159,6 @@ this, put the macro `$user.local_name$` in the restriction where you want it to This can come in handy if you have e.g. an attribute on hosts or services defining which user is responsible for it: `_host_deputy=$user.local_name$|_service_deputy=$user.local_name$` -> Please note that since version 2.9 the use of `user.local_name` instead of `user:local_name` is supported and -> recommended. `user:local_name` is deprecated and will be removed in version 2.11. - ### Filter Expressions Filters operate on columns. A complete list of all available filter columns on hosts and services can be found in diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index ca9fbd164..f524d8f2f 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -16,6 +16,10 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. In package installations this file can be found in `/usr/share/doc/icingaweb2/schema/*-upgrades/` (Debian/Ubuntu: `/usr/share/icingaweb2/etc/schema/*-upgrades/`). +**Breaking changes** + +* The `user:local_name` macro in restrictions has been removed. Use `user.local_name` now. + **Framework changes affecting third-party code** * All the following deprecated php classes and methods are removed: @@ -46,7 +50,6 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `Icinga\Util\Translator`: Use `\ipl\I18n\StaticTranslator::$instance` or `\ipl\I18n\Translation` instead. + `Icinga\Module\Migrate\Clicommands\DashboardCommand` - * All the following deprecated js classes and methods are removed: **Methods:** diff --git a/library/Icinga/Authentication/AdmissionLoader.php b/library/Icinga/Authentication/AdmissionLoader.php index 54814c87f..0c3fd3f5c 100644 --- a/library/Icinga/Authentication/AdmissionLoader.php +++ b/library/Icinga/Authentication/AdmissionLoader.php @@ -204,11 +204,8 @@ class AdmissionLoader $roleRestrictions = $role->getRestrictions(); foreach ($roleRestrictions as $name => & $restriction) { - // TODO(el): user.local_name is supported since version 2.9. - // and therefore user:local_name is deprecated. - // The latter will be removed in version 2.11. $restriction = str_replace( - ['$user.local_name$', '$user:local_name$'], + '$user.local_name$', $user->getLocalUsername(), $restriction ); From 9ef344d3b21254a0f9c93dc5b46a1739f8392a18 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 13 May 2022 15:16:12 +0200 Subject: [PATCH 24/30] Really mark class `Icinga\Web\Hook` deprecated -.- I would have removed it, but the deprecation notice wasn't defined properly and so not visible for more than six years. Now even our own projects make still use of it thoroughly.. --- library/Icinga/Web/Hook.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Web/Hook.php b/library/Icinga/Web/Hook.php index bbdd7f483..b09851898 100644 --- a/library/Icinga/Web/Hook.php +++ b/library/Icinga/Web/Hook.php @@ -8,7 +8,8 @@ use Icinga\Application\Hook as NewHookImplementation; /** * Icinga Web Hook registry * - * Deprecated, please use Icinga\Application\Hook instead + * @deprecated It is highly recommended to use {@see Icinga\Application\Hook} instead. Though since this message + * (or rather the previous message) hasn't been visible for ages... This won't be removed anyway.... */ class Hook extends NewHookImplementation { From d25854ebce1c1e5c898d9ab3e73e59a2655e6ff0 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Fri, 13 May 2022 15:23:16 +0200 Subject: [PATCH 25/30] Drop class `Icinga\Web\Hook\TicketHook` --- application/views/helpers/CreateTicketLinks.php | 4 ++-- doc/80-Upgrading.md | 1 + library/Icinga/Web/Hook/TicketHook.php | 15 --------------- 3 files changed, 3 insertions(+), 17 deletions(-) delete mode 100644 library/Icinga/Web/Hook/TicketHook.php diff --git a/application/views/helpers/CreateTicketLinks.php b/application/views/helpers/CreateTicketLinks.php index 52ef274fa..4f8a27249 100644 --- a/application/views/helpers/CreateTicketLinks.php +++ b/application/views/helpers/CreateTicketLinks.php @@ -12,12 +12,12 @@ class Zend_View_Helper_CreateTicketLinks extends Zend_View_Helper_Abstract * @param string $text * * @return string - * @see \Icinga\Web\Hook\TicketHook::createLinks() + * @see \Icinga\Application\Hook\TicketHook::createLinks() */ public function createTicketLinks($text) { $tickets = $this->view->tickets; - /** @var \Icinga\Web\Hook\TicketHook $tickets */ + /** @var \Icinga\Application\Hook\TicketHook $tickets */ return isset($tickets) ? $tickets->createLinks($text) : $text; } } diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index f524d8f2f..63a04dcee 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -49,6 +49,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `Icinga\Util\String`: Use `Icinga\Util\StringHelper` instead. + `Icinga\Util\Translator`: Use `\ipl\I18n\StaticTranslator::$instance` or `\ipl\I18n\Translation` instead. + `Icinga\Module\Migrate\Clicommands\DashboardCommand` ++ `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead. * All the following deprecated js classes and methods are removed: diff --git a/library/Icinga/Web/Hook/TicketHook.php b/library/Icinga/Web/Hook/TicketHook.php deleted file mode 100644 index 183fa774a..000000000 --- a/library/Icinga/Web/Hook/TicketHook.php +++ /dev/null @@ -1,15 +0,0 @@ - Date: Fri, 13 May 2022 15:24:11 +0200 Subject: [PATCH 26/30] Drop class `Icinga\Web\Hook\GrapherHook` --- doc/80-Upgrading.md | 1 + library/Icinga/Web/Hook/GrapherHook.php | 15 --------------- 2 files changed, 1 insertion(+), 15 deletions(-) delete mode 100644 library/Icinga/Web/Hook/GrapherHook.php diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index 63a04dcee..a563308e5 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -50,6 +50,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `Icinga\Util\Translator`: Use `\ipl\I18n\StaticTranslator::$instance` or `\ipl\I18n\Translation` instead. + `Icinga\Module\Migrate\Clicommands\DashboardCommand` + `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead. ++ `Icinga\Web\Hook\GrapherHook`: Use `Icinga\Application\Hook\GrapherHook` instead. * All the following deprecated js classes and methods are removed: diff --git a/library/Icinga/Web/Hook/GrapherHook.php b/library/Icinga/Web/Hook/GrapherHook.php deleted file mode 100644 index 4cf5205b9..000000000 --- a/library/Icinga/Web/Hook/GrapherHook.php +++ /dev/null @@ -1,15 +0,0 @@ - Date: Mon, 30 May 2022 11:10:10 +0200 Subject: [PATCH 27/30] Remove not in use class `Icinga\Module\Monitoring\Environment.php` --- doc/80-Upgrading.md | 1 + .../library/Monitoring/Environment.php | 57 ------------------- 2 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/Environment.php diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index a563308e5..7a266e8d8 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -51,6 +51,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `Icinga\Module\Migrate\Clicommands\DashboardCommand` + `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead. + `Icinga\Web\Hook\GrapherHook`: Use `Icinga\Application\Hook\GrapherHook` instead. ++ `Icinga\Module\Monitoring\Environment`: Not in use. * All the following deprecated js classes and methods are removed: diff --git a/modules/monitoring/library/Monitoring/Environment.php b/modules/monitoring/library/Monitoring/Environment.php deleted file mode 100644 index 0dee83ae4..000000000 --- a/modules/monitoring/library/Monitoring/Environment.php +++ /dev/null @@ -1,57 +0,0 @@ - array( - 'backend' => null, - 'grapher' => null, - 'configBackend' => null, - 'commandPipe' => null, - ) - ); - - public static function defaultName() - { - // TODO: Check session - reset(self::$envs); - return key(self::$envs); - } - - protected static function config($env, $what) - { - return self::$config[self::getName($env)][$what]; - } - - protected static function getName($env) - { - return $env === null ? self::defaultName() : $env; - } - - public static function backend($env = null) - { - return Backend::getInstance(self::config($env, 'backend')); - } - - public static function grapher($env = null) - { - return Hook::createInstance('grapher', null, self::config($env, 'grapher')); - } - - public static function configBackend($env = null) - { - return Hook::createInstance( - 'configBackend', - null, - self::config($env, 'configBackend') - ); - } - - public static function commandPipe($env = null) - { - return CommandPipe::getInstance(self::config($env, 'commandPipe')); - } -} From 3b04a0489e7309c4dd1f33eae5eb250621bde588 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 30 May 2022 11:21:48 +0200 Subject: [PATCH 28/30] Replace class `Backend` use with `MonitoringBackend` and remove class `Backend` --- doc/80-Upgrading.md | 1 + .../application/clicommands/ListCommand.php | 4 ++-- .../application/controllers/ConfigController.php | 6 +++--- .../application/controllers/ListController.php | 4 ++-- .../application/controllers/ShowController.php | 4 ++-- modules/monitoring/library/Monitoring/Backend.php | 12 ------------ modules/monitoring/library/Monitoring/Controller.php | 5 +++-- .../library/Monitoring/ProvidedHook/Health.php | 6 +++--- .../monitoring/test/php/regression/Bug7043Test.php | 4 ++-- 9 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 modules/monitoring/library/Monitoring/Backend.php diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index 7a266e8d8..28dcb085b 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -52,6 +52,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead. + `Icinga\Web\Hook\GrapherHook`: Use `Icinga\Application\Hook\GrapherHook` instead. + `Icinga\Module\Monitoring\Environment`: Not in use. ++ `Icinga\Module\Monitoring\Backend`: Use `Icinga\Module\Monitoring\Backend\MonitoringBackend` instead. * All the following deprecated js classes and methods are removed: diff --git a/modules/monitoring/application/clicommands/ListCommand.php b/modules/monitoring/application/clicommands/ListCommand.php index 9020c6ec2..6dc419341 100644 --- a/modules/monitoring/application/clicommands/ListCommand.php +++ b/modules/monitoring/application/clicommands/ListCommand.php @@ -3,7 +3,7 @@ namespace Icinga\Module\Monitoring\Clicommands; -use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Cli\CliUtils; use Icinga\Date\DateFormatter; use Icinga\Cli\Command; @@ -25,7 +25,7 @@ class ListCommand extends Command public function init() { - $this->backend = Backend::instance($this->params->shift('backend')); + $this->backend = MonitoringBackend::instance($this->params->shift('backend')); $this->dumpSql = $this->params->shift('showsql'); } diff --git a/modules/monitoring/application/controllers/ConfigController.php b/modules/monitoring/application/controllers/ConfigController.php index 7c4e4315e..b8ca0a1ab 100644 --- a/modules/monitoring/application/controllers/ConfigController.php +++ b/modules/monitoring/application/controllers/ConfigController.php @@ -8,10 +8,10 @@ use Icinga\Data\ResourceFactory; use Icinga\Exception\ConfigurationError; use Icinga\Exception\NotFoundError; use Icinga\Forms\ConfirmRemovalForm; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Forms\Config\TransportReorderForm; use Icinga\Web\Controller; use Icinga\Web\Notification; -use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Forms\Config\BackendConfigForm; use Icinga\Module\Monitoring\Forms\Config\SecurityConfigForm; use Icinga\Module\Monitoring\Forms\Config\TransportConfigForm; @@ -215,7 +215,7 @@ class ConfigController extends Controller $form->setTitle(sprintf($this->translate('Edit Command Transport %s'), $transportName)); $form->setIniConfig($this->Config('commandtransports')); $form->setInstanceNames( - Backend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() + MonitoringBackend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() ); $form->setOnSuccess(function (TransportConfigForm $form) use ($transportName) { try { @@ -259,7 +259,7 @@ class ConfigController extends Controller $form->setTitle($this->translate('Create New Command Transport')); $form->setIniConfig($this->Config('commandtransports')); $form->setInstanceNames( - Backend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() + MonitoringBackend::instance()->select()->from('instance', array('instance_name'))->fetchColumn() ); $form->setOnSuccess(function (TransportConfigForm $form) { try { diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 397b68325..0ccff99c8 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -3,12 +3,12 @@ namespace Icinga\Module\Monitoring\Controllers; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Security\SecurityException; use Icinga\Util\GlobFilter; use Icinga\Web\Form; use Zend_Form; use Icinga\Data\Filter\Filter; -use Icinga\Module\Monitoring\Backend; use Icinga\Module\Monitoring\Controller; use Icinga\Module\Monitoring\DataView\DataView; use Icinga\Module\Monitoring\Forms\Command\Object\DeleteCommentCommandForm; @@ -34,7 +34,7 @@ class ListController extends Controller /** * Overwrite the backend to use (used for testing) * - * @param Backend $backend The Backend that should be used for querying + * @param MonitoringBackend $backend The Backend that should be used for querying */ public function setBackend($backend) { diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 3aa4a79ed..f1da5617c 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -4,7 +4,7 @@ namespace Icinga\Module\Monitoring\Controllers; use Icinga\Data\Filter\FilterEqual; -use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Module\Monitoring\Controller; use Icinga\Security\SecurityException; use Icinga\Web\Url; @@ -17,7 +17,7 @@ use Icinga\Web\Url; class ShowController extends Controller { /** - * @var Backend + * @var MonitoringBackend */ protected $backend; diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php deleted file mode 100644 index 92ea78520..000000000 --- a/modules/monitoring/library/Monitoring/Backend.php +++ /dev/null @@ -1,12 +0,0 @@ -backend = Backend::instance($this->_getParam('backend')); + $this->backend = MonitoringBackend::instance($this->_getParam('backend')); $this->view->url = Url::fromRequest(); } diff --git a/modules/monitoring/library/Monitoring/ProvidedHook/Health.php b/modules/monitoring/library/Monitoring/ProvidedHook/Health.php index da32a23d3..c2de3131c 100644 --- a/modules/monitoring/library/Monitoring/ProvidedHook/Health.php +++ b/modules/monitoring/library/Monitoring/ProvidedHook/Health.php @@ -5,7 +5,7 @@ namespace Icinga\Module\Monitoring\ProvidedHook; use Icinga\Application\Hook\HealthHook; use Icinga\Date\DateFormatter; -use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; use ipl\Web\Url; class Health extends HealthHook @@ -25,7 +25,7 @@ class Health extends HealthHook public function checkHealth() { - $backendName = Backend::instance()->getName(); + $backendName = MonitoringBackend::instance()->getName(); $programStatus = $this->getProgramStatus(); if ($programStatus === false) { $this->setState(self::STATE_UNKNOWN); @@ -55,7 +55,7 @@ class Health extends HealthHook protected function getProgramStatus() { if ($this->programStatus === null) { - $this->programStatus = Backend::instance()->select() + $this->programStatus = MonitoringBackend::instance()->select() ->from('programstatus', [ 'program_version', 'status_update_time', diff --git a/modules/monitoring/test/php/regression/Bug7043Test.php b/modules/monitoring/test/php/regression/Bug7043Test.php index 949925f7c..392f74b13 100644 --- a/modules/monitoring/test/php/regression/Bug7043Test.php +++ b/modules/monitoring/test/php/regression/Bug7043Test.php @@ -9,7 +9,7 @@ require_once realpath(dirname(__FILE__) . '/../../../../../test/php/bootstrap.ph use Icinga\Application\Config; use Icinga\Data\ConfigObject; -use Icinga\Module\Monitoring\Backend; +use Icinga\Module\Monitoring\Backend\MonitoringBackend; use Icinga\Test\BaseTestCase; use Mockery; @@ -53,7 +53,7 @@ class Bug7043Test extends BaseTestCase ) ))); - $defaultBackend = Backend::instance(); + $defaultBackend = MonitoringBackend::instance(); $this->assertEquals('backendName', $defaultBackend->getName(), 'Default backend has name set'); } From 4ab79a67584c64d430cfe8fa5db07e790dabb7c7 Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 30 May 2022 12:21:51 +0200 Subject: [PATCH 29/30] DataView: Remove not in use method `applyUrlFilter()` --- doc/80-Upgrading.md | 1 + .../library/Monitoring/DataView/DataView.php | 20 ------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index 28dcb085b..c7005abe5 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -44,6 +44,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `DbConnection::getConnection()`: Use `Connection::getDbAdapter()` instead. + `DbQuery::renderFilter()`: Use `DbConnection::renderFilter()` instead. + `DbQuery::whereToSql()`: Use `DbConnection::renderFilter()` instead. ++ `DataView::applyUrlFilter()`: Not in use. **Classes:** + `Icinga\Util\String`: Use `Icinga\Util\StringHelper` instead. diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 42ec1e75e..4d9eacdb4 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -135,26 +135,6 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite return $columns; } - // TODO: This is not the right place for this, move it away - protected function applyUrlFilter($request = null) - { - $url = Url::fromRequest(); - - $limit = $url->shift('limit'); - $sort = $url->shift('sort'); - $dir = $url->shift('dir'); - $page = $url->shift('page'); - $format = $url->shift('format'); - $view = $url->shift('showCompact'); - $view = $url->shift('backend'); - foreach ($url->getParams() as $k => $v) { - $this->where($k, $v); - } - if ($sort) { - $this->order($sort, $dir); - } - } - /** * Create view from params * From f780cc15a1f02f949b19fba2e75840aaba591dcc Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Mon, 13 Jun 2022 15:50:24 +0200 Subject: [PATCH 30/30] Update `80-Upgrading.md` doc --- doc/80-Upgrading.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/80-Upgrading.md b/doc/80-Upgrading.md index c7005abe5..b00924448 100644 --- a/doc/80-Upgrading.md +++ b/doc/80-Upgrading.md @@ -37,7 +37,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. + `SimpleQuery::paginate()`: Use `Icinga\Web\Controller::setupPaginationControl()` and/or `Icinga\Web\Widget\Paginator` instead. + `LdapConnection::connect()`: The connection is established lazily now. + `MonitoredObject::matches()`: Use `$filter->matches($object)` instead. -+ `MonitoredObject::fromParams()` ++ `MonitoredObject::fromParams()`: Deleted without substitution. + `DataView::fromRequest()`: Use `$backend->select()->from($viewName)` instead. + `DataView::sort()`: Use `DataView::order()` instead. + `MonitoringBackend::createBackend()`: Use `MonitoringBackend::instance()` instead. @@ -49,7 +49,7 @@ v2.6 to v2.8 requires to follow the instructions for v2.7 too. **Classes:** + `Icinga\Util\String`: Use `Icinga\Util\StringHelper` instead. + `Icinga\Util\Translator`: Use `\ipl\I18n\StaticTranslator::$instance` or `\ipl\I18n\Translation` instead. -+ `Icinga\Module\Migrate\Clicommands\DashboardCommand` ++ `Icinga\Module\Migrate\Clicommands\DashboardCommand`: Deleted without substitution. + `Icinga\Web\Hook\TicketHook`: Use `Icinga\Application\Hook\TicketHook` instead. + `Icinga\Web\Hook\GrapherHook`: Use `Icinga\Application\Hook\GrapherHook` instead. + `Icinga\Module\Monitoring\Environment`: Not in use.