Repository navigation
NC20: Music app Ampache API broken because URL parameter 'action' can't be used聽#23544
Description
Activity
- added0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
on Oct 17, 2020 - changed the title
[-]NC20: Application can't use URL parameter 'action'[/-][+]NC20: Music app Ampache API broken because URL parameter 'action' can't be used[/+]on Oct 26, 2020 If I knew how to fix this I would 馃檨
Pls fix <3So does anyone have any idea, why is the URL argument
actionspecial for Nextcloud 20? And what has changed on this regard between NC19 and NC20?I'm almost certain that this bug has been introduced as a side effect of the commit edc1c77. Before the commit, the execution went through this branch:
server/lib/private/Route/Router.php
Lines 291 to 297 in cd7a627
if (isset($parameters['action'])) { $action = $parameters['action']; if (!is_callable($action)) { throw new \Exception('not a callable action'); } unset($parameters['action']); call_user_func($action, $parameters);
...where the key'action'is removed from the$parametersreturned by theUrlMatcher.After the commit, this branch is executed instead:
server/lib/private/Route/Router.php
Lines 297 to 301 in f7fa292
if (isset($parameters['caller'])) { $caller = $parameters['caller']; unset($parameters['caller']); $application = $this->getApplicationClass($caller[0]); \OC\AppFramework\App::main($caller[1], $caller[2], $application->getContainer(), $parameters); Here, the
$parameterscontains the key'action'withnullvalue, and it is passed straight through toApp::mainwhich passes it to theRequestobject. Then, thearray_mergehere overwrites any URL arguments or POST parameters named'action'with the null-valued key:
server/lib/private/AppFramework/Http/Request.php
Lines 169 to 175 in cd7a627
public function setUrlParameters(array $parameters) { $this->items['urlParams'] = $parameters; $this->items['parameters'] = array_merge( $this->items['parameters'], $this->items['urlParams'] ); } What do you think, @rullzer?
To add to my previous comment, it seems that the bug can be fixed by adding the call
unset($parameters['action']);near the line
server/lib/private/Route/Router.php
Line 299 in f7fa292
unset($parameters['caller']);
But as I lack the knowledge of the big picture of the Nextcloud routing, I'm not certain if this is the best way to fix this, or if this could have some side effects on some case. But so far I have noticed nothing wrong when I made this experimental one line fix on my installation.Hi Devs,
I would like to upvote this issue too.
Unfortunately it breaks Power Ampache app.Thanks.
Reacted by sunjamHi Devs,
It works with Nextcloud 20.0.5.
Thanks!
- added a commit that references this issue
on Jul 21, 2025
How to use GitHub
Steps to reproduce
action=somecontent, e.g.https://domain.org/nextcloud/index.php/apps/someapp/api/somemethod?action=somecontentactionin the controller class either through function argument injectionpublic function someMethod($action)or by calling$this->request->getParam('action')or$this->request->getParams()['action']or$this->request['action'].Expected behaviour
The controller should be able to obtain the value
somecontentof the URL argumentaction.Actual behaviour
The value of the argument
actionis empty, no matter which method you use to obtain it. Arguments with any other name work as expected, but the nameactionis somehow special. Also, if you call an API endpoint without supplying the command line argumentaction, the array returned by$this->request->getParams()still contains the keyactionwith an empty content.This oddity prevents using the Ampache API of the Music app on Nextcloud 20, as reported in nc-music/oc-music#791. This issue is new in NC20, there has never been such problem on the NC versions 12 - 19.
(Side note: The Music app version 0.17.0 with support for NC20 has just been released.)
Server configuration
Operating system: Raspbian Linux 4.9.35-v7+ armv7l
Web server: nginx/1.6.2
Database: sqlite3 3.8.7.1
PHP version: 7.4
Nextcloud version: Nextcloud 20.0.0 RC2
Updated from an older Nextcloud/ownCloud or fresh install: fresh
Where did you install Nextcloud from: https://nextcloud.com/install/
Signing status:
Signing status
List of activated apps:
App list
Nextcloud configuration:
Config report
Are you using external storage, if yes which one: no
Are you using encryption: no
Are you using an external user-backend, if yes which one: no
Client configuration
Browser: N/A
Operating system: N/A