diff options
author | Victor Dubiniuk <victor.dubiniuk@gmail.com> | 2016-03-29 16:57:41 +0300 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2016-04-06 15:34:16 +0200 |
commit | b87b27cbd94275895fd9da3f29edced27cd5aaad (patch) | |
tree | 3a4b57968928b219bef50645fc883083055b9eb1 /lib | |
parent | cfd8cc3fd8382038a556ea729bb7c9beb09e4765 (diff) | |
download | nextcloud-server-b87b27cbd94275895fd9da3f29edced27cd5aaad.tar.gz nextcloud-server-b87b27cbd94275895fd9da3f29edced27cd5aaad.zip |
Show hint in CLI
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 2 | ||||
-rw-r--r-- | lib/private/releasenotes.php | 30 | ||||
-rw-r--r-- | lib/private/server.php | 13 |
3 files changed, 19 insertions, 26 deletions
diff --git a/lib/base.php b/lib/base.php index a5b0dd429ae..e77a07239c4 100644 --- a/lib/base.php +++ b/lib/base.php @@ -392,7 +392,7 @@ class OC { $tmpl->assign('isAppsOnlyUpgrade', false); } - $releaseNotes = \OC::$server->getReleaseNotes(); + $releaseNotes = new \OC\ReleaseNotes(\OC::$server->getDatabaseConnection()); // get third party apps $ocVersion = \OCP\Util::getVersion(); diff --git a/lib/private/releasenotes.php b/lib/private/releasenotes.php index 32ab036f9c1..a7caf8601ae 100644 --- a/lib/private/releasenotes.php +++ b/lib/private/releasenotes.php @@ -32,18 +32,18 @@ class ReleaseNotes { protected $dbConnection; /** - * @param OCP\IDBConnection $connection + * @param \OCP\IDBConnection $dbConnection */ - public function __construct(IDBConnection $dbConnection){ + public function __construct(IDBConnection $dbConnection) { $this->dbConnection = $dbConnection; } /** * @param string $fromVersion * @param string $toVersion - * @return array + * @return string[] */ - public function getReleaseNotes($fromVersion, $toVersion){ + public function getReleaseNotes($fromVersion, $toVersion) { $releaseNotes = []; $l10n = \OC::$server->getL10N('core'); @@ -59,16 +59,16 @@ class ReleaseNotes { $toVersionMajorMinor = ''; } - if ( $fromVersionMajorMinor === '8.2' && $toVersionMajorMinor === '9.0' ) { + if ($fromVersionMajorMinor === '8.2' && $toVersionMajorMinor === '9.0') { if (!$this->isCliMode() && $this->countFilecacheEntries() > 200000) { $releaseNotes[] = $l10n->t( - "You have an ownCloud installation with over 200.000 files so the upgrade might take a while. The recommendation is to use the command-line instead of the web interface for big ownCloud servers." + 'You have an ownCloud installation with over 200.000 files so the upgrade might take a while. The recommendation is to use the command-line instead of the web interface for big ownCloud servers.' ); } if ($this->isMysql() && $this->countFilecacheEntries() > 200000) { $releaseNotes[] = $l10n->t( - "Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE %s ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;", - [$this->dbConnection->getPrefix().'filecache'] + 'Hint: You can speed up the upgrade by executing this SQL command manually: ALTER TABLE %s ADD COLUMN checksum varchar(255) DEFAULT NULL AFTER permissions;', + [$this->dbConnection->getQueryBuilder()->getTableName('filecache')] ); } } @@ -78,7 +78,7 @@ class ReleaseNotes { /** * @return bool */ - protected function isCliMode(){ + protected function isCliMode() { return \OC::$CLI; } @@ -94,9 +94,15 @@ class ReleaseNotes { * @return int */ protected function countFilecacheEntries(){ - $result = $this->dbConnection->executeQuery("SELECT COUNT(*) FROM *PREFIX*filecache"); - $count = $result->fetchColumn(); - return $count ? $count : 0; + $query = $this->dbConnection->getQueryBuilder(); + $query->selectAlias($query->createFunction('COUNT(*)'), 'num_entries') + ->from('filecache'); + + $result = $query->execute(); + $row = $result->fetch(); + $result->closeCursor(); + + return (int) $row['num_entries']; } /** diff --git a/lib/private/server.php b/lib/private/server.php index 00ee4e5c565..581a2b44cea 100644 --- a/lib/private/server.php +++ b/lib/private/server.php @@ -623,12 +623,6 @@ class Server extends ServerContainer implements IServerContainer { return $manager; }); - - $this->registerService('ReleaseNotes', function (Server $c) { - return new \OC\ReleaseNotes( - $c->getDatabaseConnection() - ); - }); } /** @@ -1282,11 +1276,4 @@ class Server extends ServerContainer implements IServerContainer { return $this->query('ShareManager'); } - /** - * @return \OC\ReleaseNotes - */ - public function getReleaseNotes() { - return $this->query('ReleaseNotes'); - } - } |