From 892965e86998248f4da87fcc5a1268c37b26a0f3 Mon Sep 17 00:00:00 2001 From: brantje Date: Mon, 19 Dec 2016 17:51:59 +0100 Subject: [PATCH] Fix for NC12 $container->getDb() --- js/app/controllers/edit_credential.js | 2 +- lib/AppInfo/Application.php | 6 ++++-- lib/Service/CronService.php | 10 ++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/js/app/controllers/edit_credential.js b/js/app/controllers/edit_credential.js index 73d5ee21..930b3ca2 100644 --- a/js/app/controllers/edit_credential.js +++ b/js/app/controllers/edit_credential.js @@ -329,7 +329,7 @@ delete _credential.shared_key; var _useKey = (key != null); var regex = /(<([^>]+)>)/ig; - if(_credential.description && _credential.description != "") { + if(_credential.description && _credential.description !== "") { _credential.description = _credential.description.replace(regex, ""); } CredentialService.updateCredential(_credential, _useKey).then(function () { diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index c7d70f3f..c2840294 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -36,6 +36,7 @@ use OCA\Passman\Service\FileService; use OCA\Passman\Service\VaultService; use OCA\Passman\Utility\Utils; use OCA\Passman\Service\NotificationService; +use OCP\IDBConnection; use OCP\AppFramework\App; use OCP\IL10N; @@ -75,7 +76,7 @@ class Application extends App { - /** Cron **/ + /** Cron **/ $container->registerService('CronService', function ($c) { return new CronService( $c->query('CredentialService'), @@ -83,7 +84,7 @@ class Application extends App { $c->query('Utils'), $c->query('NotificationService'), $c->query('ActivityService'), - $c->query('ServerContainer')->getDb() + $c->query('IDBConnection') ); }); @@ -107,6 +108,7 @@ class Application extends App { $container->registerAlias('FileService', FileService::class); $container->registerAlias('ShareService', ShareService::class); $container->registerAlias('Utils', Utils::class); + $container->registerAlias('IDBConnection', IDBConnection::class); } /** diff --git a/lib/Service/CronService.php b/lib/Service/CronService.php index eb9733b3..3ee3660e 100644 --- a/lib/Service/CronService.php +++ b/lib/Service/CronService.php @@ -37,7 +37,7 @@ class CronService { private $notificationService; private $activityService; private $db; - public function __construct(CredentialService $credentialService, ILogger $logger, Utils $utils, NotificationService $notificationService, ActivityService $activityService, $db) { + public function __construct(CredentialService $credentialService, ILogger $logger, Utils $utils, NotificationService $notificationService, ActivityService $activityService, IDBConnection $db) { $this->credentialService = $credentialService; $this->logger = $logger; $this->utils = $utils; @@ -54,14 +54,12 @@ class CronService { $link = ''; // @TODO create direct link to credential $sql = 'SELECT count(*) as rows from `*PREFIX*notifications` WHERE `subject`= \'credential_expired\' AND object_id=?'; - $query = $this->db->prepareQuery($sql); $id = $credential->getId(); - $query->bindParam(1, $id, \PDO::PARAM_INT); - $result = $query->execute(); + $result = $this->db->executeQuery($sql, array($id)); $this->logger->debug($credential->getLabel() .' is expired, checking notifications!', array('app' => 'passman')); - if($result->fetchRow()['rows'] === 0) { + $notifications = intval($result->fetch()['rows']); + if($notifications === 0) { $this->logger->debug($credential->getLabel() .' is expired, adding notification!', array('app' => 'passman')); - $this->activityService->add( Activity::SUBJECT_ITEM_EXPIRED, array($credential->getLabel(), $credential->getUserId()), '', array(),