aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/psalm-github.yml26
m---------3rdparty0
-rw-r--r--lib/private/AppFramework/Bootstrap/RegistrationContext.php5
-rw-r--r--lib/private/Authentication/Token/PublicKeyTokenProvider.php5
-rw-r--r--lib/private/legacy/OC_App.php10
-rw-r--r--lib/public/EventDispatcher/Event.php37
-rw-r--r--lib/public/EventDispatcher/GenericEvent.php17
-rw-r--r--tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php18
8 files changed, 85 insertions, 33 deletions
diff --git a/.github/workflows/psalm-github.yml b/.github/workflows/psalm-github.yml
new file mode 100644
index 00000000000..ef35c39cd67
--- /dev/null
+++ b/.github/workflows/psalm-github.yml
@@ -0,0 +1,26 @@
+name: Psalm show github
+
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '0 0 * * 0'
+
+jobs:
+ psalm:
+ name: Psalm
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v2
+ with:
+ submodules: recursive
+ - name: Psalm
+ uses: docker://vimeo/psalm-github-actions
+ continue-on-error: true
+ with:
+ report_file: results.sarif
+ - name: Upload Analysis results to GitHub
+ uses: github/codeql-action/upload-sarif@v1
+ with:
+ sarif_file: results.sarif
diff --git a/3rdparty b/3rdparty
-Subproject 90a8336c3b51a3be5869569ef8e84949a1e6760
+Subproject 4466d782fafe2b53f3839156d10be0d3eacb47d
diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
index 619e4f55011..fc13a78f3d3 100644
--- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php
+++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php
@@ -271,10 +271,7 @@ class RegistrationContext {
}
public function registerTemplateProvider(string $appId, string $class): void {
- $this->templateProviders[] = [
- 'appId' => $appId,
- 'class' => $class,
- ];
+ $this->templateProviders[] = new ServiceRegistration($appId, $class);
}
/**
diff --git a/lib/private/Authentication/Token/PublicKeyTokenProvider.php b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
index 38551e63b87..a293d2a8404 100644
--- a/lib/private/Authentication/Token/PublicKeyTokenProvider.php
+++ b/lib/private/Authentication/Token/PublicKeyTokenProvider.php
@@ -414,11 +414,6 @@ class PublicKeyTokenProvider implements IProvider {
public function updatePasswords(string $uid, string $password) {
$this->cache->clear();
- if (!$this->mapper->hasExpiredTokens($uid)) {
- // Nothing to do here
- return;
- }
-
// Update the password for all tokens
$tokens = $this->mapper->getTokenByUser($uid);
foreach ($tokens as $t) {
diff --git a/lib/private/legacy/OC_App.php b/lib/private/legacy/OC_App.php
index 530291002bb..d48d6c40810 100644
--- a/lib/private/legacy/OC_App.php
+++ b/lib/private/legacy/OC_App.php
@@ -709,12 +709,12 @@ class OC_App {
try {
/** @var IAlternativeLogin $provider */
- $provider = \OC::$server->query($registration['class']);
+ $provider = \OC::$server->query($registration->getService());
} catch (QueryException $e) {
\OC::$server->getLogger()->logException($e, [
'message' => 'Alternative login option {option} can not be initialised.',
- 'option' => $registration['class'],
- 'app' => $registration['app'],
+ 'option' => $registration->getService(),
+ 'app' => $registration->getAppId(),
]);
}
@@ -729,8 +729,8 @@ class OC_App {
} catch (Throwable $e) {
\OC::$server->getLogger()->logException($e, [
'message' => 'Alternative login option {option} had an error while loading.',
- 'option' => $registration['class'],
- 'app' => $registration['app'],
+ 'option' => $registration->getService(),
+ 'app' => $registration->getAppId(),
]);
}
}
diff --git a/lib/public/EventDispatcher/Event.php b/lib/public/EventDispatcher/Event.php
index 8e6a5217af9..b07efba0f19 100644
--- a/lib/public/EventDispatcher/Event.php
+++ b/lib/public/EventDispatcher/Event.php
@@ -26,7 +26,7 @@ declare(strict_types=1);
namespace OCP\EventDispatcher;
-use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;
+use Psr\EventDispatcher\StoppableEventInterface;
/**
* Base event class for the event dispatcher service
@@ -34,9 +34,21 @@ use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent;
* Typically this class isn't instantiated directly but sub classed for specific
* event types
*
+ * This class extended \Symfony\Contracts\EventDispatcher\Event until 21.0, since
+ * 22.0.0 this class directly implements the PSR StoppableEventInterface and no
+ * longer relies on Symfony. This transition does not come with any changes in API,
+ * the class has the same methods and behavior before and after this change.
+ *
* @since 17.0.0
*/
-class Event extends SymfonyEvent {
+class Event implements StoppableEventInterface {
+
+ /**
+ * @var bool
+ *
+ * @since 22.0.0
+ */
+ private $propagationStopped = false;
/**
* Compatibility constructor
@@ -51,4 +63,25 @@ class Event extends SymfonyEvent {
*/
public function __construct() {
}
+
+ /**
+ * Stops the propagation of the event to further event listeners
+ *
+ * @return void
+ *
+ * @since 22.0.0
+ */
+ public function stopPropagation(): void {
+ $this->propagationStopped = true;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @since 22.0.0
+ * @see \Psr\EventDispatcher\StoppableEventInterface
+ */
+ public function isPropagationStopped(): bool {
+ return $this->propagationStopped;
+ }
}
diff --git a/lib/public/EventDispatcher/GenericEvent.php b/lib/public/EventDispatcher/GenericEvent.php
index ab2ff734ada..eda7fdf0997 100644
--- a/lib/public/EventDispatcher/GenericEvent.php
+++ b/lib/public/EventDispatcher/GenericEvent.php
@@ -40,17 +40,23 @@ use function array_key_exists;
* \OCP\EventDispatcher\Event
*
* @since 18.0.0
+ * @deprecated 22.0.0 use \OCP\EventDispatcher\Event
*/
class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
+ /** @deprecated 22.0.0 */
protected $subject;
+
+ /** @deprecated 22.0.0 */
protected $arguments;
/**
* Encapsulate an event with $subject and $args.
*
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function __construct($subject = null, array $arguments = []) {
+ parent::__construct();
$this->subject = $subject;
$this->arguments = $arguments;
}
@@ -59,6 +65,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
* Getter for subject property.
*
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function getSubject() {
return $this->subject;
@@ -69,6 +76,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
*
* @throws InvalidArgumentException if key is not found
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function getArgument(string $key) {
if ($this->hasArgument($key)) {
@@ -82,6 +90,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
* Add argument to event.
*
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function setArgument($key, $value): GenericEvent {
$this->arguments[$key] = $value;
@@ -92,6 +101,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
* Getter for all arguments.
*
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function getArguments(): array {
return $this->arguments;
@@ -101,6 +111,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
* Set args property.
*
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function setArguments(array $args = []): GenericEvent {
$this->arguments = $args;
@@ -111,6 +122,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
* Has argument.
*
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function hasArgument($key): bool {
return array_key_exists($key, $this->arguments);
@@ -121,6 +133,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
*
* @link https://php.net/manual/en/iteratoraggregate.getiterator.php
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function getIterator(): Traversable {
return new ArrayIterator($this->arguments);
@@ -131,6 +144,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
*
* @link https://php.net/manual/en/arrayaccess.offsetexists.php
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function offsetExists($offset): bool {
return $this->hasArgument($offset);
@@ -141,6 +155,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
*
* @link https://php.net/manual/en/arrayaccess.offsetget.php
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function offsetGet($offset) {
return $this->arguments[$offset];
@@ -151,6 +166,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
*
* @link https://php.net/manual/en/arrayaccess.offsetset.php
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function offsetSet($offset, $value): void {
$this->setArgument($offset, $value);
@@ -161,6 +177,7 @@ class GenericEvent extends Event implements ArrayAccess, IteratorAggregate {
*
* @link https://php.net/manual/en/arrayaccess.offsetunset.php
* @since 18.0.0
+ * @deprecated 22.0.0
*/
public function offsetUnset($offset): void {
if ($this->hasArgument($offset)) {
diff --git a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
index 04e0fdb527e..f27100b5d78 100644
--- a/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
+++ b/tests/lib/Authentication/Token/PublicKeyTokenProviderTest.php
@@ -548,8 +548,7 @@ class PublicKeyTokenProviderTest extends TestCase {
IToken::PERMANENT_TOKEN,
IToken::REMEMBER);
- $this->mapper->expects($this->once())
- ->method('hasExpiredTokens')
+ $this->mapper->method('hasExpiredTokens')
->with($uid)
->willReturn(true);
$this->mapper->expects($this->once())
@@ -564,19 +563,4 @@ class PublicKeyTokenProviderTest extends TestCase {
$this->tokenProvider->updatePasswords($uid, 'bar2');
}
-
- public function testUpdatePasswordsNotRequired() {
- $uid = 'myUID';
-
- $this->mapper->expects($this->once())
- ->method('hasExpiredTokens')
- ->with($uid)
- ->willReturn(false);
- $this->mapper->expects($this->never())
- ->method('getTokenByUser');
- $this->mapper->expects($this->never())
- ->method('update');
-
- $this->tokenProvider->updatePasswords($uid, 'bar2');
- }
}