Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ceeb44b
Initial work on Apps page split:
blizzz Aug 8, 2016
9d9c540
fix duplicated db index name
blizzz Aug 9, 2016
97df444
remove mistakenly added file
blizzz Aug 9, 2016
518545f
Fallback for legacy settings. They are placed into Additional Settings
blizzz Aug 9, 2016
1eb8b95
more admin page splitup improvements
blizzz Aug 10, 2016
0fc34c9
fix registration of admin settings and section on app install
blizzz Aug 10, 2016
f3b15a9
fixes, improvements, and another app:
blizzz Aug 10, 2016
14ddf9d
rename IAdmin to ISettings, the interface is not bound to a specific …
blizzz Aug 11, 2016
5696c8a
adjust federatedfilesharing
blizzz Aug 11, 2016
a2f752b
adjust files_external
blizzz Aug 11, 2016
ce6ad5d
make sure shipped apps also setup their admin settings on a fresh ins…
blizzz Aug 11, 2016
e8ea671
superfluous
blizzz Aug 11, 2016
36c1b7e
adjust Theming app
blizzz Aug 11, 2016
30ff3ad
adjust files app, and integrate files_external into that section
blizzz Aug 11, 2016
c0a2a1f
superfluous
blizzz Aug 11, 2016
3f9e1b3
adjust federation app
blizzz Aug 11, 2016
3dfdc8e
adjust systemtags app
blizzz Aug 11, 2016
8f12f5d
Add missing since annotations
LukasReschke Aug 11, 2016
225eb27
Add since tags to class
LukasReschke Aug 11, 2016
8261ccc
Merge branch 'master' into implement_712
LukasReschke Aug 11, 2016
82bf479
Resolve conflict
LukasReschke Aug 11, 2016
ac04ba6
register app autoload instead of loading apps
blizzz Aug 12, 2016
18fd8ff
rename "Tenmplate" to "ThemingDefaults" to make the auto loader happy"
schiessle Aug 12, 2016
0c15081
rename remaining occurences of OCA/Theming/Template
blizzz Aug 12, 2016
9aa6b99
added some missed diagnosis output
blizzz Aug 12, 2016
0fdf801
fix theming tests
blizzz Aug 12, 2016
90e58b7
mark current section
blizzz Aug 12, 2016
7a2b96c
change casing in section display names
blizzz Aug 12, 2016
a133e79
make updatenotification settings appear as if it is part of the versi…
blizzz Aug 12, 2016
b99ecb3
move systemstags to sharign section, drop collaboration section
blizzz Aug 12, 2016
d2fcac8
change federatedfilesharing css class to followupsection to reduce wh…
blizzz Aug 12, 2016
158d78e
move mail settings and file handling to additional ones, thus files_e…
blizzz Aug 12, 2016
8188bb4
simplify encryption manager fetching in DIContainer
blizzz Aug 12, 2016
75a73a5
satisfy dependencies for files_external
blizzz Aug 15, 2016
8a7a0f3
Add unit tests
LukasReschke Aug 15, 2016
7ffb7b0
Use MockBuilder instead of createMock
LukasReschke Aug 15, 2016
6c6338b
Merge branch 'master' into implement_712
LukasReschke Aug 15, 2016
9edca39
attempt to remove section and settings entries when an app got disabled
blizzz Aug 15, 2016
208e551
check registered sections and settings after an app got updated to ga…
blizzz Aug 15, 2016
d96e8f5
adopt to Controller constructor changes
blizzz Aug 15, 2016
83ba2f2
final db indexes
blizzz Aug 16, 2016
58530ab
fix missing parameters in sharing settings page
blizzz Aug 16, 2016
f76b64d
add missing encryption modules to settings
blizzz Aug 16, 2016
4946cc2
for new we cannot have nested settings, default module is only append…
blizzz Aug 16, 2016
717e222
Merge branch 'master' into implement_712
blizzz Aug 16, 2016
4943441
adjust tests to latest changes
blizzz Aug 16, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
check registered sections and settings after an app got updated to ga…
…rbage collect orphaned classes
  • Loading branch information
blizzz committed Aug 15, 2016
commit 208e551216c955e326d41868956a46a03e8047e3
8 changes: 8 additions & 0 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,14 @@ public static function registerSettingsHooks() {
/** @var \OCP\App\ManagerEvent $event */
\OC::$server->getSettingsManager()->onAppDisabled($event->getAppID());
});
$dispatcher->addListener(OCP\App\ManagerEvent::EVENT_APP_UPDATE, function($event) {
/** @var \OCP\App\ManagerEvent $event */
$jobList = \OC::$server->getJobList();
$job = 'OC\\Settings\\RemoveOrphaned';
if(!($jobList->has($job, null))) {
$jobList->add($job);
}
});
}

