11<?php
2+ declare (strict_types=1 );
23/**
34 * @author Thomas Müller <thomas.mueller@tmit.eu>
45 *
1920 *
2021 */
2122
22- namespace OCA \DAV \Repair ;
23+ namespace OCA \DAV \Command ;
2324
2425use OCA \DAV \Connector \Sabre \Principal ;
2526use OCP \IDBConnection ;
26- use OCP \ ILogger ;
27- use OCP \ Migration \ IOutput ;
28- use OCP \ Migration \ IRepairStep ;
27+ use Symfony \ Component \ Console \ Command \ Command ;
28+ use Symfony \ Component \ Console \ Input \ InputInterface ;
29+ use Symfony \ Component \ Console \ Output \ OutputInterface ;
2930
3031/**
3132 * Class RemoveInvalidShares - removes shared calendars and addressbook which
3233 * have no matching principal. Happened because of a bug in the calendar app.
33- *
34- * @package OCA\DAV\Repair
3534 */
36- class RemoveInvalidShares implements IRepairStep {
35+ class RemoveInvalidShares extends Command {
3736
3837 /** @var IDBConnection */
3938 private $ connection ;
4039 /** @var Principal */
4140 private $ principalBackend ;
4241
43- /**
44- * RemoveInvalidShares constructor.
45- *
46- * @param IDBConnection $connection
47- * @param Principal $principalBackend
48- */
4942 public function __construct (IDBConnection $ connection ,
5043 Principal $ principalBackend ) {
44+ parent ::__construct ();
45+
5146 $ this ->connection = $ connection ;
5247 $ this ->principalBackend = $ principalBackend ;
5348 }
5449
55- /**
56- * Returns the step's name
57- *
58- * @return string
59- * @since 9.1.0
60- */
61- public function getName () {
62- return 'Remove invalid calendar and addressbook shares ' ;
50+ protected function configure () {
51+ $ this
52+ ->setName ('dav:remove-invalid-shares ' )
53+ ->setDescription ('Remove invalid dav shares ' );
6354 }
6455
65- /**
66- * Run repair step.
67- * Must throw exception on error.
68- *
69- * @param IOutput $output
70- * @throws \Exception in case of failure
71- * @since 9.1.0
72- */
73- public function run (IOutput $ output ) {
56+ protected function execute (InputInterface $ input , OutputInterface $ output ) {
7457 $ query = $ this ->connection ->getQueryBuilder ();
7558 $ result = $ query ->selectDistinct ('principaluri ' )
7659 ->from ('dav_shares ' )
@@ -80,7 +63,6 @@ public function run(IOutput $output) {
8063 $ principaluri = $ row ['principaluri ' ];
8164 $ p = $ this ->principalBackend ->getPrincipalByPath ($ principaluri );
8265 if ($ p === null ) {
83- $ output ->info (" ... for principal ' $ principaluri' " );
8466 $ this ->deleteSharesForPrincipal ($ principaluri );
8567 }
8668 }
0 commit comments