installer.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. /**
  17. * Installation lib
  18. *
  19. * @package Installation
  20. * @author Adrian Lang <mail@adrianlang.de>
  21. * @author Brenda Wallace <shiny@cpan.org>
  22. * @author Brett Taylor <brett@webfroot.co.nz>
  23. * @author Brion Vibber <brion@pobox.com>
  24. * @author CiaranG <ciaran@ciarang.com>
  25. * @author Craig Andrews <candrews@integralblue.com>
  26. * @author Eric Helgeson <helfire@Erics-MBP.local>
  27. * @author Evan Prodromou <evan@status.net>
  28. * @author Mikael Nordfeldth <mmn@hethane.se>
  29. * @author Robin Millette <millette@controlyourself.ca>
  30. * @author Sarven Capadisli <csarven@status.net>
  31. * @author Tom Adams <tom@holizz.com>
  32. * @author Zach Copley <zach@status.net>
  33. * @author Diogo Cordeiro <diogo@fc.up.pt>
  34. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  35. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  36. */
  37. abstract class Installer
  38. {
  39. /** Web site info */
  40. public $sitename;
  41. public $server;
  42. public $path;
  43. public $fancy;
  44. public $siteProfile;
  45. public $ssl;
  46. /** DB info */
  47. public $host;
  48. public $database;
  49. public $dbtype;
  50. public $username;
  51. public $password;
  52. public $db;
  53. /** Storage info */
  54. public $avatarDir;
  55. public $fileDir;
  56. /** Administrator info */
  57. public $adminNick;
  58. public $adminPass;
  59. public $adminEmail;
  60. /** Should we skip writing the configuration file? */
  61. public $skipConfig = false;
  62. public static $dbModules = [
  63. 'mysql' => [
  64. 'name' => 'MariaDB 10.3+',
  65. 'check_module' => 'mysqli',
  66. 'scheme' => 'mysqli', // DSN prefix for PEAR::DB
  67. ],
  68. /*'pgsql' => [
  69. 'name' => 'PostgreSQL',
  70. 'check_module' => 'pgsql',
  71. 'scheme' => 'pgsql', // DSN prefix for PEAR::DB
  72. ]*/
  73. ];
  74. /**
  75. * Attempt to include a PHP file and report if it worked, while
  76. * suppressing the annoying warning messages on failure.
  77. * @param string $filename
  78. * @return bool
  79. */
  80. private function haveIncludeFile(string $filename): bool
  81. {
  82. $old = error_reporting(error_reporting() & ~E_WARNING);
  83. $ok = include_once($filename);
  84. error_reporting($old);
  85. return $ok;
  86. }
  87. /**
  88. * Check if all is ready for installation
  89. *
  90. * @return bool
  91. */
  92. public function checkPrereqs(): bool
  93. {
  94. $pass = true;
  95. $config = INSTALLDIR . '/config.php';
  96. if (!$this->skipConfig && file_exists($config)) {
  97. if (!is_writable($config) || filesize($config) > 0) {
  98. if (filesize($config) == 0) {
  99. $this->warning('Config file "config.php" already exists and is empty, but is not writable.');
  100. } else {
  101. $this->warning('Config file "config.php" already exists.');
  102. }
  103. $pass = false;
  104. }
  105. }
  106. if (version_compare(PHP_VERSION, '7.3.0', '<')) {
  107. $this->warning('Require PHP version 7.3.0 or greater.');
  108. $pass = false;
  109. }
  110. $reqs = ['bcmath', 'curl', 'dom', 'gd', 'intl', 'json', 'mbstring', 'openssl', 'simplexml', 'xml', 'xmlwriter'];
  111. foreach ($reqs as $req) {
  112. // Checks if a php extension is both installed and loaded
  113. if (!extension_loaded($req)) {
  114. $this->warning(sprintf('Cannot load required extension: <code>%s</code>', $req));
  115. $pass = false;
  116. }
  117. }
  118. // Make sure we have at least one database module available
  119. $missingExtensions = [];
  120. foreach (self::$dbModules as $type => $info) {
  121. if (!extension_loaded($info['check_module'])) {
  122. $missingExtensions[] = $info['check_module'];
  123. }
  124. }
  125. if (count($missingExtensions) == count(self::$dbModules)) {
  126. $req = implode(', ', $missingExtensions);
  127. $this->warning(sprintf('Cannot find a database extension. You need at least one of %s.', $req));
  128. $pass = false;
  129. }
  130. // @fixme this check seems to be insufficient with Windows ACLs
  131. if (!$this->skipConfig && !is_writable(INSTALLDIR)) {
  132. $this->warning(
  133. sprintf('Cannot write config file to: <code>%s</code></p>', INSTALLDIR),
  134. sprintf('On your server, try this command: <code>chmod a+w %s</code>', INSTALLDIR)
  135. );
  136. $pass = false;
  137. }
  138. // Check the subdirs used for file uploads
  139. // TODO get another flag for this --skipFileSubdirCreation
  140. if (!$this->skipConfig) {
  141. define('GNUSOCIAL', true);
  142. define('STATUSNET', true);
  143. require_once INSTALLDIR . '/lib/language.php';
  144. $_server = $this->server;
  145. $_path = $this->path; // We won't be using those so it's safe to do this small hack
  146. require_once INSTALLDIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'util.php';
  147. require_once INSTALLDIR . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'default.php';
  148. $fileSubdirs = [
  149. empty($this->avatarDir) ? $default['avatar']['dir'] : $this->avatarDir,
  150. empty($this->fileDir) ? $default['attachments']['dir'] : $this->fileDir
  151. ];
  152. unset($default);
  153. foreach ($fileSubdirs as $fileFullPath) {
  154. if (!file_exists($fileFullPath)) {
  155. $this->warning(
  156. sprintf('GNU social was unable to create a directory on this path: %s', $fileFullPath),
  157. 'Either create that directory with the right permissions so that GNU social can use it or '.
  158. 'set the necessary permissions and it will be created.'
  159. );
  160. $pass = $pass && mkdir($fileFullPath);
  161. } elseif (!is_dir($fileFullPath)) {
  162. $this->warning(
  163. sprintf('GNU social expected a directory but found something else on this path: %s', $fileFullPath),
  164. 'Either make sure it goes to a directory or remove it and a directory will be created.'
  165. );
  166. $pass = false;
  167. } elseif (!is_writable($fileFullPath)) {
  168. $this->warning(
  169. sprintf('Cannot write to directory: <code>%s</code>', $fileFullPath),
  170. sprintf('On your server, try this command: <code>chmod a+w %s</code>', $fileFullPath)
  171. );
  172. $pass = false;
  173. }
  174. }
  175. }
  176. return $pass;
  177. }
  178. /**
  179. * Basic validation on the database parameters
  180. * Side effects: error output if not valid
  181. *
  182. * @return bool success
  183. */
  184. public function validateDb(): bool
  185. {
  186. $fail = false;
  187. if (empty($this->host)) {
  188. $this->updateStatus("No hostname specified.", true);
  189. $fail = true;
  190. }
  191. if (empty($this->database)) {
  192. $this->updateStatus("No database specified.", true);
  193. $fail = true;
  194. }
  195. if (empty($this->username)) {
  196. $this->updateStatus("No username specified.", true);
  197. $fail = true;
  198. }
  199. if (empty($this->sitename)) {
  200. $this->updateStatus("No sitename specified.", true);
  201. $fail = true;
  202. }
  203. return !$fail;
  204. }
  205. /**
  206. * Basic validation on the administrator user parameters
  207. * Side effects: error output if not valid
  208. *
  209. * @return bool success
  210. */
  211. public function validateAdmin(): bool
  212. {
  213. $fail = false;
  214. if (empty($this->adminNick)) {
  215. $this->updateStatus("No initial user nickname specified.", true);
  216. $fail = true;
  217. }
  218. if ($this->adminNick && !preg_match('/^[0-9a-z]{1,64}$/', $this->adminNick)) {
  219. $this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
  220. '" is invalid; should be plain letters and numbers no longer than 64 characters.', true);
  221. $fail = true;
  222. }
  223. // @fixme hardcoded list; should use Nickname::isValid()
  224. // if/when it's safe to have loaded the infrastructure here
  225. $blacklist = ['main', 'panel', 'twitter', 'settings', 'rsd.xml', 'favorited', 'featured', 'favoritedrss', 'featuredrss', 'rss', 'getfile', 'api', 'groups', 'group', 'peopletag', 'tag', 'user', 'message', 'conversation', 'notice', 'attachment', 'search', 'index.php', 'doc', 'opensearch', 'robots.txt', 'xd_receiver.html', 'facebook', 'activity'];
  226. if (in_array($this->adminNick, $blacklist)) {
  227. $this->updateStatus('The user nickname "' . htmlspecialchars($this->adminNick) .
  228. '" is reserved.', true);
  229. $fail = true;
  230. }
  231. if (empty($this->adminPass)) {
  232. $this->updateStatus("No initial user password specified.", true);
  233. $fail = true;
  234. }
  235. return !$fail;
  236. }
  237. /**
  238. * Make sure a site profile was selected
  239. *
  240. * @return bool success
  241. */
  242. public function validateSiteProfile(): bool
  243. {
  244. if (empty($this->siteProfile)) {
  245. $this->updateStatus("No site profile selected.", true);
  246. return false;
  247. }
  248. return true;
  249. }
  250. /**
  251. * Set up the database with the appropriate function for the selected type...
  252. * Saves database info into $this->db.
  253. *
  254. * @fixme escape things in the connection string in case we have a funny pass etc
  255. * @return mixed array of database connection params on success, false on failure
  256. * @throws Exception
  257. */
  258. public function setupDatabase()
  259. {
  260. if ($this->db) {
  261. throw new Exception("Bad order of operations: DB already set up.");
  262. }
  263. $this->updateStatus("Starting installation...");
  264. if (empty($this->password)) {
  265. $auth = '';
  266. } else {
  267. $auth = ":$this->password";
  268. }
  269. $scheme = self::$dbModules[$this->dbtype]['scheme'];
  270. $dsn = "{$scheme}://{$this->username}{$auth}@{$this->host}/{$this->database}";
  271. $this->updateStatus("Checking database...");
  272. $conn = $this->connectDatabase($dsn);
  273. if (!$conn instanceof DB_common) {
  274. // Is not the right instance
  275. throw new Exception('Cannot connect to database: ' . $conn->getMessage());
  276. }
  277. // ensure database encoding is UTF8
  278. $conn->query('SET NAMES utf8mb4');
  279. if ($this->dbtype == 'mysql') {
  280. $server_encoding = $conn->getRow("SHOW VARIABLES LIKE 'character_set_server'")[1];
  281. if ($server_encoding != 'utf8mb4') {
  282. $this->updateStatus("GNU social requires UTF8 character encoding. Your database is " . htmlentities($server_encoding));
  283. return false;
  284. }
  285. } elseif ($this->dbtype == 'pgsql') {
  286. $server_encoding = $conn->getRow('SHOW server_encoding')[0];
  287. if ($server_encoding != 'UTF8') {
  288. $this->updateStatus("GNU social requires UTF8 character encoding. Your database is " . htmlentities($server_encoding));
  289. return false;
  290. }
  291. }
  292. $res = $this->updateStatus("Creating database tables...");
  293. if (!$this->createCoreTables($conn)) {
  294. $this->updateStatus("Error creating tables.", true);
  295. return false;
  296. }
  297. foreach (['sms_carrier' => 'SMS carrier',
  298. 'notice_source' => 'notice source',
  299. 'foreign_services' => 'foreign service']
  300. as $scr => $name) {
  301. $this->updateStatus(sprintf("Adding %s data to database...", $name));
  302. $res = $this->runDbScript($scr . '.sql', $conn);
  303. if ($res === false) {
  304. $this->updateStatus(sprintf("Can't run %s script.", $name), true);
  305. return false;
  306. }
  307. }
  308. $db = ['type' => $this->dbtype, 'database' => $dsn];
  309. return $db;
  310. }
  311. /**
  312. * Open a connection to the database.
  313. *
  314. * @param string $dsn
  315. * @return DB|DB_Error
  316. */
  317. public function connectDatabase(string $dsn)
  318. {
  319. global $_DB;
  320. return $_DB->connect($dsn);
  321. }
  322. /**
  323. * Create core tables on the given database connection.
  324. *
  325. * @param DB_common $conn
  326. * @return bool
  327. */
  328. public function createCoreTables(DB_common $conn): bool
  329. {
  330. $schema = Schema::get($conn);
  331. $tableDefs = $this->getCoreSchema();
  332. foreach ($tableDefs as $name => $def) {
  333. if (defined('DEBUG_INSTALLER')) {
  334. echo " $name ";
  335. }
  336. $schema->ensureTable($name, $def);
  337. }
  338. return true;
  339. }
  340. /**
  341. * Fetch the core table schema definitions.
  342. *
  343. * @return array of table names => table def arrays
  344. */
  345. public function getCoreSchema(): array
  346. {
  347. $schema = [];
  348. include INSTALLDIR . '/db/core.php';
  349. return $schema;
  350. }
  351. /**
  352. * Return a parseable PHP literal for the given value.
  353. * This will include quotes for strings, etc.
  354. *
  355. * @param mixed $val
  356. * @return string
  357. */
  358. public function phpVal($val): string
  359. {
  360. return var_export($val, true);
  361. }
  362. /**
  363. * Return an array of parseable PHP literal for the given values.
  364. * These will include quotes for strings, etc.
  365. *
  366. * @param mixed $map
  367. * @return array
  368. */
  369. public function phpVals($map): array
  370. {
  371. return array_map([$this, 'phpVal'], $map);
  372. }
  373. /**
  374. * Write a stock configuration file.
  375. *
  376. * @return bool success
  377. *
  378. * @fixme escape variables in output in case we have funny chars, apostrophes etc
  379. */
  380. public function writeConf(): bool
  381. {
  382. $vals = $this->phpVals([
  383. 'sitename' => $this->sitename,
  384. 'server' => $this->server,
  385. 'path' => $this->path,
  386. 'ssl' => in_array($this->ssl, ['never', 'always'])
  387. ? $this->ssl
  388. : 'never',
  389. 'db_database' => $this->db['database'],
  390. 'db_type' => $this->db['type']
  391. ]);
  392. // assemble configuration file in a string
  393. $cfg = "<?php\n" .
  394. "if (!defined('GNUSOCIAL')) { exit(1); }\n\n" .
  395. // site name
  396. "\$config['site']['name'] = {$vals['sitename']};\n\n" .
  397. // site location
  398. "\$config['site']['server'] = {$vals['server']};\n" .
  399. "\$config['site']['path'] = {$vals['path']}; \n\n" .
  400. "\$config['site']['ssl'] = {$vals['ssl']}; \n\n" .
  401. // checks if fancy URLs are enabled
  402. ($this->fancy ? "\$config['site']['fancy'] = true;\n\n" : '') .
  403. // database
  404. "\$config['db']['database'] = {$vals['db_database']};\n\n" .
  405. ($this->db['type'] == 'pgsql' ? "\$config['db']['quote_identifiers'] = true;\n\n" : '') .
  406. "\$config['db']['type'] = {$vals['db_type']};\n\n" .
  407. "// Uncomment below for better performance. Just remember you must run\n" .
  408. "// php scripts/checkschema.php whenever your enabled plugins change!\n" .
  409. "//\$config['db']['schemacheck'] = 'script';\n\n";
  410. // Normalize line endings for Windows servers
  411. $cfg = str_replace("\n", PHP_EOL, $cfg);
  412. // write configuration file out to install directory
  413. $res = file_put_contents(INSTALLDIR . '/config.php', $cfg);
  414. return $res;
  415. }
  416. /**
  417. * Write the site profile. We do this after creating the initial user
  418. * in case the site profile is set to single user. This gets around the
  419. * 'chicken-and-egg' problem of the system requiring a valid user for
  420. * single user mode, before the intial user is actually created. Yeah,
  421. * we should probably do this in smarter way.
  422. *
  423. * @return int res number of bytes written
  424. */
  425. public function writeSiteProfile(): int
  426. {
  427. $vals = $this->phpVals([
  428. 'site_profile' => $this->siteProfile,
  429. 'nickname' => $this->adminNick
  430. ]);
  431. $cfg =
  432. // site profile
  433. "\$config['site']['profile'] = {$vals['site_profile']};\n";
  434. if ($this->siteProfile == "singleuser") {
  435. $cfg .= "\$config['singleuser']['nickname'] = {$vals['nickname']};\n\n";
  436. } else {
  437. $cfg .= "\n";
  438. }
  439. // Normalize line endings for Windows servers
  440. $cfg = str_replace("\n", PHP_EOL, $cfg);
  441. // write configuration file out to install directory
  442. $res = file_put_contents(INSTALLDIR . '/config.php', $cfg, FILE_APPEND);
  443. return $res;
  444. }
  445. /**
  446. * Install schema into the database
  447. *
  448. * @param string $filename location of database schema file
  449. * @param DB_common $conn connection to database
  450. *
  451. * @return bool - indicating success or failure
  452. */
  453. public function runDbScript(string $filename, DB_common $conn): bool
  454. {
  455. $sql = trim(file_get_contents(INSTALLDIR . '/db/' . $filename));
  456. $stmts = explode(';', $sql);
  457. foreach ($stmts as $stmt) {
  458. $stmt = trim($stmt);
  459. if (!mb_strlen($stmt)) {
  460. continue;
  461. }
  462. try {
  463. $res = $conn->query($stmt);
  464. } catch (Exception $e) {
  465. $error = $e->getMessage();
  466. $this->updateStatus("ERROR ($error) for SQL '$stmt'");
  467. return false;
  468. }
  469. }
  470. return true;
  471. }
  472. /**
  473. * Create the initial admin user account.
  474. * Side effect: may load portions of GNU social framework.
  475. * Side effect: outputs program info
  476. */
  477. public function registerInitialUser(): bool
  478. {
  479. // initalize hostname from install arguments, so it can be used to find
  480. // the /etc config file from the commandline installer
  481. $server = $this->server;
  482. require_once INSTALLDIR . '/lib/common.php';
  483. $data = ['nickname' => $this->adminNick,
  484. 'password' => $this->adminPass,
  485. 'fullname' => $this->adminNick];
  486. if ($this->adminEmail) {
  487. $data['email'] = $this->adminEmail;
  488. }
  489. try {
  490. $user = User::register($data, true); // true to skip email sending verification
  491. } catch (Exception $e) {
  492. return false;
  493. }
  494. // give initial user carte blanche
  495. $user->grantRole('owner');
  496. $user->grantRole('moderator');
  497. $user->grantRole('administrator');
  498. return true;
  499. }
  500. /**
  501. * The beef of the installer!
  502. * Create database, config file, and admin user.
  503. *
  504. * Prerequisites: validation of input data.
  505. *
  506. * @return bool success
  507. */
  508. public function doInstall(): bool
  509. {
  510. global $config;
  511. $this->updateStatus("Initializing...");
  512. ini_set('display_errors', 1);
  513. error_reporting(E_ALL & ~E_STRICT & ~E_NOTICE);
  514. if (!defined('GNUSOCIAL')) {
  515. define('GNUSOCIAL', true);
  516. }
  517. if (!defined('STATUSNET')) {
  518. define('STATUSNET', true);
  519. }
  520. require_once INSTALLDIR . '/lib/framework.php';
  521. GNUsocial::initDefaults($this->server, $this->path);
  522. if ($this->siteProfile == "singleuser") {
  523. // Until we use ['site']['profile']==='singleuser' everywhere
  524. $config['singleuser']['enabled'] = true;
  525. }
  526. try {
  527. $this->db = $this->setupDatabase();
  528. if (!$this->db) {
  529. // database connection failed, do not move on to create config file.
  530. return false;
  531. }
  532. } catch (Exception $e) {
  533. // Lower-level DB error!
  534. $this->updateStatus("Database error: " . $e->getMessage(), true);
  535. return false;
  536. }
  537. if (!$this->skipConfig) {
  538. // Make sure we can write to the file twice
  539. $oldUmask = umask(000);
  540. $this->updateStatus("Writing config file...");
  541. $res = $this->writeConf();
  542. if (!$res) {
  543. $this->updateStatus("Can't write config file.", true);
  544. return false;
  545. }
  546. }
  547. if (!empty($this->adminNick)) {
  548. // Okay, cross fingers and try to register an initial user
  549. if ($this->registerInitialUser()) {
  550. $this->updateStatus(
  551. "An initial user with the administrator role has been created."
  552. );
  553. } else {
  554. $this->updateStatus(
  555. "Could not create initial user account.",
  556. true
  557. );
  558. return false;
  559. }
  560. }
  561. if (!$this->skipConfig) {
  562. $this->updateStatus("Setting site profile...");
  563. $res = $this->writeSiteProfile();
  564. if (!$res) {
  565. $this->updateStatus("Can't write to config file.", true);
  566. return false;
  567. }
  568. // Restore original umask
  569. umask($oldUmask);
  570. // Set permissions back to something decent
  571. chmod(INSTALLDIR . '/config.php', 0644);
  572. }
  573. $scheme = $this->ssl === 'always' ? 'https' : 'http';
  574. $link = "{$scheme}://{$this->server}/{$this->path}";
  575. $this->updateStatus("GNU social has been installed at $link");
  576. $this->updateStatus(
  577. '<strong>DONE!</strong> You can visit your <a href="' . htmlspecialchars($link) . '">new GNU social site</a> (log in as "' . htmlspecialchars($this->adminNick) . '"). If this is your first GNU social install, make your experience the best possible by visiting our resource site to join the <a href="https://gnu.io/social/resources/">mailing list or IRC</a>. <a href="' . htmlspecialchars($link) . '/doc/faq">FAQ is found here</a>.'
  578. );
  579. return true;
  580. }
  581. /**
  582. * Output a pre-install-time warning message
  583. * @param string $message HTML ok, but should be plaintext-able
  584. * @param string $submessage HTML ok, but should be plaintext-able
  585. */
  586. abstract public function warning(string $message, string $submessage = '');
  587. /**
  588. * Output an install-time progress message
  589. * @param string $status HTML ok, but should be plaintext-able
  590. * @param bool $error true if this should be marked as an error condition
  591. */
  592. abstract public function updateStatus(string $status, bool $error = false);
  593. }