Merge pull request #10178 from nupplaphil/fix/10174

Fixed new "user config" console feature
This commit is contained in:
Tobias Diekershoff 2021-04-29 06:54:02 +02:00 committed by GitHub
commit d28fbf9d8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View file

@ -52,6 +52,10 @@ class User extends \Asika\SimpleConsole\Console
* @var Database * @var Database
*/ */
private $dba; private $dba;
/**
* @var IPConfig
*/
private $pConfig;
protected function getHelp() protected function getHelp()
{ {
@ -89,13 +93,14 @@ HELP;
return $help; return $help;
} }
public function __construct(App\Mode $appMode, L10n $l10n, Database $dba, array $argv = null) public function __construct(App\Mode $appMode, L10n $l10n, Database $dba, IPConfig $pConfig, array $argv = null)
{ {
parent::__construct($argv); parent::__construct($argv);
$this->appMode = $appMode; $this->appMode = $appMode;
$this->l10n = $l10n; $this->l10n = $l10n;
$this->dba = $dba; $this->dba = $dba;
$this->pConfig = $pConfig;
} }
protected function doExecute() protected function doExecute()
@ -338,8 +343,8 @@ HELP;
private function listUser() private function listUser()
{ {
$subCmd = $this->getArgument(1); $subCmd = $this->getArgument(1);
$start = $this->getOption(['s', 'start'], 0); $start = $this->getOption(['s', 'start'], 0);
$count = $this->getOption(['c', 'count'], Pager::ITEMS_PER_PAGE); $count = $this->getOption(['c', 'count'], Pager::ITEMS_PER_PAGE);
$table = new Console_Table(); $table = new Console_Table();
@ -403,7 +408,7 @@ HELP;
]; ];
$subCmd = $this->getArgument(1); $subCmd = $this->getArgument(1);
$param = $this->getArgument(2); $param = $this->getArgument(2);
$table = new Console_Table(); $table = new Console_Table();
$table->setHeaders(['UID', 'GUID', 'Name', 'Nick', 'E-Mail', 'Register', 'Login', 'Verified', 'Blocked']); $table->setHeaders(['UID', 'GUID', 'Name', 'Nick', 'E-Mail', 'Register', 'Login', 'Verified', 'Blocked']);
@ -463,8 +468,7 @@ HELP;
} }
} }
$pconfig = \Friendica\DI::pConfig(); $values = $this->pConfig->load($user['uid'], $category);
$values = $pconfig->load($user['uid'], $category);
switch ($subCmd) { switch ($subCmd) {
case 'list': case 'list':
@ -499,8 +503,8 @@ HELP;
} }
if (array_key_exists($category, $values) and if (array_key_exists($category, $values) and
array_key_exists($key, $values[$category]) and array_key_exists($key, $values[$category]) and
$values[$category][$key] == $value) { $values[$category][$key] == $value) {
throw new RuntimeException('Value not changed'); throw new RuntimeException('Value not changed');
} }

View file

@ -35,7 +35,7 @@ interface IPConfig
* @param int $uid The user_id * @param int $uid The user_id
* @param string $cat The category of the configuration value * @param string $cat The category of the configuration value
* *
* @return void * @return array The loaded config array
* @see Cache * @see Cache
* *
*/ */

View file

@ -68,6 +68,8 @@ class PreloadPConfig extends BasePConfig
// load the whole category out of the DB into the cache // load the whole category out of the DB into the cache
$this->configCache->load($uid, $config); $this->configCache->load($uid, $config);
return $config;
} }
/** /**