private static function registerEncryptionWrapper() {
Expand Down
31 changes: 31 additions & 0 deletions lib/private/Settings/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,37 @@ public function onAppDisabled($appId) {
}
}

public function checkForOrphanedClassNames() {
$tables = [ self::TABLE_ADMIN_SECTIONS, self::TABLE_ADMIN_SETTINGS ];
foreach ($tables as $table) {
$classes = $this->getClasses($table);
foreach($classes as $className) {
try {
\OC::$server->query($className);
} catch (QueryException $e) {
$this->remove($table, $className);
}
}
}
}

/**
* returns the registerd classes in the given table
*
* @param $table
* @return string[]
*/
private function getClasses($table) {
$q = $this->dbc->getQueryBuilder();
$resultStatement = $q->select('class')
->from($table)
->execute();
$data = $resultStatement->fetchAll();
$resultStatement->closeCursor();

return array_map(function($row) { return $row['class']; }, $data);
}

/**
* @param string $sectionClassName
*/
Expand Down
91 changes: 91 additions & 0 deletions lib/private/Settings/RemoveOrphaned.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
/**
* @copyright Copyright (c) 2016 Arthur Schiwon <[email protected]>
*
* @author Arthur Schiwon <[email protected]>
*
* @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\Settings;

use OC\BackgroundJob\JobList;
use OC\BackgroundJob\TimedJob;
use OC\NeedsUpdateException;
use OCP\BackgroundJob\IJobList;
use OCP\ILogger;

/**
* Class RemoveOrphaned
*
* @package OC\Settings
*/
class RemoveOrphaned extends TimedJob {

/** @var IJobList */
private $jobList;

/** @var ILogger */
private $logger;

/** @var Manager */
private $manager;

public function __construct(Manager $manager = null) {
if($manager !== null) {
$this->manager = $manager;
} else {
// fix DI for Jobs
$this->manager = \OC::$server->getSettingsManager();
}
}

/**
* run the job, then remove it from the job list
*
* @param JobList $jobList
* @param ILogger $logger
*/
public function execute($jobList, ILogger $logger = null) {
// add an interval of 15 mins
$this->setInterval(15*60);

$this->jobList = $jobList;
$this->logger = $logger;
parent::execute($jobList, $logger);
}

/**
* @param array $argument
* @throws \Exception
* @throws \OC\NeedsUpdateException
*/
protected function run($argument) {
try {
\OC_App::loadApps();
} catch (NeedsUpdateException $ex) {
// only run when apps are up to date
return;
}

$this->manager->checkForOrphanedClassNames();

// remove the job once executed successfully
$this->jobList->remove($this);
}

}
5 changes: 5 additions & 0 deletions lib/private/legacy/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
use OC\Installer;
use OC\OCSClient;
use OC\Repair;
use OCP\App\ManagerEvent;

/**
* This class manages the apps. It allows them to register and integrate in the
Expand Down Expand Up @@ -1237,6 +1238,10 @@ public static function updateApp($appId) {
$version = \OC_App::getAppVersion($appId);
\OC::$server->getAppConfig()->setValue($appId, 'installed_version', $version);

\OC::$server->getEventDispatcher()->dispatch(ManagerEvent::EVENT_APP_UPDATE, new ManagerEvent(
ManagerEvent::EVENT_APP_UPDATE, $appId
));

return true;
}

Expand Down
5 changes: 5 additions & 0 deletions lib/public/App/ManagerEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ class ManagerEvent extends Event {
const EVENT_APP_ENABLE_FOR_GROUPS = 'OCP\App\IAppManager::enableAppForGroups';
const EVENT_APP_DISABLE = 'OCP\App\IAppManager::disableApp';

/**
* @since 9.1.0
*/
const EVENT_APP_UPDATE = 'OCP\App\IAppManager::updateApp';

/** @var string */
protected $event;
/** @var string */
Expand Down
15 changes: 15 additions & 0 deletions lib/public/Settings/IManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ public function setupSettings(array $settings);
*/
public function onAppDisabled($appId);

/**
* The method should check all registered classes whether they are still
* instantiable and remove them, if not. This method is called by a
* background job once, after one or more apps were updated.
*
* An app`s info.xml can change during an update and make it unknown whether
* a registered class name was changed or not. An old one would just stay
* registered. Another case is if an admin takes a radical approach and
* simply removes an app from the app folder. These unregular checks will
* take care of such situations.
*
* @since 9.1.0
*/
public function checkForOrphanedClassNames();

/**
* returns a list of the admin sections
*
Expand Down