diff options
Diffstat (limited to 'lib')
35 files changed, 755 insertions, 169 deletions
diff --git a/lib/base.php b/lib/base.php index 1db6b84c5fb..3ca4775dbe2 100644 --- a/lib/base.php +++ b/lib/base.php @@ -935,14 +935,15 @@ class OC { // emergency app disabling if ($requestPath === '/disableapp' && $request->getMethod() === 'POST' - && ((string)$request->getParam('appid')) !== '' + && ((array)$request->getParam('appid')) !== '' ) { \OCP\JSON::callCheck(); \OCP\JSON::checkAdminUser(); - $appId = (string)$request->getParam('appid'); - $appId = \OC_App::cleanAppId($appId); - - \OC_App::disable($appId); + $appIds = (array)$request->getParam('appid'); + foreach($appIds as $appId) { + $appId = \OC_App::cleanAppId($appId); + \OC_App::disable($appId); + } \OC_JSON::success(); exit(); } diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 9dea4d10fb2..8a883938b55 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -318,6 +318,12 @@ return array( 'OC\\AppFramework\\Utility\\TimeFactory' => $baseDir . '/lib/private/AppFramework/Utility/TimeFactory.php', 'OC\\AppHelper' => $baseDir . '/lib/private/AppHelper.php', 'OC\\App\\AppManager' => $baseDir . '/lib/private/App/AppManager.php', + 'OC\\App\\AppStore\\Bundles\\Bundle' => $baseDir . '/lib/private/App/AppStore/Bundles/Bundle.php', + 'OC\\App\\AppStore\\Bundles\\BundleFetcher' => $baseDir . '/lib/private/App/AppStore/Bundles/BundleFetcher.php', + 'OC\\App\\AppStore\\Bundles\\CoreBundle' => $baseDir . '/lib/private/App/AppStore/Bundles/CoreBundle.php', + 'OC\\App\\AppStore\\Bundles\\EnterpriseBundle' => $baseDir . '/lib/private/App/AppStore/Bundles/EnterpriseBundle.php', + 'OC\\App\\AppStore\\Bundles\\GroupwareBundle' => $baseDir . '/lib/private/App/AppStore/Bundles/GroupwareBundle.php', + 'OC\\App\\AppStore\\Bundles\\SocialSharingBundle' => $baseDir . '/lib/private/App/AppStore/Bundles/SocialSharingBundle.php', 'OC\\App\\AppStore\\Fetcher\\AppFetcher' => $baseDir . '/lib/private/App/AppStore/Fetcher/AppFetcher.php', 'OC\\App\\AppStore\\Fetcher\\CategoryFetcher' => $baseDir . '/lib/private/App/AppStore/Fetcher/CategoryFetcher.php', 'OC\\App\\AppStore\\Fetcher\\Fetcher' => $baseDir . '/lib/private/App/AppStore/Fetcher/Fetcher.php', @@ -511,8 +517,6 @@ return array( 'OC\\DateTimeZone' => $baseDir . '/lib/private/DateTimeZone.php', 'OC\\Diagnostics\\Event' => $baseDir . '/lib/private/Diagnostics/Event.php', 'OC\\Diagnostics\\EventLogger' => $baseDir . '/lib/private/Diagnostics/EventLogger.php', - 'OC\\Diagnostics\\NullEventLogger' => $baseDir . '/lib/private/Diagnostics/NullEventLogger.php', - 'OC\\Diagnostics\\NullQueryLogger' => $baseDir . '/lib/private/Diagnostics/NullQueryLogger.php', 'OC\\Diagnostics\\Query' => $baseDir . '/lib/private/Diagnostics/Query.php', 'OC\\Diagnostics\\QueryLogger' => $baseDir . '/lib/private/Diagnostics/QueryLogger.php', 'OC\\Encryption\\DecryptAll' => $baseDir . '/lib/private/Encryption/DecryptAll.php', @@ -727,6 +731,7 @@ return array( 'OC\\Repair\\NC11\\FixMountStorages' => $baseDir . '/lib/private/Repair/NC11/FixMountStorages.php', 'OC\\Repair\\NC11\\MoveAvatars' => $baseDir . '/lib/private/Repair/NC11/MoveAvatars.php', 'OC\\Repair\\NC11\\MoveAvatarsBackgroundJob' => $baseDir . '/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php', + 'OC\\Repair\\NC12\\InstallCoreBundle' => $baseDir . '/lib/private/Repair/NC12/InstallCoreBundle.php', 'OC\\Repair\\NC12\\UpdateLanguageCodes' => $baseDir . '/lib/private/Repair/NC12/UpdateLanguageCodes.php', 'OC\\Repair\\OldGroupMembershipShares' => $baseDir . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\RemoveRootShares' => $baseDir . '/lib/private/Repair/RemoveRootShares.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 11d949de34a..70761572620 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -348,6 +348,12 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\AppFramework\\Utility\\TimeFactory' => __DIR__ . '/../../..' . '/lib/private/AppFramework/Utility/TimeFactory.php', 'OC\\AppHelper' => __DIR__ . '/../../..' . '/lib/private/AppHelper.php', 'OC\\App\\AppManager' => __DIR__ . '/../../..' . '/lib/private/App/AppManager.php', + 'OC\\App\\AppStore\\Bundles\\Bundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/Bundle.php', + 'OC\\App\\AppStore\\Bundles\\BundleFetcher' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/BundleFetcher.php', + 'OC\\App\\AppStore\\Bundles\\CoreBundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/CoreBundle.php', + 'OC\\App\\AppStore\\Bundles\\EnterpriseBundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/EnterpriseBundle.php', + 'OC\\App\\AppStore\\Bundles\\GroupwareBundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/GroupwareBundle.php', + 'OC\\App\\AppStore\\Bundles\\SocialSharingBundle' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Bundles/SocialSharingBundle.php', 'OC\\App\\AppStore\\Fetcher\\AppFetcher' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Fetcher/AppFetcher.php', 'OC\\App\\AppStore\\Fetcher\\CategoryFetcher' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Fetcher/CategoryFetcher.php', 'OC\\App\\AppStore\\Fetcher\\Fetcher' => __DIR__ . '/../../..' . '/lib/private/App/AppStore/Fetcher/Fetcher.php', @@ -541,8 +547,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\DateTimeZone' => __DIR__ . '/../../..' . '/lib/private/DateTimeZone.php', 'OC\\Diagnostics\\Event' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/Event.php', 'OC\\Diagnostics\\EventLogger' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/EventLogger.php', - 'OC\\Diagnostics\\NullEventLogger' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/NullEventLogger.php', - 'OC\\Diagnostics\\NullQueryLogger' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/NullQueryLogger.php', 'OC\\Diagnostics\\Query' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/Query.php', 'OC\\Diagnostics\\QueryLogger' => __DIR__ . '/../../..' . '/lib/private/Diagnostics/QueryLogger.php', 'OC\\Encryption\\DecryptAll' => __DIR__ . '/../../..' . '/lib/private/Encryption/DecryptAll.php', @@ -757,6 +761,7 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OC\\Repair\\NC11\\FixMountStorages' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/FixMountStorages.php', 'OC\\Repair\\NC11\\MoveAvatars' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/MoveAvatars.php', 'OC\\Repair\\NC11\\MoveAvatarsBackgroundJob' => __DIR__ . '/../../..' . '/lib/private/Repair/NC11/MoveAvatarsBackgroundJob.php', + 'OC\\Repair\\NC12\\InstallCoreBundle' => __DIR__ . '/../../..' . '/lib/private/Repair/NC12/InstallCoreBundle.php', 'OC\\Repair\\NC12\\UpdateLanguageCodes' => __DIR__ . '/../../..' . '/lib/private/Repair/NC12/UpdateLanguageCodes.php', 'OC\\Repair\\OldGroupMembershipShares' => __DIR__ . '/../../..' . '/lib/private/Repair/OldGroupMembershipShares.php', 'OC\\Repair\\RemoveRootShares' => __DIR__ . '/../../..' . '/lib/private/Repair/RemoveRootShares.php', diff --git a/lib/l10n/nb.js b/lib/l10n/nb.js index 3e824b6376e..606de2c8dc2 100644 --- a/lib/l10n/nb.js +++ b/lib/l10n/nb.js @@ -158,6 +158,7 @@ OC.L10N.register( "Only the following characters are allowed in a username: \"a-z\", \"A-Z\", \"0-9\", and \"_.@-'\"" : "Bare disse tegnene tillates i et brukernavn: \"a-z\", \"A-Z\", \"0-9\" og \"_.@-'\"", "A valid username must be provided" : "Oppgi et gyldig brukernavn", "Username contains whitespace at the beginning or at the end" : "Brukernavn inneholder blanke på begynnelsen eller slutten", + "Username must not consist of dots only" : "Brukernavn kan ikke bare bestå av punktum", "A valid password must be provided" : "Oppgi et gyldig passord", "The username is already being used" : "Brukernavnet er allerede i bruk", "User disabled" : "Brukeren er deaktivert", diff --git a/lib/l10n/nb.json b/lib/l10n/nb.json index 246bea1e256..97c0d164723 100644 --- a/lib/l10n/nb.json +++ b/lib/l10n/nb.json @@ -156,6 +156,7 @@ "Only the following characters are allowed in a username: \"a-z\", \"A-Z\", \"0-9\", and \"_.@-'\"" : "Bare disse tegnene tillates i et brukernavn: \"a-z\", \"A-Z\", \"0-9\" og \"_.@-'\"", "A valid username must be provided" : "Oppgi et gyldig brukernavn", "Username contains whitespace at the beginning or at the end" : "Brukernavn inneholder blanke på begynnelsen eller slutten", + "Username must not consist of dots only" : "Brukernavn kan ikke bare bestå av punktum", "A valid password must be provided" : "Oppgi et gyldig passord", "The username is already being used" : "Brukernavnet er allerede i bruk", "User disabled" : "Brukeren er deaktivert", diff --git a/lib/private/App/AppStore/Bundles/Bundle.php b/lib/private/App/AppStore/Bundles/Bundle.php new file mode 100644 index 00000000000..47efc4e0cce --- /dev/null +++ b/lib/private/App/AppStore/Bundles/Bundle.php @@ -0,0 +1,59 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\App\AppStore\Bundles; + +use OCP\IL10N; + +abstract class Bundle { + /** @var IL10N */ + protected $l10n; + + /** + * @param IL10N $l10n + */ + public function __construct(IL10N $l10n) { + $this->l10n = $l10n; + } + + /** + * Get the identifier of the bundle + * + * @return string + */ + public final function getIdentifier() { + return substr(strrchr(get_class($this), '\\'), 1); + } + + /** + * Get the name of the bundle + * + * @return string + */ + public abstract function getName(); + + /** + * Get the list of app identifiers in the bundle + * + * @return array + */ + public abstract function getAppIdentifiers(); +} diff --git a/lib/private/App/AppStore/Bundles/BundleFetcher.php b/lib/private/App/AppStore/Bundles/BundleFetcher.php new file mode 100644 index 00000000000..01cd4d6a518 --- /dev/null +++ b/lib/private/App/AppStore/Bundles/BundleFetcher.php @@ -0,0 +1,80 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\App\AppStore\Bundles; + +use OCP\IL10N; + +class BundleFetcher { + /** @var IL10N */ + private $l10n; + + /** + * @param IL10N $l10n + */ + public function __construct(IL10N $l10n) { + $this->l10n = $l10n; + } + + /** + * @return Bundle[] + */ + public function getBundles() { + return [ + new EnterpriseBundle($this->l10n), + new GroupwareBundle($this->l10n), + new SocialSharingBundle($this->l10n), + ]; + } + + /** + * Bundles that should be installed by default after installation + * + * @return Bundle[] + */ + public function getDefaultInstallationBundle() { + return [ + new CoreBundle($this->l10n), + ]; + } + + /** + * Get the bundle with the specified identifier + * + * @param string $identifier + * @return Bundle + * @throws \BadMethodCallException If the bundle does not exist + */ + public function getBundleByIdentifier($identifier) { + /** @var Bundle[] $bundles */ + $bundles = array_merge( + $this->getBundles(), + $this->getDefaultInstallationBundle() + ); + foreach($bundles as $bundle) { + if($bundle->getIdentifier() === $identifier) { + return $bundle; + } + } + + throw new \BadMethodCallException('Bundle with specified identifier does not exist'); + } +} diff --git a/lib/private/App/AppStore/Bundles/CoreBundle.php b/lib/private/App/AppStore/Bundles/CoreBundle.php new file mode 100644 index 00000000000..a87292b9ec9 --- /dev/null +++ b/lib/private/App/AppStore/Bundles/CoreBundle.php @@ -0,0 +1,42 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\App\AppStore\Bundles; + +class CoreBundle extends Bundle { + + /** + * {@inheritDoc} + */ + public function getName() { + return 'Core bundle'; + } + + /** + * {@inheritDoc} + */ + public function getAppIdentifiers() { + return [ + 'bruteforcesettings', + ]; + } + +} diff --git a/lib/private/App/AppStore/Bundles/EnterpriseBundle.php b/lib/private/App/AppStore/Bundles/EnterpriseBundle.php new file mode 100644 index 00000000000..6d43a6210fa --- /dev/null +++ b/lib/private/App/AppStore/Bundles/EnterpriseBundle.php @@ -0,0 +1,47 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\App\AppStore\Bundles; + +class EnterpriseBundle extends Bundle { + + /** + * {@inheritDoc} + */ + public function getName() { + return (string)$this->l10n->t('Enterprise bundle'); + } + + /** + * {@inheritDoc} + */ + public function getAppIdentifiers() { + return [ + 'admin_audit', + 'user_ldap', + 'files_retention', + 'files_automatedtagging', + 'user_saml', + 'files_accesscontrol', + ]; + } + +} diff --git a/lib/private/App/AppStore/Bundles/GroupwareBundle.php b/lib/private/App/AppStore/Bundles/GroupwareBundle.php new file mode 100644 index 00000000000..7e7414f69c7 --- /dev/null +++ b/lib/private/App/AppStore/Bundles/GroupwareBundle.php @@ -0,0 +1,44 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\App\AppStore\Bundles; + +class GroupwareBundle extends Bundle { + + /** + * {@inheritDoc} + */ + public function getName() { + return (string)$this->l10n->t('Groupware bundle'); + } + + /** + * {@inheritDoc} + */ + public function getAppIdentifiers() { + return [ + 'calendar', + 'contacts', + 'spreed', + ]; + } + +} diff --git a/lib/private/App/AppStore/Bundles/SocialSharingBundle.php b/lib/private/App/AppStore/Bundles/SocialSharingBundle.php new file mode 100644 index 00000000000..8da84e8d1ef --- /dev/null +++ b/lib/private/App/AppStore/Bundles/SocialSharingBundle.php @@ -0,0 +1,46 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\App\AppStore\Bundles; + +class SocialSharingBundle extends Bundle { + + /** + * {@inheritDoc} + */ + public function getName() { + return (string)$this->l10n->t('Social sharing bundle'); + } + + /** + * {@inheritDoc} + */ + public function getAppIdentifiers() { + return [ + 'socialsharing_twitter', + 'socialsharing_googleplus', + 'socialsharing_facebook', + 'socialsharing_email', + 'socialsharing_diaspora', + ]; + } + +} diff --git a/lib/private/BackgroundJob/Job.php b/lib/private/BackgroundJob/Job.php index 726c66ef5d7..cb9328f01b9 100644 --- a/lib/private/BackgroundJob/Job.php +++ b/lib/private/BackgroundJob/Job.php @@ -49,8 +49,18 @@ abstract class Job implements IJob { */ public function execute($jobList, ILogger $logger = null) { $jobList->setLastRun($this); + if ($logger === null) { + $logger = \OC::$server->getLogger(); + } + try { + $jobStartTime = time(); + $logger->debug('Run ' . get_class($this) . ' job with ID ' . $this->getId(), ['app' => 'cron']); $this->run($this->argument); + $timeTaken = time() - $jobStartTime; + + $logger->debug('Finished ' . get_class($this) . ' job with ID ' . $this->getId() . ' in ' . $timeTaken . ' seconds', ['app' => 'cron']); + $jobList->setExecutionTime($this, $timeTaken); } catch (\Exception $e) { if ($logger) { $logger->logException($e, [ diff --git a/lib/private/BackgroundJob/JobList.php b/lib/private/BackgroundJob/JobList.php index 0de5dfecc8b..b0c580290ed 100644 --- a/lib/private/BackgroundJob/JobList.php +++ b/lib/private/BackgroundJob/JobList.php @@ -275,7 +275,7 @@ class JobList implements IJobList { * * @param IJob $job */ - public function setLastJob($job) { + public function setLastJob(IJob $job) { $this->unlockJob($job); $this->config->setAppValue('backgroundjob', 'lastjob', $job->getId()); } @@ -285,7 +285,7 @@ class JobList implements IJobList { * * @param IJob $job */ - public function unlockJob($job) { + public function unlockJob(IJob $job) { $query = $this->connection->getQueryBuilder(); $query->update('jobs') ->set('reserved_at', $query->expr()->literal(0, IQueryBuilder::PARAM_INT)) @@ -310,11 +310,23 @@ class JobList implements IJobList { * * @param IJob $job */ - public function setLastRun($job) { + public function setLastRun(IJob $job) { $query = $this->connection->getQueryBuilder(); $query->update('jobs') ->set('last_run', $query->createNamedParameter(time(), IQueryBuilder::PARAM_INT)) ->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT))); $query->execute(); } + + /** + * @param IJob $job + * @param $timeTaken + */ + public function setExecutionTime(IJob $job, $timeTaken) { + $query = $this->connection->getQueryBuilder(); + $query->update('jobs') + ->set('execution_duration', $query->createNamedParameter($timeTaken, IQueryBuilder::PARAM_INT)) + ->where($query->expr()->eq('id', $query->createNamedParameter($job->getId(), IQueryBuilder::PARAM_INT))); + $query->execute(); + } } diff --git a/lib/private/Contacts/ContactsMenu/ContactsStore.php b/lib/private/Contacts/ContactsMenu/ContactsStore.php index 1cdb5d6fc5f..40a0bf87031 100644 --- a/lib/private/Contacts/ContactsMenu/ContactsStore.php +++ b/lib/private/Contacts/ContactsMenu/ContactsStore.php @@ -60,6 +60,50 @@ class ContactsStore { } /** + * @param IUser $user + * @param integer $shareType + * @param string $shareWith + * @return IEntry|null + */ + public function findOne(IUser $user, $shareType, $shareWith) { + switch($shareType) { + case 0: + case 6: + $filter = ['UID']; + break; + case 4: + $filter = ['EMAIL']; + break; + default: + return null; + } + + $userId = $user->getUID(); + $allContacts = $this->contactsManager->search($shareWith, $filter); + $contacts = array_filter($allContacts, function($contact) use ($userId) { + return $contact['UID'] !== $userId; + }); + $match = null; + + foreach ($contacts as $contact) { + if ($shareType === 4 && isset($contact['EMAIL'])) { + if (in_array($shareWith, $contact['EMAIL'])) { + $match = $contact; + break; + } + } + if ($shareType === 0 || $shareType === 6) { + if ($contact['UID'] === $shareWith && $contact['isLocalSystemBook'] === true) { + $match = $contact; + break; + } + } + } + + return $match ? $this->contactArrayToEntry($match) : null; + } + + /** * @param array $contact * @return Entry */ diff --git a/lib/private/Contacts/ContactsMenu/Manager.php b/lib/private/Contacts/ContactsMenu/Manager.php index 16d77c2df08..766b4623253 100644 --- a/lib/private/Contacts/ContactsMenu/Manager.php +++ b/lib/private/Contacts/ContactsMenu/Manager.php @@ -51,7 +51,7 @@ class Manager { } /** - * @param string $user + * @param IUser $user * @param string $filter * @return array */ @@ -70,6 +70,21 @@ class Manager { } /** + * @param IUser $user + * @param integer $shareType + * @param string $shareWith + * @return IEntry + */ + public function findOne(IUser $user, $shareType, $shareWith) { + $entry = $this->store->findOne($user, $shareType, $shareWith); + if ($entry) { + $this->processEntries([$entry], $user); + } + + return $entry; + } + + /** * @param IEntry[] $entries * @return IEntry[] */ diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index 9e116712642..6b56ae8ad5c 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -167,9 +167,6 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { $statement = $this->replaceTablePrefix($statement); $statement = $this->adapter->fixupStatement($statement); - if(\OC::$server->getSystemConfig()->getValue( 'log_query', false)) { - \OCP\Util::writeLog('core', 'DB prepare : '.$statement, \OCP\Util::DEBUG); - } return parent::prepare($statement); } diff --git a/lib/private/Diagnostics/EventLogger.php b/lib/private/Diagnostics/EventLogger.php index 5abaae3f1dd..846be7efc5b 100644 --- a/lib/private/Diagnostics/EventLogger.php +++ b/lib/private/Diagnostics/EventLogger.php @@ -4,6 +4,8 @@ * * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Piotr Mrowczynski <piotr@owncloud.com> * * @license AGPL-3.0 * @@ -29,28 +31,53 @@ class EventLogger implements IEventLogger { /** * @var \OC\Diagnostics\Event[] */ - private $events = array(); + private $events = []; + + /** + * @var bool - Module needs to be activated by some app + */ + private $activated = false; + /** + * @inheritdoc + */ public function start($id, $description) { - $this->events[$id] = new Event($id, $description, microtime(true)); + if ($this->activated){ + $this->events[$id] = new Event($id, $description, microtime(true)); + } } + /** + * @inheritdoc + */ public function end($id) { - if (isset($this->events[$id])) { + if ($this->activated && isset($this->events[$id])) { $timing = $this->events[$id]; $timing->end(microtime(true)); } } + /** + * @inheritdoc + */ public function log($id, $description, $start, $end) { - $this->events[$id] = new Event($id, $description, $start); - $this->events[$id]->end($end); + if ($this->activated) { + $this->events[$id] = new Event($id, $description, $start); + $this->events[$id]->end($end); + } } /** - * @return \OCP\Diagnostics\IEvent[] + * @inheritdoc */ public function getEvents() { return $this->events; } + + /** + * @inheritdoc + */ + public function activate() { + $this->activated = true; + } } diff --git a/lib/private/Diagnostics/NullEventLogger.php b/lib/private/Diagnostics/NullEventLogger.php deleted file mode 100644 index 9fe7461eb45..00000000000 --- a/lib/private/Diagnostics/NullEventLogger.php +++ /dev/null @@ -1,58 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IEventLogger; - -/** - * Dummy event logger that doesn't actually log anything - */ -class NullEventLogger implements IEventLogger { - /** - * Mark the start of an event - * - * @param $id - * @param $description - */ - public function start($id, $description) { - } - - /** - * Mark the end of an event - * - * @param $id - */ - public function end($id) { - } - - public function log($id, $description, $start, $end) { - } - - /** - * @return \OCP\Diagnostics\IEvent[] - */ - public function getEvents() { - return array(); - } -} diff --git a/lib/private/Diagnostics/NullQueryLogger.php b/lib/private/Diagnostics/NullQueryLogger.php deleted file mode 100644 index 873f556f90e..00000000000 --- a/lib/private/Diagnostics/NullQueryLogger.php +++ /dev/null @@ -1,46 +0,0 @@ -<?php -/** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace OC\Diagnostics; - -use OCP\Diagnostics\IQueryLogger; - -class NullQueryLogger implements IQueryLogger { - /** - * @param string $sql - * @param array $params - * @param array $types - */ - public function startQuery($sql, array $params = null, array $types = null) { - } - - public function stopQuery() { - } - - /** - * @return \OCP\Diagnostics\IQuery[] - */ - public function getQueries() { - return array(); - } -} diff --git a/lib/private/Diagnostics/Query.php b/lib/private/Diagnostics/Query.php index 8ac2cc0eeac..7b083ed41b7 100644 --- a/lib/private/Diagnostics/Query.php +++ b/lib/private/Diagnostics/Query.php @@ -67,7 +67,14 @@ class Query implements IQuery { } /** - * @return int + * @return float + */ + public function getStart() { + return $this->start; + } + + /** + * @return float */ public function getDuration() { return $this->end - $this->start; diff --git a/lib/private/Diagnostics/QueryLogger.php b/lib/private/Diagnostics/QueryLogger.php index 5f2a061a910..875d25e9be3 100644 --- a/lib/private/Diagnostics/QueryLogger.php +++ b/lib/private/Diagnostics/QueryLogger.php @@ -4,6 +4,8 @@ * * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Thomas Müller <thomas.mueller@tmit.eu> + * @author Piotr Mrowczynski <piotr@owncloud.com> * * @license AGPL-3.0 * @@ -46,12 +48,17 @@ class QueryLogger implements IQueryLogger { /** - * @param string $sql - * @param array $params - * @param array $types + * @var bool - Module needs to be activated by some app + */ + private $activated = false; + + /** + * @inheritdoc */ public function startQuery($sql, array $params = null, array $types = null) { - $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); + if ($this->activated) { + $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); + } } private function getStack() { @@ -62,8 +69,11 @@ class QueryLogger implements IQueryLogger { return $stack; } + /** + * @inheritdoc + */ public function stopQuery() { - if ($this->activeQuery) { + if ($this->activated && $this->activeQuery) { $this->activeQuery->end(microtime(true)); $this->queries[] = $this->activeQuery; $this->activeQuery = null; @@ -71,9 +81,16 @@ class QueryLogger implements IQueryLogger { } /** - * @return Query[] + * @inheritdoc */ public function getQueries() { return $this->queries->getData(); } + + /** + * @inheritdoc + */ + public function activate() { + $this->activated = true; + } } diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 02f355fd4d9..fac95462ce5 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -47,6 +47,8 @@ use OCP\ILogger; * @package OC\Files\Utils */ class Scanner extends PublicEmitter { + const MAX_ENTRIES_TO_COMMIT = 10000; + /** * @var string $user */ @@ -63,6 +65,20 @@ class Scanner extends PublicEmitter { protected $logger; /** + * Whether to use a DB transaction + * + * @var bool + */ + protected $useTransaction; + + /** + * Number of entries scanned to commit + * + * @var int + */ + protected $entriesToCommit; + + /** * @param string $user * @param \OCP\IDBConnection $db * @param ILogger $logger @@ -71,6 +87,8 @@ class Scanner extends PublicEmitter { $this->logger = $logger; $this->user = $user; $this->db = $db; + // when DB locking is used, no DB transactions will be used + $this->useTransaction = !(\OC::$server->getLockingProvider() instanceof DBLockingProvider); } /** @@ -200,22 +218,22 @@ class Scanner extends PublicEmitter { $scanner = $storage->getScanner(); $scanner->setUseTransactions(false); $this->attachListener($mount); - $isDbLocking = \OC::$server->getLockingProvider() instanceof DBLockingProvider; $scanner->listen('\OC\Files\Cache\Scanner', 'removeFromCache', function ($path) use ($storage) { - $this->triggerPropagator($storage, $path); + $this->postProcessEntry($storage, $path); }); $scanner->listen('\OC\Files\Cache\Scanner', 'updateCache', function ($path) use ($storage) { - $this->triggerPropagator($storage, $path); + $this->postProcessEntry($storage, $path); }); $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function ($path) use ($storage) { - $this->triggerPropagator($storage, $path); + $this->postProcessEntry($storage, $path); }); if (!$storage->file_exists($relativePath)) { throw new NotFoundException($dir); } - if (!$isDbLocking) { + + if ($this->useTransaction) { $this->db->beginTransaction(); } try { @@ -233,7 +251,7 @@ class Scanner extends PublicEmitter { $this->logger->logException($e); $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); } - if (!$isDbLocking) { + if ($this->useTransaction) { $this->db->commit(); } } @@ -242,5 +260,20 @@ class Scanner extends PublicEmitter { private function triggerPropagator(IStorage $storage, $internalPath) { $storage->getPropagator()->propagateChange($internalPath, time()); } + + private function postProcessEntry(IStorage $storage, $internalPath) { + $this->triggerPropagator($storage, $internalPath); + if ($this->useTransaction) { + $this->entriesToCommit++; + if ($this->entriesToCommit >= self::MAX_ENTRIES_TO_COMMIT) { + $propagator = $storage->getPropagator(); + $this->entriesToCommit = 0; + $this->db->commit(); + $propagator->commitBatch(); + $this->db->beginTransaction(); + $propagator->beginBatch(); + } + } + } } diff --git a/lib/private/Installer.php b/lib/private/Installer.php index 0d6030d5744..8702f264e54 100644 --- a/lib/private/Installer.php +++ b/lib/private/Installer.php @@ -42,6 +42,8 @@ namespace OC; use Doctrine\DBAL\Exception\TableExistsException; +use OC\App\AppManager; +use OC\App\AppStore\Bundles\Bundle; use OC\App\AppStore\Fetcher\AppFetcher; use OC\App\CodeChecker\CodeChecker; use OC\App\CodeChecker\EmptyCheck; @@ -50,7 +52,9 @@ use OC\Archive\TAR; use OC_App; use OC_DB; use OC_Helper; +use OCP\App\IAppManager; use OCP\Http\Client\IClientService; +use OCP\IConfig; use OCP\ILogger; use OCP\ITempManager; use phpseclib\File\X509; @@ -67,21 +71,26 @@ class Installer { private $tempManager; /** @var ILogger */ private $logger; + /** @var IConfig */ + private $config; /** * @param AppFetcher $appFetcher * @param IClientService $clientService * @param ITempManager $tempManager * @param ILogger $logger + * @param IConfig $config */ public function __construct(AppFetcher $appFetcher, IClientService $clientService, ITempManager $tempManager, - ILogger $logger) { + ILogger $logger, + IConfig $config) { $this->appFetcher = $appFetcher; $this->clientService = $clientService; $this->tempManager = $tempManager; $this->logger = $logger; + $this->config = $config; } /** @@ -109,6 +118,7 @@ class Installer { } } + \OC_App::registerAutoloading($appId, $basedir); \OC_App::setupBackgroundJobs($info['background-jobs']); //run appinfo/install.php @@ -420,6 +430,27 @@ class Installer { } /** + * Installs the app within the bundle and marks the bundle as installed + * + * @param Bundle $bundle + * @throws \Exception If app could not get installed + */ + public function installAppBundle(Bundle $bundle) { + $appIds = $bundle->getAppIdentifiers(); + foreach($appIds as $appId) { + if(!$this->isDownloaded($appId)) { + $this->downloadApp($appId); + } + $this->installApp($appId); + $app = new OC_App(); + $app->enable($appId); + } + $bundles = json_decode($this->config->getAppValue('core', 'installed.bundles', json_encode([])), true); + $bundles[] = $bundle->getIdentifier(); + $this->config->setAppValue('core', 'installed.bundles', json_encode($bundles)); + } + + /** * Installs shipped apps * * This function installs all apps found in the 'apps' directory that should be enabled by default; diff --git a/lib/private/Repair.php b/lib/private/Repair.php index e808774ec93..65e0342905a 100644 --- a/lib/private/Repair.php +++ b/lib/private/Repair.php @@ -30,12 +30,14 @@ namespace OC; +use OC\App\AppStore\Bundles\BundleFetcher; use OC\Repair\CleanTags; use OC\Repair\Collation; use OC\Repair\MoveUpdaterStepFile; use OC\Repair\NC11\CleanPreviews; use OC\Repair\NC11\FixMountStorages; use OC\Repair\NC11\MoveAvatars; +use OC\Repair\NC12\InstallCoreBundle; use OC\Repair\NC12\UpdateLanguageCodes; use OC\Repair\OldGroupMembershipShares; use OC\Repair\RemoveRootShares; @@ -136,6 +138,11 @@ class Repair implements IOutput{ ), new FixMountStorages(\OC::$server->getDatabaseConnection()), new UpdateLanguageCodes(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig()), + new InstallCoreBundle( + \OC::$server->query(BundleFetcher::class), + \OC::$server->getConfig(), + \OC::$server->query(Installer::class) + ) ]; } diff --git a/lib/private/Repair/NC12/InstallCoreBundle.php b/lib/private/Repair/NC12/InstallCoreBundle.php new file mode 100644 index 00000000000..38583b09a89 --- /dev/null +++ b/lib/private/Repair/NC12/InstallCoreBundle.php @@ -0,0 +1,78 @@ +<?php +/** + * @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OC\Repair\NC12; + +use OC\App\AppStore\Bundles\BundleFetcher; +use OC\Installer; +use OCP\IConfig; +use OCP\Migration\IOutput; +use OCP\Migration\IRepairStep; + +class InstallCoreBundle implements IRepairStep { + /** @var BundleFetcher */ + private $bundleFetcher; + /** @var IConfig */ + private $config; + /** @var Installer */ + private $installer; + + /** + * @param BundleFetcher $bundleFetcher + * @param IConfig $config + * @param Installer $installer + */ + public function __construct(BundleFetcher $bundleFetcher, + IConfig $config, + Installer $installer) { + $this->bundleFetcher = $bundleFetcher; + $this->config = $config; + $this->installer = $installer; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return 'Install new core bundle components'; + } + + /** + * {@inheritdoc} + */ + public function run(IOutput $output) { + $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0'); + + if (version_compare($versionFromBeforeUpdate, '12.0.0.14', '>')) { + return; + } + + $defaultBundle = $this->bundleFetcher->getDefaultInstallationBundle(); + foreach($defaultBundle as $bundle) { + try { + $this->installer->installAppBundle($bundle); + $output->info('Successfully installed core app bundle.'); + } catch (\Exception $e) { + $output->warning('Could not install core app bundle: ' . $e->getMessage()); + } + } + } +} diff --git a/lib/private/Server.php b/lib/private/Server.php index 7724feb551b..25c0b5d9cc9 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -43,6 +43,7 @@ namespace OC; use bantu\IniGetWrapper\IniGetWrapper; use OC\App\AppManager; +use OC\App\AppStore\Bundles\BundleFetcher; use OC\App\AppStore\Fetcher\AppFetcher; use OC\App\AppStore\Fetcher\CategoryFetcher; use OC\AppFramework\Http\Request; @@ -602,22 +603,23 @@ class Server extends ServerContainer implements IServerContainer { ); }); $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { + $eventLogger = new EventLogger(); if ($c->getSystemConfig()->getValue('debug', false)) { - return new EventLogger(); - } else { - return new NullEventLogger(); + // In debug mode, module is being activated by default + $eventLogger->activate(); } + return $eventLogger; }); $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { + $queryLogger = new QueryLogger(); if ($c->getSystemConfig()->getValue('debug', false)) { - return new QueryLogger(); - } else { - return new NullQueryLogger(); + // In debug mode, module is being activated by default + $queryLogger->activate(); } + return $queryLogger; }); $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); @@ -816,7 +818,12 @@ class Server extends ServerContainer implements IServerContainer { ); }); $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); - + $this->registerService(BundleFetcher::class, function () { + return new BundleFetcher($this->getL10N('lib')); + }); + $this->registerService(AppFetcher::class, function() { + return $this->getAppFetcher(); + }); $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { return new Manager( $c->query(IValidator::class) diff --git a/lib/private/Setup.php b/lib/private/Setup.php index e2806efad48..b1cf289d9aa 100644 --- a/lib/private/Setup.php +++ b/lib/private/Setup.php @@ -41,6 +41,7 @@ namespace OC; use bantu\IniGetWrapper\IniGetWrapper; use Exception; +use OC\App\AppStore\Bundles\BundleFetcher; use OCP\Defaults; use OCP\IL10N; use OCP\ILogger; @@ -63,11 +64,12 @@ class Setup { /** * @param SystemConfig $config * @param IniGetWrapper $iniWrapper + * @param IL10N $l10n * @param Defaults $defaults * @param ILogger $logger * @param ISecureRandom $random */ - function __construct(SystemConfig $config, + public function __construct(SystemConfig $config, IniGetWrapper $iniWrapper, IL10N $l10n, Defaults $defaults, @@ -364,8 +366,22 @@ class Setup { $group =\OC::$server->getGroupManager()->createGroup('admin'); $group->addUser($user); - //guess what this does + // Install shipped apps and specified app bundles Installer::installShippedApps(); + $installer = new Installer( + \OC::$server->getAppFetcher(), + \OC::$server->getHTTPClientService(), + \OC::$server->getTempManager(), + \OC::$server->getLogger(), + \OC::$server->getConfig() + ); + $bundleFetcher = new BundleFetcher(\OC::$server->getL10N('lib')); + $defaultInstallationBundles = $bundleFetcher->getDefaultInstallationBundle(); + foreach($defaultInstallationBundles as $bundle) { + try { + $installer->installAppBundle($bundle); + } catch (Exception $e) {} + } // create empty file in data dir, so we can later find // out that this is indeed an ownCloud data directory diff --git a/lib/private/Updater.php b/lib/private/Updater.php index 4427e4c48dc..c080ee0eb43 100644 --- a/lib/private/Updater.php +++ b/lib/private/Updater.php @@ -243,11 +243,11 @@ class Updater extends BasicEmitter { } // update all shipped apps - $disabledApps = $this->checkAppsRequirements(); + $this->checkAppsRequirements(); $this->doAppUpgrade(); // upgrade appstore apps - $this->upgradeAppStoreApps($disabledApps); + $this->upgradeAppStoreApps(\OC::$server->getAppManager()->getInstalledApps()); // install new shipped apps on upgrade OC_App::loadApps('authentication'); @@ -441,7 +441,8 @@ class Updater extends BasicEmitter { \OC::$server->getAppFetcher(), \OC::$server->getHTTPClientService(), \OC::$server->getTempManager(), - $this->log + $this->log, + \OC::$server->getConfig() ); if (Installer::isUpdateAvailable($app, \OC::$server->getAppFetcher())) { $this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]); diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php index 3800b8b770e..111da7d0d40 100644 --- a/lib/private/legacy/app.php +++ b/lib/private/legacy/app.php @@ -365,7 +365,8 @@ class OC_App { \OC::$server->getAppFetcher(), \OC::$server->getHTTPClientService(), \OC::$server->getTempManager(), - \OC::$server->getLogger() + \OC::$server->getLogger(), + \OC::$server->getConfig() ); $isDownloaded = $installer->isDownloaded($appId); @@ -427,7 +428,8 @@ class OC_App { \OC::$server->getAppFetcher(), \OC::$server->getHTTPClientService(), \OC::$server->getTempManager(), - \OC::$server->getLogger() + \OC::$server->getLogger(), + \OC::$server->getConfig() ); return $installer->removeApp($app); } diff --git a/lib/private/legacy/db/statementwrapper.php b/lib/private/legacy/db/statementwrapper.php index dedaf2d8cef..53f7b484d04 100644 --- a/lib/private/legacy/db/statementwrapper.php +++ b/lib/private/legacy/db/statementwrapper.php @@ -64,14 +64,7 @@ class OC_DB_StatementWrapper { * @param array $input * @return \OC_DB_StatementWrapper|int */ - public function execute($input=array()) { - if(\OC::$server->getSystemConfig()->getValue( "log_query", false)) { - $backTrace = debug_backtrace(); - $class = $backTrace[1]['class'] . ':' . $backTrace[1]['function']; - $file = substr($backTrace[0]['file'], strlen(\OC::$SERVERROOT)) . ':' . $backTrace[0]['line']; - $params_str = str_replace("\n", " ", var_export($input, true)); - \OCP\Util::writeLog('core', "DB execute with arguments : $params_str in $class; $file", \OCP\Util::DEBUG); - } + public function execute($input= []) { $this->lastArguments = $input; if (count($input) > 0) { $result = $this->statement->execute($input); diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 9516a67af48..d49599cb8a1 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -1388,6 +1388,12 @@ class OC_Util { if (\OC\Files\Filesystem::isIgnoredDir($trimmed)) { return false; } + + // detect part files + if (preg_match('/' . \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX . '/', $trimmed) !== 0) { + return false; + } + foreach (str_split($trimmed) as $char) { if (strpos(\OCP\Constants::FILENAME_INVALID_CHARS, $char) !== false) { return false; diff --git a/lib/public/BackgroundJob/IJobList.php b/lib/public/BackgroundJob/IJobList.php index fbc46192227..d7c2642712c 100644 --- a/lib/public/BackgroundJob/IJobList.php +++ b/lib/public/BackgroundJob/IJobList.php @@ -91,7 +91,7 @@ interface IJobList { * @param \OCP\BackgroundJob\IJob $job * @since 7.0.0 */ - public function setLastJob($job); + public function setLastJob(IJob $job); /** * Remove the reservation for a job @@ -99,7 +99,7 @@ interface IJobList { * @param IJob $job * @since 9.1.0 */ - public function unlockJob($job); + public function unlockJob(IJob $job); /** * get the id of the last ran job @@ -115,8 +115,17 @@ interface IJobList { /** * set the lastRun of $job to now * - * @param \OCP\BackgroundJob\IJob $job + * @param IJob $job * @since 7.0.0 */ - public function setLastRun($job); + public function setLastRun(IJob $job); + + /** + * set the run duration of $job + * + * @param IJob $job + * @param $timeTaken + * @since 12.0.0 + */ + public function setExecutionTime(IJob $job, $timeTaken); } diff --git a/lib/public/Diagnostics/IEventLogger.php b/lib/public/Diagnostics/IEventLogger.php index 517a131d436..c76e96c5674 100644 --- a/lib/public/Diagnostics/IEventLogger.php +++ b/lib/public/Diagnostics/IEventLogger.php @@ -4,6 +4,7 @@ * * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Piotr Mrowczynski <piotr@owncloud.com> * * @license AGPL-3.0 * @@ -31,7 +32,7 @@ namespace OCP\Diagnostics; */ interface IEventLogger { /** - * Mark the start of an event + * Mark the start of an event setting its ID $id and providing event description $description. * * @param string $id * @param string $description @@ -40,7 +41,9 @@ interface IEventLogger { public function start($id, $description); /** - * Mark the end of an event + * Mark the end of an event with specific ID $id, marked by start() method. + * Ending event should store \OCP\Diagnostics\IEvent to + * be returned with getEvents() method. * * @param string $id * @since 8.0.0 @@ -48,6 +51,11 @@ interface IEventLogger { public function end($id); /** + * Mark the start and the end of an event with specific ID $id and description $description, + * explicitly marking start and end of the event, represented by $start and $end timestamps. + * Logging event should store \OCP\Diagnostics\IEvent to + * be returned with getEvents() method. + * * @param string $id * @param string $description * @param float $start @@ -57,8 +65,21 @@ interface IEventLogger { public function log($id, $description, $start, $end); /** + * This method should return all \OCP\Diagnostics\IEvent objects stored using + * start()/end() or log() methods + * * @return \OCP\Diagnostics\IEvent[] * @since 8.0.0 */ public function getEvents(); + + /** + * Activate the module for the duration of the request. Deactivated module + * does not create and store \OCP\Diagnostics\IEvent objects. + * Only activated module should create and store objects to be + * returned with getEvents() call. + * + * @since 12.0.0 + */ + public function activate(); } diff --git a/lib/public/Diagnostics/IQuery.php b/lib/public/Diagnostics/IQuery.php index 7f26bd7f1b8..ceaee191b39 100644 --- a/lib/public/Diagnostics/IQuery.php +++ b/lib/public/Diagnostics/IQuery.php @@ -59,4 +59,9 @@ interface IQuery { * @since 11.0.0 */ public function getStacktrace(); + /** + * @return array + * @since 12.0.0 + */ + public function getStart(); } diff --git a/lib/public/Diagnostics/IQueryLogger.php b/lib/public/Diagnostics/IQueryLogger.php index 58ea78795e2..32723a56cb9 100644 --- a/lib/public/Diagnostics/IQueryLogger.php +++ b/lib/public/Diagnostics/IQueryLogger.php @@ -4,6 +4,7 @@ * * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> + * @author Piotr Mrowczynski <piotr@owncloud.com> * * @license AGPL-3.0 * @@ -33,6 +34,10 @@ use Doctrine\DBAL\Logging\SQLLogger; */ interface IQueryLogger extends SQLLogger { /** + * Mark the start of a query providing query SQL statement, its parameters and types. + * This method should be called as close to the DB as possible and after + * query is finished finalized with stopQuery() method. + * * @param string $sql * @param array $params * @param array $types @@ -41,14 +46,30 @@ interface IQueryLogger extends SQLLogger { public function startQuery($sql, array $params = null, array $types = null); /** + * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to + * be returned with getQueries() method. + * * @return mixed * @since 8.0.0 */ public function stopQuery(); /** + * This method should return all \OCP\Diagnostics\IQuery objects stored using + * startQuery()/stopQuery() methods. + * * @return \OCP\Diagnostics\IQuery[] * @since 8.0.0 */ public function getQueries(); + + /** + * Activate the module for the duration of the request. Deactivated module + * does not create and store \OCP\Diagnostics\IQuery objects. + * Only activated module should create and store objects to be + * returned with getQueries() call. + * + * @since 12.0.0 + */ + public function activate(); } |