X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FConsole%2FGlobalCommunitySilence.php;h=3ea6b415544b6a2f94105d5d15320d9ef43aa2c2;hb=8a46c786f37550160d81e7b7ecbcacb4c9fff493;hp=a1fba2dc79bd5da89f75514000fecbdef7018ffb;hpb=334d3921549a538130220f8b627f39f3e0877e26;p=friendica.git diff --git a/src/Core/Console/GlobalCommunitySilence.php b/src/Core/Console/GlobalCommunitySilence.php index a1fba2dc79..3ea6b41554 100644 --- a/src/Core/Console/GlobalCommunitySilence.php +++ b/src/Core/Console/GlobalCommunitySilence.php @@ -3,8 +3,9 @@ namespace Friendica\Core\Console; use Friendica\Core\Protocol; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Network\Probe; +use RuntimeException; require_once 'include/text.php'; @@ -18,8 +19,8 @@ require_once 'include/text.php'; * * License: AGPLv3 or later, same as Friendica * - * @author Tobias Diekershoff - * @author Hypolite Petovan + * @author Tobias Diekershoff + * @author Hypolite Petovan */ class GlobalCommunitySilence extends \Asika\SimpleConsole\Console { @@ -64,12 +65,8 @@ HELP; throw new \Asika\SimpleConsole\CommandArgsException('Too many arguments'); } - require_once 'config/.htconfig.php'; - $result = \dba::connect($db_host, $db_user, $db_pass, $db_data); - unset($db_host, $db_user, $db_pass, $db_data); - - if (!$result) { - throw new \RuntimeException('Unable to connect to database'); + if ($a->getMode()->isInstall()) { + throw new RuntimeException('Database isn\'t ready or populated yet'); } /** @@ -79,16 +76,16 @@ HELP; * */ $net = Probe::uri($this->getArgument(0)); if (in_array($net['network'], [Protocol::PHANTOM, Protocol::MAIL])) { - throw new \RuntimeException('This account seems not to exist.'); + throw new RuntimeException('This account seems not to exist.'); } $nurl = normalise_link($net['url']); - $contact = \dba::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]); - if (DBM::is_result($contact)) { - \dba::update("contact", ["hidden" => true], ["id" => $contact["id"]]); + $contact = DBA::selectFirst("contact", ["id"], ["nurl" => $nurl, "uid" => 0]); + if (DBA::isResult($contact)) { + DBA::update("contact", ["hidden" => true], ["id" => $contact["id"]]); $this->out('NOTICE: The account should be silenced from the global community page'); } else { - throw new \RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')'); + throw new RuntimeException('NOTICE: Could not find any entry for this URL (' . $nurl . ')'); } return 0;