@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * |
251 | 251 | * Defaults to ``60*60*24*15`` seconds (15 days) |
252 | 252 | */ |
253 | -'remember_login_cookie_lifetime' => 60*60*24*15, |
|
253 | +'remember_login_cookie_lifetime' => 60 * 60 * 24 * 15, |
|
254 | 254 | |
255 | 255 | /** |
256 | 256 | * The lifetime of a session after inactivity. |
@@ -1427,7 +1427,7 @@ discard block |
||
1427 | 1427 | * https://github.com/phpredis/phpredis/commit/c5994f2a42b8a348af92d3acb4edff1328ad8ce1 |
1428 | 1428 | */ |
1429 | 1429 | 'redis.cluster' => [ |
1430 | - 'seeds' => [ // provide some or all of the cluster servers to bootstrap discovery, port required |
|
1430 | + 'seeds' => [// provide some or all of the cluster servers to bootstrap discovery, port required |
|
1431 | 1431 | 'localhost:7000', |
1432 | 1432 | 'localhost:7001', |
1433 | 1433 | ], |
@@ -1501,7 +1501,7 @@ discard block |
||
1501 | 1501 | * |
1502 | 1502 | * Defaults to ``60*60*24`` (1 day) |
1503 | 1503 | */ |
1504 | -'cache_chunk_gc_ttl' => 60*60*24, |
|
1504 | +'cache_chunk_gc_ttl' => 60 * 60 * 24, |
|
1505 | 1505 | |
1506 | 1506 | /** |
1507 | 1507 | * Using Object Store with Nextcloud |
@@ -2093,7 +2093,7 @@ discard block |
||
2093 | 2093 | * Defaults to ``60*60`` seconds (1 hour) or the php |
2094 | 2094 | * max_execution_time, whichever is higher. |
2095 | 2095 | */ |
2096 | -'filelocking.ttl' => 60*60, |
|
2096 | +'filelocking.ttl' => 60 * 60, |
|
2097 | 2097 | |
2098 | 2098 | /** |
2099 | 2099 | * Memory caching backend for file locking |
@@ -47,17 +47,17 @@ discard block |
||
47 | 47 | */ |
48 | 48 | 'instanceid' => '', |
49 | 49 | |
50 | - /** |
|
51 | - * The salt used to hash all passwords, auto-generated by the Nextcloud |
|
52 | - * installer. (There are also per-user salts.) If you lose this salt you lose |
|
53 | - * all your passwords. This example is for documentation only, and you should |
|
54 | - * never use it. |
|
55 | - * |
|
56 | - * @deprecated This salt is deprecated and only used for legacy-compatibility, |
|
57 | - * developers should *NOT* use this value for anything nowadays. |
|
58 | - * |
|
59 | - * 'passwordsalt' => 'd3c944a9af095aa08f', |
|
60 | - */ |
|
50 | + /** |
|
51 | + * The salt used to hash all passwords, auto-generated by the Nextcloud |
|
52 | + * installer. (There are also per-user salts.) If you lose this salt you lose |
|
53 | + * all your passwords. This example is for documentation only, and you should |
|
54 | + * never use it. |
|
55 | + * |
|
56 | + * @deprecated This salt is deprecated and only used for legacy-compatibility, |
|
57 | + * developers should *NOT* use this value for anything nowadays. |
|
58 | + * |
|
59 | + * 'passwordsalt' => 'd3c944a9af095aa08f', |
|
60 | + */ |
|
61 | 61 | 'passwordsalt' => '', |
62 | 62 | |
63 | 63 | /** |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | * Using TLS certificates where commonName=<IP address> is deprecated |
82 | 82 | */ |
83 | 83 | 'trusted_domains' => |
84 | - [ |
|
84 | + [ |
|
85 | 85 | 'demo.example.org', |
86 | 86 | 'otherdomain.example.org', |
87 | 87 | '10.111.112.113', |
88 | 88 | '[2001:db8::1]' |
89 | - ], |
|
89 | + ], |
|
90 | 90 | |
91 | 91 | |
92 | 92 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * Specify read only replicas to be used by Nextcloud when querying the database |
162 | 162 | */ |
163 | 163 | 'dbreplica' => [ |
164 | - ['user' => 'nextcloud', 'password' => 'password1', 'host' => 'replica1', 'dbname' => ''], |
|
165 | - ['user' => 'nextcloud', 'password' => 'password2', 'host' => 'replica2', 'dbname' => ''], |
|
164 | + ['user' => 'nextcloud', 'password' => 'password1', 'host' => 'replica1', 'dbname' => ''], |
|
165 | + ['user' => 'nextcloud', 'password' => 'password2', 'host' => 'replica2', 'dbname' => ''], |
|
166 | 166 | ], |
167 | 167 | |
168 | 168 | /** |
@@ -941,10 +941,10 @@ discard block |
||
941 | 941 | * - https://www.edri.org |
942 | 942 | */ |
943 | 943 | 'connectivity_check_domains' => [ |
944 | - 'https://www.nextcloud.com', |
|
945 | - 'https://www.startpage.com', |
|
946 | - 'https://www.eff.org', |
|
947 | - 'https://www.edri.org' |
|
944 | + 'https://www.nextcloud.com', |
|
945 | + 'https://www.startpage.com', |
|
946 | + 'https://www.eff.org', |
|
947 | + 'https://www.edri.org' |
|
948 | 948 | ], |
949 | 949 | |
950 | 950 | /** |
@@ -1106,18 +1106,18 @@ discard block |
||
1106 | 1106 | * Defaults to an empty array. |
1107 | 1107 | */ |
1108 | 1108 | 'log.condition' => [ |
1109 | - 'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9', |
|
1110 | - 'users' => ['sample-user'], |
|
1111 | - 'apps' => ['files'], |
|
1112 | - 'matches' => [ |
|
1113 | - [ |
|
1114 | - 'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9', |
|
1115 | - 'users' => ['sample-user'], |
|
1116 | - 'apps' => ['files'], |
|
1117 | - 'loglevel' => 1, |
|
1118 | - 'message' => 'contains substring' |
|
1119 | - ], |
|
1120 | - ], |
|
1109 | + 'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9', |
|
1110 | + 'users' => ['sample-user'], |
|
1111 | + 'apps' => ['files'], |
|
1112 | + 'matches' => [ |
|
1113 | + [ |
|
1114 | + 'shared_secret' => '57b58edb6637fe3059b3595cf9c41b9', |
|
1115 | + 'users' => ['sample-user'], |
|
1116 | + 'apps' => ['files'], |
|
1117 | + 'loglevel' => 1, |
|
1118 | + 'message' => 'contains substring' |
|
1119 | + ], |
|
1120 | + ], |
|
1121 | 1121 | ], |
1122 | 1122 | |
1123 | 1123 | /** |
@@ -1191,20 +1191,20 @@ discard block |
||
1191 | 1191 | * - F-Droid client: ``https://f-droid.org/packages/com.nextcloud.client/`` |
1192 | 1192 | */ |
1193 | 1193 | 'customclient_desktop' => |
1194 | - 'https://nextcloud.com/install/#install-clients', |
|
1194 | + 'https://nextcloud.com/install/#install-clients', |
|
1195 | 1195 | 'customclient_android' => |
1196 | - 'https://play.google.com/store/apps/details?id=com.nextcloud.client', |
|
1196 | + 'https://play.google.com/store/apps/details?id=com.nextcloud.client', |
|
1197 | 1197 | 'customclient_ios' => |
1198 | - 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', |
|
1198 | + 'https://itunes.apple.com/us/app/nextcloud/id1125420102?mt=8', |
|
1199 | 1199 | 'customclient_ios_appid' => |
1200 | - '1125420102', |
|
1200 | + '1125420102', |
|
1201 | 1201 | 'customclient_fdroid' => |
1202 | - 'https://f-droid.org/packages/com.nextcloud.client/', |
|
1202 | + 'https://f-droid.org/packages/com.nextcloud.client/', |
|
1203 | 1203 | /** |
1204 | - * Apps |
|
1205 | - * |
|
1206 | - * Options for the Apps folder, Apps store, and App code checker. |
|
1207 | - */ |
|
1204 | + * Apps |
|
1205 | + * |
|
1206 | + * Options for the Apps folder, Apps store, and App code checker. |
|
1207 | + */ |
|
1208 | 1208 | |
1209 | 1209 | /** |
1210 | 1210 | * Set the default app to open on login. The entry IDs can be retrieved from |
@@ -1247,11 +1247,11 @@ discard block |
||
1247 | 1247 | * indicates if a Web server can write files to that folder. |
1248 | 1248 | */ |
1249 | 1249 | 'apps_paths' => [ |
1250 | - [ |
|
1251 | - 'path'=> '/var/www/nextcloud/apps', |
|
1252 | - 'url' => '/apps', |
|
1253 | - 'writable' => true, |
|
1254 | - ], |
|
1250 | + [ |
|
1251 | + 'path'=> '/var/www/nextcloud/apps', |
|
1252 | + 'url' => '/apps', |
|
1253 | + 'writable' => true, |
|
1254 | + ], |
|
1255 | 1255 | ], |
1256 | 1256 | |
1257 | 1257 | /** |
@@ -1406,16 +1406,16 @@ discard block |
||
1406 | 1406 | * - ``OC\Preview\XBitmap`` |
1407 | 1407 | */ |
1408 | 1408 | 'enabledPreviewProviders' => [ |
1409 | - 'OC\Preview\BMP', |
|
1410 | - 'OC\Preview\GIF', |
|
1411 | - 'OC\Preview\JPEG', |
|
1412 | - 'OC\Preview\Krita', |
|
1413 | - 'OC\Preview\MarkDown', |
|
1414 | - 'OC\Preview\MP3', |
|
1415 | - 'OC\Preview\OpenDocument', |
|
1416 | - 'OC\Preview\PNG', |
|
1417 | - 'OC\Preview\TXT', |
|
1418 | - 'OC\Preview\XBitmap', |
|
1409 | + 'OC\Preview\BMP', |
|
1410 | + 'OC\Preview\GIF', |
|
1411 | + 'OC\Preview\JPEG', |
|
1412 | + 'OC\Preview\Krita', |
|
1413 | + 'OC\Preview\MarkDown', |
|
1414 | + 'OC\Preview\MP3', |
|
1415 | + 'OC\Preview\OpenDocument', |
|
1416 | + 'OC\Preview\PNG', |
|
1417 | + 'OC\Preview\TXT', |
|
1418 | + 'OC\Preview\XBitmap', |
|
1419 | 1419 | ], |
1420 | 1420 | |
1421 | 1421 | /** |
@@ -1531,11 +1531,11 @@ discard block |
||
1531 | 1531 | |
1532 | 1532 | /** |
1533 | 1533 | * Extra SSL options to be used for configuration. |
1534 | - * |
|
1534 | + * |
|
1535 | 1535 | * Defaults to an empty array. |
1536 | 1536 | */ |
1537 | 1537 | 'openssl' => [ |
1538 | - 'config' => '/absolute/location/of/openssl.cnf', |
|
1538 | + 'config' => '/absolute/location/of/openssl.cnf', |
|
1539 | 1539 | ], |
1540 | 1540 | |
1541 | 1541 | /** |
@@ -1586,20 +1586,20 @@ discard block |
||
1586 | 1586 | * See https://redis.io/topics/encryption for more information. |
1587 | 1587 | */ |
1588 | 1588 | 'redis' => [ |
1589 | - 'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock' |
|
1590 | - 'port' => 6379, |
|
1591 | - 'timeout' => 0.0, |
|
1592 | - 'read_timeout' => 0.0, |
|
1593 | - 'user' => '', // Optional: if not defined, no password will be used. |
|
1594 | - 'password' => '', // Optional: if not defined, no password will be used. |
|
1595 | - 'dbindex' => 0, // Optional: if undefined SELECT will not run and will use Redis Server's default DB Index. |
|
1596 | - // If redis in-transit encryption is enabled, provide certificates |
|
1597 | - // SSL context https://www.php.net/manual/en/context.ssl.php |
|
1598 | - 'ssl_context' => [ |
|
1599 | - 'local_cert' => '/certs/redis.crt', |
|
1600 | - 'local_pk' => '/certs/redis.key', |
|
1601 | - 'cafile' => '/certs/ca.crt' |
|
1602 | - ] |
|
1589 | + 'host' => 'localhost', // can also be a unix domain socket: '/tmp/redis.sock' |
|
1590 | + 'port' => 6379, |
|
1591 | + 'timeout' => 0.0, |
|
1592 | + 'read_timeout' => 0.0, |
|
1593 | + 'user' => '', // Optional: if not defined, no password will be used. |
|
1594 | + 'password' => '', // Optional: if not defined, no password will be used. |
|
1595 | + 'dbindex' => 0, // Optional: if undefined SELECT will not run and will use Redis Server's default DB Index. |
|
1596 | + // If redis in-transit encryption is enabled, provide certificates |
|
1597 | + // SSL context https://www.php.net/manual/en/context.ssl.php |
|
1598 | + 'ssl_context' => [ |
|
1599 | + 'local_cert' => '/certs/redis.crt', |
|
1600 | + 'local_pk' => '/certs/redis.key', |
|
1601 | + 'cafile' => '/certs/ca.crt' |
|
1602 | + ] |
|
1603 | 1603 | ], |
1604 | 1604 | |
1605 | 1605 | /** |
@@ -1625,22 +1625,22 @@ discard block |
||
1625 | 1625 | * https://github.com/phpredis/phpredis/commit/c5994f2a42b8a348af92d3acb4edff1328ad8ce1 |
1626 | 1626 | */ |
1627 | 1627 | 'redis.cluster' => [ |
1628 | - 'seeds' => [ // provide some or all of the cluster servers to bootstrap discovery, port required |
|
1629 | - 'localhost:7000', |
|
1630 | - 'localhost:7001', |
|
1631 | - ], |
|
1632 | - 'timeout' => 0.0, |
|
1633 | - 'read_timeout' => 0.0, |
|
1634 | - 'failover_mode' => \RedisCluster::FAILOVER_ERROR, |
|
1635 | - 'user' => '', // Optional: if not defined, no password will be used. |
|
1636 | - 'password' => '', // Optional: if not defined, no password will be used. |
|
1637 | - // If redis in-transit encryption is enabled, provide certificates |
|
1638 | - // SSL context https://www.php.net/manual/en/context.ssl.php |
|
1639 | - 'ssl_context' => [ |
|
1640 | - 'local_cert' => '/certs/redis.crt', |
|
1641 | - 'local_pk' => '/certs/redis.key', |
|
1642 | - 'cafile' => '/certs/ca.crt' |
|
1643 | - ] |
|
1628 | + 'seeds' => [ // provide some or all of the cluster servers to bootstrap discovery, port required |
|
1629 | + 'localhost:7000', |
|
1630 | + 'localhost:7001', |
|
1631 | + ], |
|
1632 | + 'timeout' => 0.0, |
|
1633 | + 'read_timeout' => 0.0, |
|
1634 | + 'failover_mode' => \RedisCluster::FAILOVER_ERROR, |
|
1635 | + 'user' => '', // Optional: if not defined, no password will be used. |
|
1636 | + 'password' => '', // Optional: if not defined, no password will be used. |
|
1637 | + // If redis in-transit encryption is enabled, provide certificates |
|
1638 | + // SSL context https://www.php.net/manual/en/context.ssl.php |
|
1639 | + 'ssl_context' => [ |
|
1640 | + 'local_cert' => '/certs/redis.crt', |
|
1641 | + 'local_pk' => '/certs/redis.key', |
|
1642 | + 'cafile' => '/certs/ca.crt' |
|
1643 | + ] |
|
1644 | 1644 | ], |
1645 | 1645 | |
1646 | 1646 | |
@@ -1648,36 +1648,36 @@ discard block |
||
1648 | 1648 | * Server details for one or more memcached servers to use for memory caching. |
1649 | 1649 | */ |
1650 | 1650 | 'memcached_servers' => [ |
1651 | - // hostname, port and optional weight |
|
1652 | - // or path and port 0 for unix socket. Also see: |
|
1653 | - // https://www.php.net/manual/en/memcached.addservers.php |
|
1654 | - // https://www.php.net/manual/en/memcached.addserver.php |
|
1655 | - ['localhost', 11211], |
|
1656 | - //array('other.host.local', 11211), |
|
1651 | + // hostname, port and optional weight |
|
1652 | + // or path and port 0 for unix socket. Also see: |
|
1653 | + // https://www.php.net/manual/en/memcached.addservers.php |
|
1654 | + // https://www.php.net/manual/en/memcached.addserver.php |
|
1655 | + ['localhost', 11211], |
|
1656 | + //array('other.host.local', 11211), |
|
1657 | 1657 | ], |
1658 | 1658 | |
1659 | 1659 | /** |
1660 | 1660 | * Connection options for memcached |
1661 | 1661 | */ |
1662 | 1662 | 'memcached_options' => [ |
1663 | - // Set timeouts to 50ms |
|
1664 | - \Memcached::OPT_CONNECT_TIMEOUT => 50, |
|
1665 | - \Memcached::OPT_RETRY_TIMEOUT => 50, |
|
1666 | - \Memcached::OPT_SEND_TIMEOUT => 50, |
|
1667 | - \Memcached::OPT_RECV_TIMEOUT => 50, |
|
1668 | - \Memcached::OPT_POLL_TIMEOUT => 50, |
|
1663 | + // Set timeouts to 50ms |
|
1664 | + \Memcached::OPT_CONNECT_TIMEOUT => 50, |
|
1665 | + \Memcached::OPT_RETRY_TIMEOUT => 50, |
|
1666 | + \Memcached::OPT_SEND_TIMEOUT => 50, |
|
1667 | + \Memcached::OPT_RECV_TIMEOUT => 50, |
|
1668 | + \Memcached::OPT_POLL_TIMEOUT => 50, |
|
1669 | 1669 | |
1670 | - // Enable compression |
|
1671 | - \Memcached::OPT_COMPRESSION => true, |
|
1670 | + // Enable compression |
|
1671 | + \Memcached::OPT_COMPRESSION => true, |
|
1672 | 1672 | |
1673 | - // Turn on consistent hashing |
|
1674 | - \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, |
|
1673 | + // Turn on consistent hashing |
|
1674 | + \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, |
|
1675 | 1675 | |
1676 | - // Enable Binary Protocol |
|
1677 | - \Memcached::OPT_BINARY_PROTOCOL => true, |
|
1676 | + // Enable Binary Protocol |
|
1677 | + \Memcached::OPT_BINARY_PROTOCOL => true, |
|
1678 | 1678 | |
1679 | - // Binary serializer vill be enabled if the igbinary PECL module is available |
|
1680 | - //\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY, |
|
1679 | + // Binary serializer vill be enabled if the igbinary PECL module is available |
|
1680 | + //\Memcached::OPT_SERIALIZER => \Memcached::SERIALIZER_IGBINARY, |
|
1681 | 1681 | ], |
1682 | 1682 | |
1683 | 1683 | |
@@ -1722,63 +1722,63 @@ discard block |
||
1722 | 1722 | * |
1723 | 1723 | */ |
1724 | 1724 | 'objectstore' => [ |
1725 | - 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
1726 | - 'arguments' => [ |
|
1727 | - // trystack will use your facebook id as the username |
|
1728 | - 'username' => 'facebook100000123456789', |
|
1729 | - // in the trystack dashboard go to user -> settings -> API Password to |
|
1730 | - // generate a password |
|
1731 | - 'password' => 'Secr3tPaSSWoRdt7', |
|
1732 | - // must already exist in the objectstore, name can be different |
|
1733 | - 'container' => 'nextcloud', |
|
1734 | - // prefix to prepend to the fileid, default is 'oid:urn:' |
|
1735 | - 'objectPrefix' => 'oid:urn:', |
|
1736 | - // create the container if it does not exist. default is false |
|
1737 | - 'autocreate' => true, |
|
1738 | - // required, dev-/trystack defaults to 'RegionOne' |
|
1739 | - 'region' => 'RegionOne', |
|
1740 | - // The Identity / Keystone endpoint |
|
1741 | - 'url' => 'http://8.21.28.222:5000/v2.0', |
|
1742 | - // uploadPartSize: size of the uploaded chunks, defaults to 524288000 |
|
1743 | - 'uploadPartSize' => 524288000, |
|
1744 | - // required on dev-/trystack |
|
1745 | - 'tenantName' => 'facebook100000123456789', |
|
1746 | - // dev-/trystack uses swift by default, the lib defaults to 'cloudFiles' |
|
1747 | - // if omitted |
|
1748 | - 'serviceName' => 'swift', |
|
1749 | - // The Interface / url Type, optional |
|
1750 | - 'urlType' => 'internal' |
|
1751 | - ], |
|
1725 | + 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
1726 | + 'arguments' => [ |
|
1727 | + // trystack will use your facebook id as the username |
|
1728 | + 'username' => 'facebook100000123456789', |
|
1729 | + // in the trystack dashboard go to user -> settings -> API Password to |
|
1730 | + // generate a password |
|
1731 | + 'password' => 'Secr3tPaSSWoRdt7', |
|
1732 | + // must already exist in the objectstore, name can be different |
|
1733 | + 'container' => 'nextcloud', |
|
1734 | + // prefix to prepend to the fileid, default is 'oid:urn:' |
|
1735 | + 'objectPrefix' => 'oid:urn:', |
|
1736 | + // create the container if it does not exist. default is false |
|
1737 | + 'autocreate' => true, |
|
1738 | + // required, dev-/trystack defaults to 'RegionOne' |
|
1739 | + 'region' => 'RegionOne', |
|
1740 | + // The Identity / Keystone endpoint |
|
1741 | + 'url' => 'http://8.21.28.222:5000/v2.0', |
|
1742 | + // uploadPartSize: size of the uploaded chunks, defaults to 524288000 |
|
1743 | + 'uploadPartSize' => 524288000, |
|
1744 | + // required on dev-/trystack |
|
1745 | + 'tenantName' => 'facebook100000123456789', |
|
1746 | + // dev-/trystack uses swift by default, the lib defaults to 'cloudFiles' |
|
1747 | + // if omitted |
|
1748 | + 'serviceName' => 'swift', |
|
1749 | + // The Interface / url Type, optional |
|
1750 | + 'urlType' => 'internal' |
|
1751 | + ], |
|
1752 | 1752 | ], |
1753 | 1753 | |
1754 | 1754 | /** |
1755 | 1755 | * To use swift V3 |
1756 | 1756 | */ |
1757 | 1757 | 'objectstore' => [ |
1758 | - 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
1759 | - 'arguments' => [ |
|
1760 | - 'autocreate' => true, |
|
1761 | - 'user' => [ |
|
1762 | - 'name' => 'swift', |
|
1763 | - 'password' => 'swift', |
|
1764 | - 'domain' => [ |
|
1765 | - 'name' => 'default', |
|
1766 | - ], |
|
1767 | - ], |
|
1768 | - 'scope' => [ |
|
1769 | - 'project' => [ |
|
1770 | - 'name' => 'service', |
|
1771 | - 'domain' => [ |
|
1772 | - 'name' => 'default', |
|
1773 | - ], |
|
1774 | - ], |
|
1775 | - ], |
|
1776 | - 'tenantName' => 'service', |
|
1777 | - 'serviceName' => 'swift', |
|
1778 | - 'region' => 'regionOne', |
|
1779 | - 'url' => 'http://yourswifthost:5000/v3', |
|
1780 | - 'bucket' => 'nextcloud', |
|
1781 | - ], |
|
1758 | + 'class' => 'OC\\Files\\ObjectStore\\Swift', |
|
1759 | + 'arguments' => [ |
|
1760 | + 'autocreate' => true, |
|
1761 | + 'user' => [ |
|
1762 | + 'name' => 'swift', |
|
1763 | + 'password' => 'swift', |
|
1764 | + 'domain' => [ |
|
1765 | + 'name' => 'default', |
|
1766 | + ], |
|
1767 | + ], |
|
1768 | + 'scope' => [ |
|
1769 | + 'project' => [ |
|
1770 | + 'name' => 'service', |
|
1771 | + 'domain' => [ |
|
1772 | + 'name' => 'default', |
|
1773 | + ], |
|
1774 | + ], |
|
1775 | + ], |
|
1776 | + 'tenantName' => 'service', |
|
1777 | + 'serviceName' => 'swift', |
|
1778 | + 'region' => 'regionOne', |
|
1779 | + 'url' => 'http://yourswifthost:5000/v3', |
|
1780 | + 'bucket' => 'nextcloud', |
|
1781 | + ], |
|
1782 | 1782 | ], |
1783 | 1783 | |
1784 | 1784 | /** |
@@ -1891,9 +1891,9 @@ discard block |
||
1891 | 1891 | * Federated Cloud Sharing |
1892 | 1892 | */ |
1893 | 1893 | |
1894 | - /** |
|
1895 | - * Allow self-signed certificates for federated shares |
|
1896 | - */ |
|
1894 | + /** |
|
1895 | + * Allow self-signed certificates for federated shares |
|
1896 | + */ |
|
1897 | 1897 | 'sharing.federation.allowSelfSignedCertificates' => false, |
1898 | 1898 | |
1899 | 1899 | /** |
@@ -1955,11 +1955,11 @@ discard block |
||
1955 | 1955 | * does not verify the server cert except --ssl-verify-server-cert is passed manually. |
1956 | 1956 | */ |
1957 | 1957 | 'dbdriveroptions' => [ |
1958 | - PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem', |
|
1959 | - PDO::MYSQL_ATTR_SSL_KEY => '/file/path/to/mysql-client-key.pem', |
|
1960 | - PDO::MYSQL_ATTR_SSL_CERT => '/file/path/to/mysql-client-cert.pem', |
|
1961 | - PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false, |
|
1962 | - PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800' |
|
1958 | + PDO::MYSQL_ATTR_SSL_CA => '/file/path/to/ca_cert.pem', |
|
1959 | + PDO::MYSQL_ATTR_SSL_KEY => '/file/path/to/mysql-client-key.pem', |
|
1960 | + PDO::MYSQL_ATTR_SSL_CERT => '/file/path/to/mysql-client-cert.pem', |
|
1961 | + PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false, |
|
1962 | + PDO::MYSQL_ATTR_INIT_COMMAND => 'SET wait_timeout = 28800' |
|
1963 | 1963 | ], |
1964 | 1964 | |
1965 | 1965 | /** |
@@ -2034,10 +2034,10 @@ discard block |
||
2034 | 2034 | * - pgsql (PostgreSQL) |
2035 | 2035 | */ |
2036 | 2036 | 'supportedDatabases' => [ |
2037 | - 'sqlite', |
|
2038 | - 'mysql', |
|
2039 | - 'pgsql', |
|
2040 | - 'oci', |
|
2037 | + 'sqlite', |
|
2038 | + 'mysql', |
|
2039 | + 'pgsql', |
|
2040 | + 'oci', |
|
2041 | 2041 | ], |
2042 | 2042 | |
2043 | 2043 | /** |
@@ -2442,8 +2442,8 @@ discard block |
||
2442 | 2442 | * WARNING: only use this if you know what you are doing |
2443 | 2443 | */ |
2444 | 2444 | 'csrf.optout' => [ |
2445 | - '/^WebDAVFS/', // OS X Finder |
|
2446 | - '/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive |
|
2445 | + '/^WebDAVFS/', // OS X Finder |
|
2446 | + '/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive |
|
2447 | 2447 | ], |
2448 | 2448 | |
2449 | 2449 | /** |
@@ -2595,13 +2595,13 @@ discard block |
||
2595 | 2595 | * Defaults to ``['/usr/local/sbin','/usr/local/bin','/usr/sbin','/usr/bin','/sbin','/bin','/opt/bin']`` |
2596 | 2596 | */ |
2597 | 2597 | 'binary_search_paths' => [ |
2598 | - '/usr/local/sbin', |
|
2599 | - '/usr/local/bin', |
|
2600 | - '/usr/sbin', |
|
2601 | - '/usr/bin', |
|
2602 | - '/sbin', |
|
2603 | - '/bin', |
|
2604 | - '/opt/bin', |
|
2598 | + '/usr/local/sbin', |
|
2599 | + '/usr/local/bin', |
|
2600 | + '/usr/sbin', |
|
2601 | + '/usr/bin', |
|
2602 | + '/sbin', |
|
2603 | + '/bin', |
|
2604 | + '/opt/bin', |
|
2605 | 2605 | ], |
2606 | 2606 | |
2607 | 2607 | /** |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->appData = $appData; |
64 | 64 | $this->urlGenerator = $urlGenerator; |
65 | 65 | $this->cacheFactory = $cacheFactory; |
66 | - $this->depsCache = $this->cacheFactory->createDistributed('JS-' . md5($this->urlGenerator->getBaseUrl())); |
|
66 | + $this->depsCache = $this->cacheFactory->createDistributed('JS-'.md5($this->urlGenerator->getBaseUrl())); |
|
67 | 67 | $this->config = $config; |
68 | 68 | $this->logger = $logger; |
69 | 69 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | return false; |
80 | 80 | } |
81 | 81 | |
82 | - $path = explode('/', $root . '/' . $file); |
|
82 | + $path = explode('/', $root.'/'.$file); |
|
83 | 83 | |
84 | 84 | $fileName = array_pop($path); |
85 | 85 | $path = implode('/', $path); |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | return false; |
110 | 110 | } |
111 | 111 | |
112 | - $fileName = $fileName . '.deps'; |
|
112 | + $fileName = $fileName.'.deps'; |
|
113 | 113 | try { |
114 | - $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
114 | + $deps = $this->depsCache->get($folder->getName().'-'.$fileName); |
|
115 | 115 | $fromCache = true; |
116 | 116 | if ($deps === null || $deps === '') { |
117 | 117 | $fromCache = false; |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | |
122 | 122 | // check again |
123 | 123 | if ($deps === null || $deps === '') { |
124 | - $this->logger->info('JSCombiner: deps file empty: ' . $fileName); |
|
124 | + $this->logger->info('JSCombiner: deps file empty: '.$fileName); |
|
125 | 125 | return false; |
126 | 126 | } |
127 | 127 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | if ($fromCache === false) { |
141 | - $this->depsCache->set($folder->getName() . '-' . $fileName, json_encode($deps)); |
|
141 | + $this->depsCache->set($folder->getName().'-'.$fileName, json_encode($deps)); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | return true; |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | */ |
156 | 156 | protected function cache($path, $fileName, ISimpleFolder $folder) { |
157 | 157 | $deps = []; |
158 | - $fullPath = $path . '/' . $fileName; |
|
158 | + $fullPath = $path.'/'.$fileName; |
|
159 | 159 | $data = json_decode(file_get_contents($fullPath)); |
160 | 160 | $deps[$fullPath] = filemtime($fullPath); |
161 | 161 | |
162 | 162 | $res = ''; |
163 | 163 | foreach ($data as $file) { |
164 | - $filePath = $path . '/' . $file; |
|
164 | + $filePath = $path.'/'.$file; |
|
165 | 165 | |
166 | 166 | if (is_file($filePath)) { |
167 | 167 | $res .= file_get_contents($filePath); |
168 | - $res .= PHP_EOL . PHP_EOL; |
|
168 | + $res .= PHP_EOL.PHP_EOL; |
|
169 | 169 | $deps[$filePath] = filemtime($filePath); |
170 | 170 | } |
171 | 171 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $cachedfile = $folder->newFile($fileName); |
178 | 178 | } |
179 | 179 | |
180 | - $depFileName = $fileName . '.deps'; |
|
180 | + $depFileName = $fileName.'.deps'; |
|
181 | 181 | try { |
182 | 182 | $depFile = $folder->getFile($depFileName); |
183 | 183 | } catch (NotFoundException $e) { |
@@ -185,21 +185,21 @@ discard block |
||
185 | 185 | } |
186 | 186 | |
187 | 187 | try { |
188 | - $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
188 | + $gzipFile = $folder->getFile($fileName.'.gzip'); # Safari doesn't like .gz |
|
189 | 189 | } catch (NotFoundException $e) { |
190 | - $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
190 | + $gzipFile = $folder->newFile($fileName.'.gzip'); # Safari doesn't like .gz |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | try { |
194 | 194 | $cachedfile->putContent($res); |
195 | 195 | $deps = json_encode($deps); |
196 | 196 | $depFile->putContent($deps); |
197 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
197 | + $this->depsCache->set($folder->getName().'-'.$depFileName, $deps); |
|
198 | 198 | $gzipFile->putContent(gzencode($res, 9)); |
199 | - $this->logger->debug('JSCombiner: successfully cached: ' . $fileName); |
|
199 | + $this->logger->debug('JSCombiner: successfully cached: '.$fileName); |
|
200 | 200 | return true; |
201 | - } catch (NotPermittedException|NotFoundException $e) { |
|
202 | - $this->logger->error('JSCombiner: unable to cache: ' . $fileName); |
|
201 | + } catch (NotPermittedException | NotFoundException $e) { |
|
202 | + $this->logger->error('JSCombiner: unable to cache: '.$fileName); |
|
203 | 203 | return false; |
204 | 204 | } |
205 | 205 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | */ |
225 | 225 | public function getContent($root, $file) { |
226 | 226 | /** @var array $data */ |
227 | - $data = json_decode(file_get_contents($root . '/' . $file)); |
|
227 | + $data = json_decode(file_get_contents($root.'/'.$file)); |
|
228 | 228 | if (!is_array($data)) { |
229 | 229 | return []; |
230 | 230 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | |
236 | 236 | $result = []; |
237 | 237 | foreach ($data as $f) { |
238 | - $result[] = $path . '/' . $f; |
|
238 | + $result[] = $path.'/'.$f; |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | return $result; |
@@ -16,222 +16,222 @@ |
||
16 | 16 | use Psr\Log\LoggerInterface; |
17 | 17 | |
18 | 18 | class JSCombiner { |
19 | - /** @var IAppData */ |
|
20 | - protected $appData; |
|
21 | - |
|
22 | - /** @var IURLGenerator */ |
|
23 | - protected $urlGenerator; |
|
24 | - |
|
25 | - /** @var ICache */ |
|
26 | - protected $depsCache; |
|
27 | - |
|
28 | - /** @var SystemConfig */ |
|
29 | - protected $config; |
|
30 | - |
|
31 | - protected LoggerInterface $logger; |
|
32 | - |
|
33 | - /** @var ICacheFactory */ |
|
34 | - private $cacheFactory; |
|
35 | - |
|
36 | - public function __construct(IAppData $appData, |
|
37 | - IURLGenerator $urlGenerator, |
|
38 | - ICacheFactory $cacheFactory, |
|
39 | - SystemConfig $config, |
|
40 | - LoggerInterface $logger) { |
|
41 | - $this->appData = $appData; |
|
42 | - $this->urlGenerator = $urlGenerator; |
|
43 | - $this->cacheFactory = $cacheFactory; |
|
44 | - $this->depsCache = $this->cacheFactory->createDistributed('JS-' . md5($this->urlGenerator->getBaseUrl())); |
|
45 | - $this->config = $config; |
|
46 | - $this->logger = $logger; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param string $root |
|
51 | - * @param string $file |
|
52 | - * @param string $app |
|
53 | - * @return bool |
|
54 | - */ |
|
55 | - public function process($root, $file, $app) { |
|
56 | - if ($this->config->getValue('debug') || !$this->config->getValue('installed')) { |
|
57 | - return false; |
|
58 | - } |
|
59 | - |
|
60 | - $path = explode('/', $root . '/' . $file); |
|
61 | - |
|
62 | - $fileName = array_pop($path); |
|
63 | - $path = implode('/', $path); |
|
64 | - |
|
65 | - try { |
|
66 | - $folder = $this->appData->getFolder($app); |
|
67 | - } catch (NotFoundException $e) { |
|
68 | - // creating css appdata folder |
|
69 | - $folder = $this->appData->newFolder($app); |
|
70 | - } |
|
71 | - |
|
72 | - if ($this->isCached($fileName, $folder)) { |
|
73 | - return true; |
|
74 | - } |
|
75 | - return $this->cache($path, $fileName, $folder); |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @param string $fileName |
|
80 | - * @param ISimpleFolder $folder |
|
81 | - * @return bool |
|
82 | - */ |
|
83 | - protected function isCached($fileName, ISimpleFolder $folder) { |
|
84 | - $fileName = str_replace('.json', '.js', $fileName); |
|
85 | - |
|
86 | - if (!$folder->fileExists($fileName)) { |
|
87 | - return false; |
|
88 | - } |
|
89 | - |
|
90 | - $fileName = $fileName . '.deps'; |
|
91 | - try { |
|
92 | - $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
93 | - $fromCache = true; |
|
94 | - if ($deps === null || $deps === '') { |
|
95 | - $fromCache = false; |
|
96 | - $depFile = $folder->getFile($fileName); |
|
97 | - $deps = $depFile->getContent(); |
|
98 | - } |
|
99 | - |
|
100 | - // check again |
|
101 | - if ($deps === null || $deps === '') { |
|
102 | - $this->logger->info('JSCombiner: deps file empty: ' . $fileName); |
|
103 | - return false; |
|
104 | - } |
|
105 | - |
|
106 | - $deps = json_decode($deps, true); |
|
107 | - |
|
108 | - if ($deps === null) { |
|
109 | - return false; |
|
110 | - } |
|
111 | - |
|
112 | - foreach ($deps as $file => $mtime) { |
|
113 | - if (!file_exists($file) || filemtime($file) > $mtime) { |
|
114 | - return false; |
|
115 | - } |
|
116 | - } |
|
117 | - |
|
118 | - if ($fromCache === false) { |
|
119 | - $this->depsCache->set($folder->getName() . '-' . $fileName, json_encode($deps)); |
|
120 | - } |
|
121 | - |
|
122 | - return true; |
|
123 | - } catch (NotFoundException $e) { |
|
124 | - return false; |
|
125 | - } |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @param string $path |
|
130 | - * @param string $fileName |
|
131 | - * @param ISimpleFolder $folder |
|
132 | - * @return bool |
|
133 | - */ |
|
134 | - protected function cache($path, $fileName, ISimpleFolder $folder) { |
|
135 | - $deps = []; |
|
136 | - $fullPath = $path . '/' . $fileName; |
|
137 | - $data = json_decode(file_get_contents($fullPath)); |
|
138 | - $deps[$fullPath] = filemtime($fullPath); |
|
139 | - |
|
140 | - $res = ''; |
|
141 | - foreach ($data as $file) { |
|
142 | - $filePath = $path . '/' . $file; |
|
143 | - |
|
144 | - if (is_file($filePath)) { |
|
145 | - $res .= file_get_contents($filePath); |
|
146 | - $res .= PHP_EOL . PHP_EOL; |
|
147 | - $deps[$filePath] = filemtime($filePath); |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - $fileName = str_replace('.json', '.js', $fileName); |
|
152 | - try { |
|
153 | - $cachedfile = $folder->getFile($fileName); |
|
154 | - } catch (NotFoundException $e) { |
|
155 | - $cachedfile = $folder->newFile($fileName); |
|
156 | - } |
|
157 | - |
|
158 | - $depFileName = $fileName . '.deps'; |
|
159 | - try { |
|
160 | - $depFile = $folder->getFile($depFileName); |
|
161 | - } catch (NotFoundException $e) { |
|
162 | - $depFile = $folder->newFile($depFileName); |
|
163 | - } |
|
164 | - |
|
165 | - try { |
|
166 | - $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
167 | - } catch (NotFoundException $e) { |
|
168 | - $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
169 | - } |
|
170 | - |
|
171 | - try { |
|
172 | - $cachedfile->putContent($res); |
|
173 | - $deps = json_encode($deps); |
|
174 | - $depFile->putContent($deps); |
|
175 | - $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
176 | - $gzipFile->putContent(gzencode($res, 9)); |
|
177 | - $this->logger->debug('JSCombiner: successfully cached: ' . $fileName); |
|
178 | - return true; |
|
179 | - } catch (NotPermittedException|NotFoundException $e) { |
|
180 | - $this->logger->error('JSCombiner: unable to cache: ' . $fileName); |
|
181 | - return false; |
|
182 | - } |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * @param string $appName |
|
187 | - * @param string $fileName |
|
188 | - * @return string |
|
189 | - */ |
|
190 | - public function getCachedJS($appName, $fileName) { |
|
191 | - $tmpfileLoc = explode('/', $fileName); |
|
192 | - $fileName = array_pop($tmpfileLoc); |
|
193 | - $fileName = str_replace('.json', '.js', $fileName); |
|
194 | - |
|
195 | - return substr($this->urlGenerator->linkToRoute('core.Js.getJs', ['fileName' => $fileName, 'appName' => $appName]), strlen(\OC::$WEBROOT) + 1); |
|
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * @param string $root |
|
200 | - * @param string $file |
|
201 | - * @return string[] |
|
202 | - */ |
|
203 | - public function getContent($root, $file) { |
|
204 | - /** @var array $data */ |
|
205 | - $data = json_decode(file_get_contents($root . '/' . $file)); |
|
206 | - if (!is_array($data)) { |
|
207 | - return []; |
|
208 | - } |
|
209 | - |
|
210 | - $path = explode('/', $file); |
|
211 | - array_pop($path); |
|
212 | - $path = implode('/', $path); |
|
213 | - |
|
214 | - $result = []; |
|
215 | - foreach ($data as $f) { |
|
216 | - $result[] = $path . '/' . $f; |
|
217 | - } |
|
218 | - |
|
219 | - return $result; |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * Clear cache with combined javascript files |
|
225 | - * |
|
226 | - * @throws NotFoundException |
|
227 | - */ |
|
228 | - public function resetCache() { |
|
229 | - $this->cacheFactory->createDistributed('JS-')->clear(); |
|
230 | - $appDirectory = $this->appData->getDirectoryListing(); |
|
231 | - foreach ($appDirectory as $folder) { |
|
232 | - foreach ($folder->getDirectoryListing() as $file) { |
|
233 | - $file->delete(); |
|
234 | - } |
|
235 | - } |
|
236 | - } |
|
19 | + /** @var IAppData */ |
|
20 | + protected $appData; |
|
21 | + |
|
22 | + /** @var IURLGenerator */ |
|
23 | + protected $urlGenerator; |
|
24 | + |
|
25 | + /** @var ICache */ |
|
26 | + protected $depsCache; |
|
27 | + |
|
28 | + /** @var SystemConfig */ |
|
29 | + protected $config; |
|
30 | + |
|
31 | + protected LoggerInterface $logger; |
|
32 | + |
|
33 | + /** @var ICacheFactory */ |
|
34 | + private $cacheFactory; |
|
35 | + |
|
36 | + public function __construct(IAppData $appData, |
|
37 | + IURLGenerator $urlGenerator, |
|
38 | + ICacheFactory $cacheFactory, |
|
39 | + SystemConfig $config, |
|
40 | + LoggerInterface $logger) { |
|
41 | + $this->appData = $appData; |
|
42 | + $this->urlGenerator = $urlGenerator; |
|
43 | + $this->cacheFactory = $cacheFactory; |
|
44 | + $this->depsCache = $this->cacheFactory->createDistributed('JS-' . md5($this->urlGenerator->getBaseUrl())); |
|
45 | + $this->config = $config; |
|
46 | + $this->logger = $logger; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param string $root |
|
51 | + * @param string $file |
|
52 | + * @param string $app |
|
53 | + * @return bool |
|
54 | + */ |
|
55 | + public function process($root, $file, $app) { |
|
56 | + if ($this->config->getValue('debug') || !$this->config->getValue('installed')) { |
|
57 | + return false; |
|
58 | + } |
|
59 | + |
|
60 | + $path = explode('/', $root . '/' . $file); |
|
61 | + |
|
62 | + $fileName = array_pop($path); |
|
63 | + $path = implode('/', $path); |
|
64 | + |
|
65 | + try { |
|
66 | + $folder = $this->appData->getFolder($app); |
|
67 | + } catch (NotFoundException $e) { |
|
68 | + // creating css appdata folder |
|
69 | + $folder = $this->appData->newFolder($app); |
|
70 | + } |
|
71 | + |
|
72 | + if ($this->isCached($fileName, $folder)) { |
|
73 | + return true; |
|
74 | + } |
|
75 | + return $this->cache($path, $fileName, $folder); |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @param string $fileName |
|
80 | + * @param ISimpleFolder $folder |
|
81 | + * @return bool |
|
82 | + */ |
|
83 | + protected function isCached($fileName, ISimpleFolder $folder) { |
|
84 | + $fileName = str_replace('.json', '.js', $fileName); |
|
85 | + |
|
86 | + if (!$folder->fileExists($fileName)) { |
|
87 | + return false; |
|
88 | + } |
|
89 | + |
|
90 | + $fileName = $fileName . '.deps'; |
|
91 | + try { |
|
92 | + $deps = $this->depsCache->get($folder->getName() . '-' . $fileName); |
|
93 | + $fromCache = true; |
|
94 | + if ($deps === null || $deps === '') { |
|
95 | + $fromCache = false; |
|
96 | + $depFile = $folder->getFile($fileName); |
|
97 | + $deps = $depFile->getContent(); |
|
98 | + } |
|
99 | + |
|
100 | + // check again |
|
101 | + if ($deps === null || $deps === '') { |
|
102 | + $this->logger->info('JSCombiner: deps file empty: ' . $fileName); |
|
103 | + return false; |
|
104 | + } |
|
105 | + |
|
106 | + $deps = json_decode($deps, true); |
|
107 | + |
|
108 | + if ($deps === null) { |
|
109 | + return false; |
|
110 | + } |
|
111 | + |
|
112 | + foreach ($deps as $file => $mtime) { |
|
113 | + if (!file_exists($file) || filemtime($file) > $mtime) { |
|
114 | + return false; |
|
115 | + } |
|
116 | + } |
|
117 | + |
|
118 | + if ($fromCache === false) { |
|
119 | + $this->depsCache->set($folder->getName() . '-' . $fileName, json_encode($deps)); |
|
120 | + } |
|
121 | + |
|
122 | + return true; |
|
123 | + } catch (NotFoundException $e) { |
|
124 | + return false; |
|
125 | + } |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @param string $path |
|
130 | + * @param string $fileName |
|
131 | + * @param ISimpleFolder $folder |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | + protected function cache($path, $fileName, ISimpleFolder $folder) { |
|
135 | + $deps = []; |
|
136 | + $fullPath = $path . '/' . $fileName; |
|
137 | + $data = json_decode(file_get_contents($fullPath)); |
|
138 | + $deps[$fullPath] = filemtime($fullPath); |
|
139 | + |
|
140 | + $res = ''; |
|
141 | + foreach ($data as $file) { |
|
142 | + $filePath = $path . '/' . $file; |
|
143 | + |
|
144 | + if (is_file($filePath)) { |
|
145 | + $res .= file_get_contents($filePath); |
|
146 | + $res .= PHP_EOL . PHP_EOL; |
|
147 | + $deps[$filePath] = filemtime($filePath); |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + $fileName = str_replace('.json', '.js', $fileName); |
|
152 | + try { |
|
153 | + $cachedfile = $folder->getFile($fileName); |
|
154 | + } catch (NotFoundException $e) { |
|
155 | + $cachedfile = $folder->newFile($fileName); |
|
156 | + } |
|
157 | + |
|
158 | + $depFileName = $fileName . '.deps'; |
|
159 | + try { |
|
160 | + $depFile = $folder->getFile($depFileName); |
|
161 | + } catch (NotFoundException $e) { |
|
162 | + $depFile = $folder->newFile($depFileName); |
|
163 | + } |
|
164 | + |
|
165 | + try { |
|
166 | + $gzipFile = $folder->getFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
167 | + } catch (NotFoundException $e) { |
|
168 | + $gzipFile = $folder->newFile($fileName . '.gzip'); # Safari doesn't like .gz |
|
169 | + } |
|
170 | + |
|
171 | + try { |
|
172 | + $cachedfile->putContent($res); |
|
173 | + $deps = json_encode($deps); |
|
174 | + $depFile->putContent($deps); |
|
175 | + $this->depsCache->set($folder->getName() . '-' . $depFileName, $deps); |
|
176 | + $gzipFile->putContent(gzencode($res, 9)); |
|
177 | + $this->logger->debug('JSCombiner: successfully cached: ' . $fileName); |
|
178 | + return true; |
|
179 | + } catch (NotPermittedException|NotFoundException $e) { |
|
180 | + $this->logger->error('JSCombiner: unable to cache: ' . $fileName); |
|
181 | + return false; |
|
182 | + } |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * @param string $appName |
|
187 | + * @param string $fileName |
|
188 | + * @return string |
|
189 | + */ |
|
190 | + public function getCachedJS($appName, $fileName) { |
|
191 | + $tmpfileLoc = explode('/', $fileName); |
|
192 | + $fileName = array_pop($tmpfileLoc); |
|
193 | + $fileName = str_replace('.json', '.js', $fileName); |
|
194 | + |
|
195 | + return substr($this->urlGenerator->linkToRoute('core.Js.getJs', ['fileName' => $fileName, 'appName' => $appName]), strlen(\OC::$WEBROOT) + 1); |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * @param string $root |
|
200 | + * @param string $file |
|
201 | + * @return string[] |
|
202 | + */ |
|
203 | + public function getContent($root, $file) { |
|
204 | + /** @var array $data */ |
|
205 | + $data = json_decode(file_get_contents($root . '/' . $file)); |
|
206 | + if (!is_array($data)) { |
|
207 | + return []; |
|
208 | + } |
|
209 | + |
|
210 | + $path = explode('/', $file); |
|
211 | + array_pop($path); |
|
212 | + $path = implode('/', $path); |
|
213 | + |
|
214 | + $result = []; |
|
215 | + foreach ($data as $f) { |
|
216 | + $result[] = $path . '/' . $f; |
|
217 | + } |
|
218 | + |
|
219 | + return $result; |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * Clear cache with combined javascript files |
|
225 | + * |
|
226 | + * @throws NotFoundException |
|
227 | + */ |
|
228 | + public function resetCache() { |
|
229 | + $this->cacheFactory->createDistributed('JS-')->clear(); |
|
230 | + $appDirectory = $this->appData->getDirectoryListing(); |
|
231 | + foreach ($appDirectory as $folder) { |
|
232 | + foreach ($folder->getDirectoryListing() as $file) { |
|
233 | + $file->delete(); |
|
234 | + } |
|
235 | + } |
|
236 | + } |
|
237 | 237 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | if ($path === '') { |
80 | 80 | return $this->getRoot(); |
81 | 81 | } else { |
82 | - return $this->getRoot() . '/' . ltrim($path, '/'); |
|
82 | + return $this->getRoot().'/'.ltrim($path, '/'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $rootLength = strlen($root) + 1; |
99 | 99 | if ($path === $root) { |
100 | 100 | return ''; |
101 | - } elseif (substr($path, 0, $rootLength) === $root . '/') { |
|
101 | + } elseif (substr($path, 0, $rootLength) === $root.'/') { |
|
102 | 102 | return substr($path, $rootLength); |
103 | 103 | } else { |
104 | 104 | return null; |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, |
318 | 318 | [ |
319 | 319 | new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()), |
320 | - new SearchComparison(ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE, 'path', SearchComparison::escapeLikeParameter($this->getGetUnjailedRoot()) . '/%'), |
|
320 | + new SearchComparison(ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE, 'path', SearchComparison::escapeLikeParameter($this->getGetUnjailedRoot()).'/%'), |
|
321 | 321 | ], |
322 | 322 | ) |
323 | 323 | ] |
@@ -22,308 +22,308 @@ |
||
22 | 22 | */ |
23 | 23 | class CacheJail extends CacheWrapper { |
24 | 24 | |
25 | - protected string $unjailedRoot; |
|
26 | - |
|
27 | - public function __construct( |
|
28 | - ?ICache $cache, |
|
29 | - protected string $root, |
|
30 | - ?CacheDependencies $dependencies = null, |
|
31 | - ) { |
|
32 | - parent::__construct($cache, $dependencies); |
|
33 | - |
|
34 | - $this->unjailedRoot = $root; |
|
35 | - $parent = $cache; |
|
36 | - while ($parent instanceof CacheWrapper) { |
|
37 | - if ($parent instanceof CacheJail) { |
|
38 | - $this->unjailedRoot = $parent->getSourcePath($this->unjailedRoot); |
|
39 | - } |
|
40 | - $parent = $parent->getCache(); |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - protected function getRoot() { |
|
48 | - return $this->root; |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Get the root path with any nested jails resolved |
|
53 | - * |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function getGetUnjailedRoot() { |
|
57 | - return $this->unjailedRoot; |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - protected function getSourcePath(string $path) { |
|
64 | - if ($path === '') { |
|
65 | - return $this->getRoot(); |
|
66 | - } else { |
|
67 | - return $this->getRoot() . '/' . ltrim($path, '/'); |
|
68 | - } |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $path |
|
73 | - * @param null|string $root |
|
74 | - * @return null|string the jailed path or null if the path is outside the jail |
|
75 | - */ |
|
76 | - protected function getJailedPath(string $path, ?string $root = null) { |
|
77 | - if ($root === null) { |
|
78 | - $root = $this->getRoot(); |
|
79 | - } |
|
80 | - if ($root === '') { |
|
81 | - return $path; |
|
82 | - } |
|
83 | - $rootLength = strlen($root) + 1; |
|
84 | - if ($path === $root) { |
|
85 | - return ''; |
|
86 | - } elseif (substr($path, 0, $rootLength) === $root . '/') { |
|
87 | - return substr($path, $rootLength); |
|
88 | - } else { |
|
89 | - return null; |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - protected function formatCacheEntry($entry) { |
|
94 | - if (isset($entry['path'])) { |
|
95 | - $entry['path'] = $this->getJailedPath($entry['path']); |
|
96 | - } |
|
97 | - return $entry; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * get the stored metadata of a file or folder |
|
102 | - * |
|
103 | - * @param string|int $file |
|
104 | - * @return ICacheEntry|false |
|
105 | - */ |
|
106 | - public function get($file) { |
|
107 | - if (is_string($file) or $file == '') { |
|
108 | - $file = $this->getSourcePath($file); |
|
109 | - } |
|
110 | - return parent::get($file); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * insert meta data for a new file or folder |
|
115 | - * |
|
116 | - * @param string $file |
|
117 | - * @param array $data |
|
118 | - * |
|
119 | - * @return int file id |
|
120 | - * @throws \RuntimeException |
|
121 | - */ |
|
122 | - public function insert($file, array $data) { |
|
123 | - return $this->getCache()->insert($this->getSourcePath($file), $data); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * update the metadata in the cache |
|
128 | - * |
|
129 | - * @param int $id |
|
130 | - * @param array $data |
|
131 | - */ |
|
132 | - public function update($id, array $data) { |
|
133 | - $this->getCache()->update($id, $data); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * get the file id for a file |
|
138 | - * |
|
139 | - * @param string $file |
|
140 | - * @return int |
|
141 | - */ |
|
142 | - public function getId($file) { |
|
143 | - return $this->getCache()->getId($this->getSourcePath($file)); |
|
144 | - } |
|
145 | - |
|
146 | - /** |
|
147 | - * get the id of the parent folder of a file |
|
148 | - * |
|
149 | - * @param string $file |
|
150 | - * @return int |
|
151 | - */ |
|
152 | - public function getParentId($file) { |
|
153 | - return $this->getCache()->getParentId($this->getSourcePath($file)); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * check if a file is available in the cache |
|
158 | - * |
|
159 | - * @param string $file |
|
160 | - * @return bool |
|
161 | - */ |
|
162 | - public function inCache($file) { |
|
163 | - return $this->getCache()->inCache($this->getSourcePath($file)); |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * remove a file or folder from the cache |
|
168 | - * |
|
169 | - * @param string $file |
|
170 | - */ |
|
171 | - public function remove($file) { |
|
172 | - $this->getCache()->remove($this->getSourcePath($file)); |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Move a file or folder in the cache |
|
177 | - * |
|
178 | - * @param string $source |
|
179 | - * @param string $target |
|
180 | - */ |
|
181 | - public function move($source, $target) { |
|
182 | - $this->getCache()->move($this->getSourcePath($source), $this->getSourcePath($target)); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Get the storage id and path needed for a move |
|
187 | - * |
|
188 | - * @param string $path |
|
189 | - * @return array [$storageId, $internalPath] |
|
190 | - */ |
|
191 | - protected function getMoveInfo($path) { |
|
192 | - return [$this->getNumericStorageId(), $this->getSourcePath($path)]; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * remove all entries for files that are stored on the storage from the cache |
|
197 | - */ |
|
198 | - public function clear() { |
|
199 | - $this->getCache()->remove($this->getRoot()); |
|
200 | - } |
|
201 | - |
|
202 | - /** |
|
203 | - * @param string $file |
|
204 | - * |
|
205 | - * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE |
|
206 | - */ |
|
207 | - public function getStatus($file) { |
|
208 | - return $this->getCache()->getStatus($this->getSourcePath($file)); |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * update the folder size and the size of all parent folders |
|
213 | - * |
|
214 | - * @param array|ICacheEntry|null $data (optional) meta data of the folder |
|
215 | - */ |
|
216 | - public function correctFolderSize(string $path, $data = null, bool $isBackgroundScan = false): void { |
|
217 | - $cache = $this->getCache(); |
|
218 | - if ($cache instanceof Cache) { |
|
219 | - $cache->correctFolderSize($this->getSourcePath($path), $data, $isBackgroundScan); |
|
220 | - } |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * get the size of a folder and set it in the cache |
|
225 | - * |
|
226 | - * @param string $path |
|
227 | - * @param array|null|ICacheEntry $entry (optional) meta data of the folder |
|
228 | - * @return int|float |
|
229 | - */ |
|
230 | - public function calculateFolderSize($path, $entry = null) { |
|
231 | - $cache = $this->getCache(); |
|
232 | - if ($cache instanceof Cache) { |
|
233 | - return $cache->calculateFolderSize($this->getSourcePath($path), $entry); |
|
234 | - } else { |
|
235 | - return 0; |
|
236 | - } |
|
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * get all file ids on the files on the storage |
|
241 | - * |
|
242 | - * @return int[] |
|
243 | - */ |
|
244 | - public function getAll() { |
|
245 | - // not supported |
|
246 | - return []; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * find a folder in the cache which has not been fully scanned |
|
251 | - * |
|
252 | - * If multiply incomplete folders are in the cache, the one with the highest id will be returned, |
|
253 | - * use the one with the highest id gives the best result with the background scanner, since that is most |
|
254 | - * likely the folder where we stopped scanning previously |
|
255 | - * |
|
256 | - * @return string|false the path of the folder or false when no folder matched |
|
257 | - */ |
|
258 | - public function getIncomplete() { |
|
259 | - // not supported |
|
260 | - return false; |
|
261 | - } |
|
262 | - |
|
263 | - /** |
|
264 | - * get the path of a file on this storage by it's id |
|
265 | - * |
|
266 | - * @param int $id |
|
267 | - * @return string|null |
|
268 | - */ |
|
269 | - public function getPathById($id) { |
|
270 | - $path = $this->getCache()->getPathById($id); |
|
271 | - if ($path === null) { |
|
272 | - return null; |
|
273 | - } |
|
274 | - |
|
275 | - return $this->getJailedPath($path); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Move a file or folder in the cache |
|
280 | - * |
|
281 | - * Note that this should make sure the entries are removed from the source cache |
|
282 | - * |
|
283 | - * @param \OCP\Files\Cache\ICache $sourceCache |
|
284 | - * @param string $sourcePath |
|
285 | - * @param string $targetPath |
|
286 | - */ |
|
287 | - public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, $targetPath) { |
|
288 | - if ($sourceCache === $this) { |
|
289 | - return $this->move($sourcePath, $targetPath); |
|
290 | - } |
|
291 | - return $this->getCache()->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); |
|
292 | - } |
|
293 | - |
|
294 | - public function getQueryFilterForStorage(): ISearchOperator { |
|
295 | - return $this->addJailFilterQuery($this->getCache()->getQueryFilterForStorage()); |
|
296 | - } |
|
297 | - |
|
298 | - protected function addJailFilterQuery(ISearchOperator $filter): ISearchOperator { |
|
299 | - if ($this->getGetUnjailedRoot() !== '' && $this->getGetUnjailedRoot() !== '/') { |
|
300 | - return new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, |
|
301 | - [ |
|
302 | - $filter, |
|
303 | - new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, |
|
304 | - [ |
|
305 | - new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()), |
|
306 | - new SearchComparison(ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE, 'path', SearchComparison::escapeLikeParameter($this->getGetUnjailedRoot()) . '/%'), |
|
307 | - ], |
|
308 | - ) |
|
309 | - ] |
|
310 | - ); |
|
311 | - } else { |
|
312 | - return $filter; |
|
313 | - } |
|
314 | - } |
|
315 | - |
|
316 | - public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { |
|
317 | - if ($this->getGetUnjailedRoot() === '' || str_starts_with($rawEntry->getPath(), $this->getGetUnjailedRoot())) { |
|
318 | - $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); |
|
319 | - if ($rawEntry) { |
|
320 | - $jailedPath = $this->getJailedPath($rawEntry->getPath()); |
|
321 | - if ($jailedPath !== null) { |
|
322 | - return $this->formatCacheEntry(clone $rawEntry) ?: null; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
326 | - |
|
327 | - return null; |
|
328 | - } |
|
25 | + protected string $unjailedRoot; |
|
26 | + |
|
27 | + public function __construct( |
|
28 | + ?ICache $cache, |
|
29 | + protected string $root, |
|
30 | + ?CacheDependencies $dependencies = null, |
|
31 | + ) { |
|
32 | + parent::__construct($cache, $dependencies); |
|
33 | + |
|
34 | + $this->unjailedRoot = $root; |
|
35 | + $parent = $cache; |
|
36 | + while ($parent instanceof CacheWrapper) { |
|
37 | + if ($parent instanceof CacheJail) { |
|
38 | + $this->unjailedRoot = $parent->getSourcePath($this->unjailedRoot); |
|
39 | + } |
|
40 | + $parent = $parent->getCache(); |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + protected function getRoot() { |
|
48 | + return $this->root; |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Get the root path with any nested jails resolved |
|
53 | + * |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function getGetUnjailedRoot() { |
|
57 | + return $this->unjailedRoot; |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + protected function getSourcePath(string $path) { |
|
64 | + if ($path === '') { |
|
65 | + return $this->getRoot(); |
|
66 | + } else { |
|
67 | + return $this->getRoot() . '/' . ltrim($path, '/'); |
|
68 | + } |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $path |
|
73 | + * @param null|string $root |
|
74 | + * @return null|string the jailed path or null if the path is outside the jail |
|
75 | + */ |
|
76 | + protected function getJailedPath(string $path, ?string $root = null) { |
|
77 | + if ($root === null) { |
|
78 | + $root = $this->getRoot(); |
|
79 | + } |
|
80 | + if ($root === '') { |
|
81 | + return $path; |
|
82 | + } |
|
83 | + $rootLength = strlen($root) + 1; |
|
84 | + if ($path === $root) { |
|
85 | + return ''; |
|
86 | + } elseif (substr($path, 0, $rootLength) === $root . '/') { |
|
87 | + return substr($path, $rootLength); |
|
88 | + } else { |
|
89 | + return null; |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + protected function formatCacheEntry($entry) { |
|
94 | + if (isset($entry['path'])) { |
|
95 | + $entry['path'] = $this->getJailedPath($entry['path']); |
|
96 | + } |
|
97 | + return $entry; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * get the stored metadata of a file or folder |
|
102 | + * |
|
103 | + * @param string|int $file |
|
104 | + * @return ICacheEntry|false |
|
105 | + */ |
|
106 | + public function get($file) { |
|
107 | + if (is_string($file) or $file == '') { |
|
108 | + $file = $this->getSourcePath($file); |
|
109 | + } |
|
110 | + return parent::get($file); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * insert meta data for a new file or folder |
|
115 | + * |
|
116 | + * @param string $file |
|
117 | + * @param array $data |
|
118 | + * |
|
119 | + * @return int file id |
|
120 | + * @throws \RuntimeException |
|
121 | + */ |
|
122 | + public function insert($file, array $data) { |
|
123 | + return $this->getCache()->insert($this->getSourcePath($file), $data); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * update the metadata in the cache |
|
128 | + * |
|
129 | + * @param int $id |
|
130 | + * @param array $data |
|
131 | + */ |
|
132 | + public function update($id, array $data) { |
|
133 | + $this->getCache()->update($id, $data); |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * get the file id for a file |
|
138 | + * |
|
139 | + * @param string $file |
|
140 | + * @return int |
|
141 | + */ |
|
142 | + public function getId($file) { |
|
143 | + return $this->getCache()->getId($this->getSourcePath($file)); |
|
144 | + } |
|
145 | + |
|
146 | + /** |
|
147 | + * get the id of the parent folder of a file |
|
148 | + * |
|
149 | + * @param string $file |
|
150 | + * @return int |
|
151 | + */ |
|
152 | + public function getParentId($file) { |
|
153 | + return $this->getCache()->getParentId($this->getSourcePath($file)); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * check if a file is available in the cache |
|
158 | + * |
|
159 | + * @param string $file |
|
160 | + * @return bool |
|
161 | + */ |
|
162 | + public function inCache($file) { |
|
163 | + return $this->getCache()->inCache($this->getSourcePath($file)); |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * remove a file or folder from the cache |
|
168 | + * |
|
169 | + * @param string $file |
|
170 | + */ |
|
171 | + public function remove($file) { |
|
172 | + $this->getCache()->remove($this->getSourcePath($file)); |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Move a file or folder in the cache |
|
177 | + * |
|
178 | + * @param string $source |
|
179 | + * @param string $target |
|
180 | + */ |
|
181 | + public function move($source, $target) { |
|
182 | + $this->getCache()->move($this->getSourcePath($source), $this->getSourcePath($target)); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Get the storage id and path needed for a move |
|
187 | + * |
|
188 | + * @param string $path |
|
189 | + * @return array [$storageId, $internalPath] |
|
190 | + */ |
|
191 | + protected function getMoveInfo($path) { |
|
192 | + return [$this->getNumericStorageId(), $this->getSourcePath($path)]; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * remove all entries for files that are stored on the storage from the cache |
|
197 | + */ |
|
198 | + public function clear() { |
|
199 | + $this->getCache()->remove($this->getRoot()); |
|
200 | + } |
|
201 | + |
|
202 | + /** |
|
203 | + * @param string $file |
|
204 | + * |
|
205 | + * @return int Cache::NOT_FOUND, Cache::PARTIAL, Cache::SHALLOW or Cache::COMPLETE |
|
206 | + */ |
|
207 | + public function getStatus($file) { |
|
208 | + return $this->getCache()->getStatus($this->getSourcePath($file)); |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * update the folder size and the size of all parent folders |
|
213 | + * |
|
214 | + * @param array|ICacheEntry|null $data (optional) meta data of the folder |
|
215 | + */ |
|
216 | + public function correctFolderSize(string $path, $data = null, bool $isBackgroundScan = false): void { |
|
217 | + $cache = $this->getCache(); |
|
218 | + if ($cache instanceof Cache) { |
|
219 | + $cache->correctFolderSize($this->getSourcePath($path), $data, $isBackgroundScan); |
|
220 | + } |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * get the size of a folder and set it in the cache |
|
225 | + * |
|
226 | + * @param string $path |
|
227 | + * @param array|null|ICacheEntry $entry (optional) meta data of the folder |
|
228 | + * @return int|float |
|
229 | + */ |
|
230 | + public function calculateFolderSize($path, $entry = null) { |
|
231 | + $cache = $this->getCache(); |
|
232 | + if ($cache instanceof Cache) { |
|
233 | + return $cache->calculateFolderSize($this->getSourcePath($path), $entry); |
|
234 | + } else { |
|
235 | + return 0; |
|
236 | + } |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * get all file ids on the files on the storage |
|
241 | + * |
|
242 | + * @return int[] |
|
243 | + */ |
|
244 | + public function getAll() { |
|
245 | + // not supported |
|
246 | + return []; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * find a folder in the cache which has not been fully scanned |
|
251 | + * |
|
252 | + * If multiply incomplete folders are in the cache, the one with the highest id will be returned, |
|
253 | + * use the one with the highest id gives the best result with the background scanner, since that is most |
|
254 | + * likely the folder where we stopped scanning previously |
|
255 | + * |
|
256 | + * @return string|false the path of the folder or false when no folder matched |
|
257 | + */ |
|
258 | + public function getIncomplete() { |
|
259 | + // not supported |
|
260 | + return false; |
|
261 | + } |
|
262 | + |
|
263 | + /** |
|
264 | + * get the path of a file on this storage by it's id |
|
265 | + * |
|
266 | + * @param int $id |
|
267 | + * @return string|null |
|
268 | + */ |
|
269 | + public function getPathById($id) { |
|
270 | + $path = $this->getCache()->getPathById($id); |
|
271 | + if ($path === null) { |
|
272 | + return null; |
|
273 | + } |
|
274 | + |
|
275 | + return $this->getJailedPath($path); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Move a file or folder in the cache |
|
280 | + * |
|
281 | + * Note that this should make sure the entries are removed from the source cache |
|
282 | + * |
|
283 | + * @param \OCP\Files\Cache\ICache $sourceCache |
|
284 | + * @param string $sourcePath |
|
285 | + * @param string $targetPath |
|
286 | + */ |
|
287 | + public function moveFromCache(\OCP\Files\Cache\ICache $sourceCache, $sourcePath, $targetPath) { |
|
288 | + if ($sourceCache === $this) { |
|
289 | + return $this->move($sourcePath, $targetPath); |
|
290 | + } |
|
291 | + return $this->getCache()->moveFromCache($sourceCache, $sourcePath, $this->getSourcePath($targetPath)); |
|
292 | + } |
|
293 | + |
|
294 | + public function getQueryFilterForStorage(): ISearchOperator { |
|
295 | + return $this->addJailFilterQuery($this->getCache()->getQueryFilterForStorage()); |
|
296 | + } |
|
297 | + |
|
298 | + protected function addJailFilterQuery(ISearchOperator $filter): ISearchOperator { |
|
299 | + if ($this->getGetUnjailedRoot() !== '' && $this->getGetUnjailedRoot() !== '/') { |
|
300 | + return new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_AND, |
|
301 | + [ |
|
302 | + $filter, |
|
303 | + new SearchBinaryOperator(ISearchBinaryOperator::OPERATOR_OR, |
|
304 | + [ |
|
305 | + new SearchComparison(ISearchComparison::COMPARE_EQUAL, 'path', $this->getGetUnjailedRoot()), |
|
306 | + new SearchComparison(ISearchComparison::COMPARE_LIKE_CASE_SENSITIVE, 'path', SearchComparison::escapeLikeParameter($this->getGetUnjailedRoot()) . '/%'), |
|
307 | + ], |
|
308 | + ) |
|
309 | + ] |
|
310 | + ); |
|
311 | + } else { |
|
312 | + return $filter; |
|
313 | + } |
|
314 | + } |
|
315 | + |
|
316 | + public function getCacheEntryFromSearchResult(ICacheEntry $rawEntry): ?ICacheEntry { |
|
317 | + if ($this->getGetUnjailedRoot() === '' || str_starts_with($rawEntry->getPath(), $this->getGetUnjailedRoot())) { |
|
318 | + $rawEntry = $this->getCache()->getCacheEntryFromSearchResult($rawEntry); |
|
319 | + if ($rawEntry) { |
|
320 | + $jailedPath = $this->getJailedPath($rawEntry->getPath()); |
|
321 | + if ($jailedPath !== null) { |
|
322 | + return $this->formatCacheEntry(clone $rawEntry) ?: null; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | + |
|
327 | + return null; |
|
328 | + } |
|
329 | 329 | } |
@@ -28,12 +28,12 @@ |
||
28 | 28 | * @since 14.0.0 |
29 | 29 | */ |
30 | 30 | interface IWriter { |
31 | - /** |
|
32 | - * @since 14.0.0 |
|
33 | - * |
|
34 | - * @param string $app |
|
35 | - * @param string|array $message |
|
36 | - * @param int $level |
|
37 | - */ |
|
38 | - public function write(string $app, $message, int $level); |
|
31 | + /** |
|
32 | + * @since 14.0.0 |
|
33 | + * |
|
34 | + * @param string $app |
|
35 | + * @param string|array $message |
|
36 | + * @param int $level |
|
37 | + */ |
|
38 | + public function write(string $app, $message, int $level); |
|
39 | 39 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | </div> |
27 | 27 | </fieldset> |
28 | 28 | <fieldset> |
29 | - <input type="submit" value="<?php p($l->t('Save'));?>"> |
|
29 | + <input type="submit" value="<?php p($l->t('Save')); ?>"> |
|
30 | 30 | </fieldset> |
31 | 31 | </form> |
32 | 32 | </div> |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | private function filterTrace(array $trace) { |
190 | 190 | $sensitiveValues = []; |
191 | - $trace = array_map(function (array $traceLine) use (&$sensitiveValues) { |
|
191 | + $trace = array_map(function(array $traceLine) use (&$sensitiveValues) { |
|
192 | 192 | $className = $traceLine['class'] ?? ''; |
193 | 193 | if ($className && isset($this->methodsWithSensitiveParametersByClass[$className]) |
194 | 194 | && in_array($traceLine['function'], $this->methodsWithSensitiveParametersByClass[$className], true)) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | return $traceLine; |
203 | 203 | }, $trace); |
204 | - return array_map(function (array $traceLine) use ($sensitiveValues) { |
|
204 | + return array_map(function(array $traceLine) use ($sensitiveValues) { |
|
205 | 205 | if (isset($traceLine['args'])) { |
206 | 206 | $traceLine['args'] = $this->removeValuesFromArgs($traceLine['args'], $sensitiveValues); |
207 | 207 | } |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | private function encodeTrace($trace) { |
226 | - $trace = array_map(function (array $line) { |
|
226 | + $trace = array_map(function(array $line) { |
|
227 | 227 | if (isset($line['args'])) { |
228 | 228 | $line['args'] = array_map([$this, 'encodeArg'], $line['args']); |
229 | 229 | } |
@@ -241,9 +241,9 @@ discard block |
||
241 | 241 | ]; |
242 | 242 | } |
243 | 243 | |
244 | - $objectInfo = [ '__class__' => get_class($arg) ]; |
|
244 | + $objectInfo = ['__class__' => get_class($arg)]; |
|
245 | 245 | $objectVars = get_object_vars($arg); |
246 | - return array_map(function ($arg) use ($nestingLevel) { |
|
246 | + return array_map(function($arg) use ($nestingLevel) { |
|
247 | 247 | return $this->encodeArg($arg, $nestingLevel - 1); |
248 | 248 | }, array_merge($objectInfo, $objectVars)); |
249 | 249 | } |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | } |
255 | 255 | |
256 | 256 | // Only log the first 5 elements of an array unless we are on debug |
257 | - if ((int)$this->systemConfig->getValue('loglevel', 2) !== 0) { |
|
257 | + if ((int) $this->systemConfig->getValue('loglevel', 2) !== 0) { |
|
258 | 258 | $elemCount = count($arg); |
259 | 259 | if ($elemCount > 5) { |
260 | 260 | $arg = array_slice($arg, 0, 5); |
261 | - $arg[] = 'And ' . ($elemCount - 5) . ' more entries, set log level to debug to see all entries'; |
|
261 | + $arg[] = 'And '.($elemCount - 5).' more entries, set log level to debug to see all entries'; |
|
262 | 262 | } |
263 | 263 | } |
264 | - return array_map(function ($e) use ($nestingLevel) { |
|
264 | + return array_map(function($e) use ($nestingLevel) { |
|
265 | 265 | return $this->encodeArg($e, $nestingLevel - 1); |
266 | 266 | }, $arg); |
267 | 267 | } |
@@ -21,287 +21,287 @@ |
||
21 | 21 | use OCP\HintException; |
22 | 22 | |
23 | 23 | class ExceptionSerializer { |
24 | - public const SENSITIVE_VALUE_PLACEHOLDER = '*** sensitive parameters replaced ***'; |
|
24 | + public const SENSITIVE_VALUE_PLACEHOLDER = '*** sensitive parameters replaced ***'; |
|
25 | 25 | |
26 | - public const methodsWithSensitiveParameters = [ |
|
27 | - // Session/User |
|
28 | - 'completeLogin', |
|
29 | - 'login', |
|
30 | - 'checkPassword', |
|
31 | - 'checkPasswordNoLogging', |
|
32 | - 'loginWithPassword', |
|
33 | - 'updatePrivateKeyPassword', |
|
34 | - 'validateUserPass', |
|
35 | - 'loginWithToken', |
|
36 | - '{closure}', |
|
37 | - '{closure:*', |
|
38 | - 'createSessionToken', |
|
26 | + public const methodsWithSensitiveParameters = [ |
|
27 | + // Session/User |
|
28 | + 'completeLogin', |
|
29 | + 'login', |
|
30 | + 'checkPassword', |
|
31 | + 'checkPasswordNoLogging', |
|
32 | + 'loginWithPassword', |
|
33 | + 'updatePrivateKeyPassword', |
|
34 | + 'validateUserPass', |
|
35 | + 'loginWithToken', |
|
36 | + '{closure}', |
|
37 | + '{closure:*', |
|
38 | + 'createSessionToken', |
|
39 | 39 | |
40 | - // Provisioning |
|
41 | - 'addUser', |
|
40 | + // Provisioning |
|
41 | + 'addUser', |
|
42 | 42 | |
43 | - // TokenProvider |
|
44 | - 'getToken', |
|
45 | - 'isTokenPassword', |
|
46 | - 'getPassword', |
|
47 | - 'decryptPassword', |
|
48 | - 'logClientIn', |
|
49 | - 'generateToken', |
|
50 | - 'validateToken', |
|
43 | + // TokenProvider |
|
44 | + 'getToken', |
|
45 | + 'isTokenPassword', |
|
46 | + 'getPassword', |
|
47 | + 'decryptPassword', |
|
48 | + 'logClientIn', |
|
49 | + 'generateToken', |
|
50 | + 'validateToken', |
|
51 | 51 | |
52 | - // TwoFactorAuth |
|
53 | - 'solveChallenge', |
|
54 | - 'verifyChallenge', |
|
52 | + // TwoFactorAuth |
|
53 | + 'solveChallenge', |
|
54 | + 'verifyChallenge', |
|
55 | 55 | |
56 | - // ICrypto |
|
57 | - 'calculateHMAC', |
|
58 | - 'encrypt', |
|
59 | - 'decrypt', |
|
56 | + // ICrypto |
|
57 | + 'calculateHMAC', |
|
58 | + 'encrypt', |
|
59 | + 'decrypt', |
|
60 | 60 | |
61 | - // LoginController |
|
62 | - 'tryLogin', |
|
63 | - 'confirmPassword', |
|
61 | + // LoginController |
|
62 | + 'tryLogin', |
|
63 | + 'confirmPassword', |
|
64 | 64 | |
65 | - // LDAP |
|
66 | - 'bind', |
|
67 | - 'areCredentialsValid', |
|
68 | - 'invokeLDAPMethod', |
|
65 | + // LDAP |
|
66 | + 'bind', |
|
67 | + 'areCredentialsValid', |
|
68 | + 'invokeLDAPMethod', |
|
69 | 69 | |
70 | - // Encryption |
|
71 | - 'storeKeyPair', |
|
72 | - 'setupUser', |
|
73 | - 'checkSignature', |
|
70 | + // Encryption |
|
71 | + 'storeKeyPair', |
|
72 | + 'setupUser', |
|
73 | + 'checkSignature', |
|
74 | 74 | |
75 | - // files_external: OCA\Files_External\MountConfig |
|
76 | - 'getBackendStatus', |
|
75 | + // files_external: OCA\Files_External\MountConfig |
|
76 | + 'getBackendStatus', |
|
77 | 77 | |
78 | - // files_external: UserStoragesController |
|
79 | - 'update', |
|
78 | + // files_external: UserStoragesController |
|
79 | + 'update', |
|
80 | 80 | |
81 | - // Preview providers, don't log big data strings |
|
82 | - 'imagecreatefromstring', |
|
81 | + // Preview providers, don't log big data strings |
|
82 | + 'imagecreatefromstring', |
|
83 | 83 | |
84 | - // text: PublicSessionController, SessionController and ApiService |
|
85 | - 'create', |
|
86 | - 'close', |
|
87 | - 'push', |
|
88 | - 'sync', |
|
89 | - 'updateSession', |
|
90 | - 'mention', |
|
91 | - 'loginSessionUser', |
|
84 | + // text: PublicSessionController, SessionController and ApiService |
|
85 | + 'create', |
|
86 | + 'close', |
|
87 | + 'push', |
|
88 | + 'sync', |
|
89 | + 'updateSession', |
|
90 | + 'mention', |
|
91 | + 'loginSessionUser', |
|
92 | 92 | |
93 | - ]; |
|
93 | + ]; |
|
94 | 94 | |
95 | - public function __construct( |
|
96 | - private SystemConfig $systemConfig, |
|
97 | - ) { |
|
98 | - } |
|
95 | + public function __construct( |
|
96 | + private SystemConfig $systemConfig, |
|
97 | + ) { |
|
98 | + } |
|
99 | 99 | |
100 | - protected array $methodsWithSensitiveParametersByClass = [ |
|
101 | - SetupController::class => [ |
|
102 | - 'run', |
|
103 | - 'display', |
|
104 | - 'loadAutoConfig', |
|
105 | - ], |
|
106 | - Setup::class => [ |
|
107 | - 'install' |
|
108 | - ], |
|
109 | - Key::class => [ |
|
110 | - '__construct' |
|
111 | - ], |
|
112 | - Client::class => [ |
|
113 | - 'request', |
|
114 | - 'delete', |
|
115 | - 'deleteAsync', |
|
116 | - 'get', |
|
117 | - 'getAsync', |
|
118 | - 'head', |
|
119 | - 'headAsync', |
|
120 | - 'options', |
|
121 | - 'optionsAsync', |
|
122 | - 'patch', |
|
123 | - 'post', |
|
124 | - 'postAsync', |
|
125 | - 'put', |
|
126 | - 'putAsync', |
|
127 | - ], |
|
128 | - \Redis::class => [ |
|
129 | - 'auth' |
|
130 | - ], |
|
131 | - \RedisCluster::class => [ |
|
132 | - '__construct' |
|
133 | - ], |
|
134 | - Crypt::class => [ |
|
135 | - 'symmetricEncryptFileContent', |
|
136 | - 'encrypt', |
|
137 | - 'generatePasswordHash', |
|
138 | - 'encryptPrivateKey', |
|
139 | - 'decryptPrivateKey', |
|
140 | - 'isValidPrivateKey', |
|
141 | - 'symmetricDecryptFileContent', |
|
142 | - 'checkSignature', |
|
143 | - 'createSignature', |
|
144 | - 'decrypt', |
|
145 | - 'multiKeyDecrypt', |
|
146 | - 'multiKeyEncrypt', |
|
147 | - ], |
|
148 | - RecoveryController::class => [ |
|
149 | - 'adminRecovery', |
|
150 | - 'changeRecoveryPassword' |
|
151 | - ], |
|
152 | - SettingsController::class => [ |
|
153 | - 'updatePrivateKeyPassword', |
|
154 | - ], |
|
155 | - Encryption::class => [ |
|
156 | - 'encrypt', |
|
157 | - 'decrypt', |
|
158 | - ], |
|
159 | - KeyManager::class => [ |
|
160 | - 'checkRecoveryPassword', |
|
161 | - 'storeKeyPair', |
|
162 | - 'setRecoveryKey', |
|
163 | - 'setPrivateKey', |
|
164 | - 'setFileKey', |
|
165 | - 'setAllFileKeys', |
|
166 | - ], |
|
167 | - Session::class => [ |
|
168 | - 'setPrivateKey', |
|
169 | - 'prepareDecryptAll', |
|
170 | - ], |
|
171 | - \OCA\Encryption\Users\Setup::class => [ |
|
172 | - 'setupUser', |
|
173 | - ], |
|
174 | - UserEventsListener::class => [ |
|
175 | - 'handle', |
|
176 | - 'onUserCreated', |
|
177 | - 'onUserLogin', |
|
178 | - 'onBeforePasswordUpdated', |
|
179 | - 'onPasswordUpdated', |
|
180 | - 'onPasswordReset', |
|
181 | - ], |
|
182 | - PassphraseService::class => [ |
|
183 | - 'setPassphraseForUser', |
|
184 | - ], |
|
185 | - ]; |
|
100 | + protected array $methodsWithSensitiveParametersByClass = [ |
|
101 | + SetupController::class => [ |
|
102 | + 'run', |
|
103 | + 'display', |
|
104 | + 'loadAutoConfig', |
|
105 | + ], |
|
106 | + Setup::class => [ |
|
107 | + 'install' |
|
108 | + ], |
|
109 | + Key::class => [ |
|
110 | + '__construct' |
|
111 | + ], |
|
112 | + Client::class => [ |
|
113 | + 'request', |
|
114 | + 'delete', |
|
115 | + 'deleteAsync', |
|
116 | + 'get', |
|
117 | + 'getAsync', |
|
118 | + 'head', |
|
119 | + 'headAsync', |
|
120 | + 'options', |
|
121 | + 'optionsAsync', |
|
122 | + 'patch', |
|
123 | + 'post', |
|
124 | + 'postAsync', |
|
125 | + 'put', |
|
126 | + 'putAsync', |
|
127 | + ], |
|
128 | + \Redis::class => [ |
|
129 | + 'auth' |
|
130 | + ], |
|
131 | + \RedisCluster::class => [ |
|
132 | + '__construct' |
|
133 | + ], |
|
134 | + Crypt::class => [ |
|
135 | + 'symmetricEncryptFileContent', |
|
136 | + 'encrypt', |
|
137 | + 'generatePasswordHash', |
|
138 | + 'encryptPrivateKey', |
|
139 | + 'decryptPrivateKey', |
|
140 | + 'isValidPrivateKey', |
|
141 | + 'symmetricDecryptFileContent', |
|
142 | + 'checkSignature', |
|
143 | + 'createSignature', |
|
144 | + 'decrypt', |
|
145 | + 'multiKeyDecrypt', |
|
146 | + 'multiKeyEncrypt', |
|
147 | + ], |
|
148 | + RecoveryController::class => [ |
|
149 | + 'adminRecovery', |
|
150 | + 'changeRecoveryPassword' |
|
151 | + ], |
|
152 | + SettingsController::class => [ |
|
153 | + 'updatePrivateKeyPassword', |
|
154 | + ], |
|
155 | + Encryption::class => [ |
|
156 | + 'encrypt', |
|
157 | + 'decrypt', |
|
158 | + ], |
|
159 | + KeyManager::class => [ |
|
160 | + 'checkRecoveryPassword', |
|
161 | + 'storeKeyPair', |
|
162 | + 'setRecoveryKey', |
|
163 | + 'setPrivateKey', |
|
164 | + 'setFileKey', |
|
165 | + 'setAllFileKeys', |
|
166 | + ], |
|
167 | + Session::class => [ |
|
168 | + 'setPrivateKey', |
|
169 | + 'prepareDecryptAll', |
|
170 | + ], |
|
171 | + \OCA\Encryption\Users\Setup::class => [ |
|
172 | + 'setupUser', |
|
173 | + ], |
|
174 | + UserEventsListener::class => [ |
|
175 | + 'handle', |
|
176 | + 'onUserCreated', |
|
177 | + 'onUserLogin', |
|
178 | + 'onBeforePasswordUpdated', |
|
179 | + 'onPasswordUpdated', |
|
180 | + 'onPasswordReset', |
|
181 | + ], |
|
182 | + PassphraseService::class => [ |
|
183 | + 'setPassphraseForUser', |
|
184 | + ], |
|
185 | + ]; |
|
186 | 186 | |
187 | - private function editTrace(array &$sensitiveValues, array $traceLine): array { |
|
188 | - if (isset($traceLine['args'])) { |
|
189 | - $sensitiveValues = array_merge($sensitiveValues, $traceLine['args']); |
|
190 | - } |
|
191 | - $traceLine['args'] = [self::SENSITIVE_VALUE_PLACEHOLDER]; |
|
192 | - return $traceLine; |
|
193 | - } |
|
187 | + private function editTrace(array &$sensitiveValues, array $traceLine): array { |
|
188 | + if (isset($traceLine['args'])) { |
|
189 | + $sensitiveValues = array_merge($sensitiveValues, $traceLine['args']); |
|
190 | + } |
|
191 | + $traceLine['args'] = [self::SENSITIVE_VALUE_PLACEHOLDER]; |
|
192 | + return $traceLine; |
|
193 | + } |
|
194 | 194 | |
195 | - private function filterTrace(array $trace) { |
|
196 | - $sensitiveValues = []; |
|
197 | - $trace = array_map(function (array $traceLine) use (&$sensitiveValues) { |
|
198 | - $className = $traceLine['class'] ?? ''; |
|
199 | - if ($className && isset($this->methodsWithSensitiveParametersByClass[$className]) |
|
200 | - && in_array($traceLine['function'], $this->methodsWithSensitiveParametersByClass[$className], true)) { |
|
201 | - return $this->editTrace($sensitiveValues, $traceLine); |
|
202 | - } |
|
203 | - foreach (self::methodsWithSensitiveParameters as $sensitiveMethod) { |
|
204 | - if (str_contains($traceLine['function'], $sensitiveMethod) |
|
205 | - || (str_ends_with($sensitiveMethod, '*') |
|
206 | - && str_starts_with($traceLine['function'], substr($sensitiveMethod, 0, -1)))) { |
|
207 | - return $this->editTrace($sensitiveValues, $traceLine); |
|
208 | - } |
|
209 | - } |
|
210 | - return $traceLine; |
|
211 | - }, $trace); |
|
212 | - return array_map(function (array $traceLine) use ($sensitiveValues) { |
|
213 | - if (isset($traceLine['args'])) { |
|
214 | - $traceLine['args'] = $this->removeValuesFromArgs($traceLine['args'], $sensitiveValues); |
|
215 | - } |
|
216 | - return $traceLine; |
|
217 | - }, $trace); |
|
218 | - } |
|
195 | + private function filterTrace(array $trace) { |
|
196 | + $sensitiveValues = []; |
|
197 | + $trace = array_map(function (array $traceLine) use (&$sensitiveValues) { |
|
198 | + $className = $traceLine['class'] ?? ''; |
|
199 | + if ($className && isset($this->methodsWithSensitiveParametersByClass[$className]) |
|
200 | + && in_array($traceLine['function'], $this->methodsWithSensitiveParametersByClass[$className], true)) { |
|
201 | + return $this->editTrace($sensitiveValues, $traceLine); |
|
202 | + } |
|
203 | + foreach (self::methodsWithSensitiveParameters as $sensitiveMethod) { |
|
204 | + if (str_contains($traceLine['function'], $sensitiveMethod) |
|
205 | + || (str_ends_with($sensitiveMethod, '*') |
|
206 | + && str_starts_with($traceLine['function'], substr($sensitiveMethod, 0, -1)))) { |
|
207 | + return $this->editTrace($sensitiveValues, $traceLine); |
|
208 | + } |
|
209 | + } |
|
210 | + return $traceLine; |
|
211 | + }, $trace); |
|
212 | + return array_map(function (array $traceLine) use ($sensitiveValues) { |
|
213 | + if (isset($traceLine['args'])) { |
|
214 | + $traceLine['args'] = $this->removeValuesFromArgs($traceLine['args'], $sensitiveValues); |
|
215 | + } |
|
216 | + return $traceLine; |
|
217 | + }, $trace); |
|
218 | + } |
|
219 | 219 | |
220 | - private function removeValuesFromArgs($args, $values): array { |
|
221 | - $workArgs = []; |
|
222 | - foreach ($args as $key => $arg) { |
|
223 | - if (in_array($arg, $values, true)) { |
|
224 | - $arg = self::SENSITIVE_VALUE_PLACEHOLDER; |
|
225 | - } elseif (is_array($arg)) { |
|
226 | - $arg = $this->removeValuesFromArgs($arg, $values); |
|
227 | - } |
|
228 | - $workArgs[$key] = $arg; |
|
229 | - } |
|
230 | - return $workArgs; |
|
231 | - } |
|
220 | + private function removeValuesFromArgs($args, $values): array { |
|
221 | + $workArgs = []; |
|
222 | + foreach ($args as $key => $arg) { |
|
223 | + if (in_array($arg, $values, true)) { |
|
224 | + $arg = self::SENSITIVE_VALUE_PLACEHOLDER; |
|
225 | + } elseif (is_array($arg)) { |
|
226 | + $arg = $this->removeValuesFromArgs($arg, $values); |
|
227 | + } |
|
228 | + $workArgs[$key] = $arg; |
|
229 | + } |
|
230 | + return $workArgs; |
|
231 | + } |
|
232 | 232 | |
233 | - private function encodeTrace($trace) { |
|
234 | - $trace = array_map(function (array $line) { |
|
235 | - if (isset($line['args'])) { |
|
236 | - $line['args'] = array_map([$this, 'encodeArg'], $line['args']); |
|
237 | - } |
|
238 | - return $line; |
|
239 | - }, $trace); |
|
240 | - return $this->filterTrace($trace); |
|
241 | - } |
|
233 | + private function encodeTrace($trace) { |
|
234 | + $trace = array_map(function (array $line) { |
|
235 | + if (isset($line['args'])) { |
|
236 | + $line['args'] = array_map([$this, 'encodeArg'], $line['args']); |
|
237 | + } |
|
238 | + return $line; |
|
239 | + }, $trace); |
|
240 | + return $this->filterTrace($trace); |
|
241 | + } |
|
242 | 242 | |
243 | - private function encodeArg($arg, $nestingLevel = 5) { |
|
244 | - if (is_object($arg)) { |
|
245 | - if ($nestingLevel === 0) { |
|
246 | - return [ |
|
247 | - '__class__' => get_class($arg), |
|
248 | - '__properties__' => 'Encoding skipped as the maximum nesting level was reached', |
|
249 | - ]; |
|
250 | - } |
|
243 | + private function encodeArg($arg, $nestingLevel = 5) { |
|
244 | + if (is_object($arg)) { |
|
245 | + if ($nestingLevel === 0) { |
|
246 | + return [ |
|
247 | + '__class__' => get_class($arg), |
|
248 | + '__properties__' => 'Encoding skipped as the maximum nesting level was reached', |
|
249 | + ]; |
|
250 | + } |
|
251 | 251 | |
252 | - $objectInfo = [ '__class__' => get_class($arg) ]; |
|
253 | - $objectVars = get_object_vars($arg); |
|
254 | - return array_map(function ($arg) use ($nestingLevel) { |
|
255 | - return $this->encodeArg($arg, $nestingLevel - 1); |
|
256 | - }, array_merge($objectInfo, $objectVars)); |
|
257 | - } |
|
252 | + $objectInfo = [ '__class__' => get_class($arg) ]; |
|
253 | + $objectVars = get_object_vars($arg); |
|
254 | + return array_map(function ($arg) use ($nestingLevel) { |
|
255 | + return $this->encodeArg($arg, $nestingLevel - 1); |
|
256 | + }, array_merge($objectInfo, $objectVars)); |
|
257 | + } |
|
258 | 258 | |
259 | - if (is_array($arg)) { |
|
260 | - if ($nestingLevel === 0) { |
|
261 | - return ['Encoding skipped as the maximum nesting level was reached']; |
|
262 | - } |
|
259 | + if (is_array($arg)) { |
|
260 | + if ($nestingLevel === 0) { |
|
261 | + return ['Encoding skipped as the maximum nesting level was reached']; |
|
262 | + } |
|
263 | 263 | |
264 | - // Only log the first 5 elements of an array unless we are on debug |
|
265 | - if ((int)$this->systemConfig->getValue('loglevel', 2) !== 0) { |
|
266 | - $elemCount = count($arg); |
|
267 | - if ($elemCount > 5) { |
|
268 | - $arg = array_slice($arg, 0, 5); |
|
269 | - $arg[] = 'And ' . ($elemCount - 5) . ' more entries, set log level to debug to see all entries'; |
|
270 | - } |
|
271 | - } |
|
272 | - return array_map(function ($e) use ($nestingLevel) { |
|
273 | - return $this->encodeArg($e, $nestingLevel - 1); |
|
274 | - }, $arg); |
|
275 | - } |
|
264 | + // Only log the first 5 elements of an array unless we are on debug |
|
265 | + if ((int)$this->systemConfig->getValue('loglevel', 2) !== 0) { |
|
266 | + $elemCount = count($arg); |
|
267 | + if ($elemCount > 5) { |
|
268 | + $arg = array_slice($arg, 0, 5); |
|
269 | + $arg[] = 'And ' . ($elemCount - 5) . ' more entries, set log level to debug to see all entries'; |
|
270 | + } |
|
271 | + } |
|
272 | + return array_map(function ($e) use ($nestingLevel) { |
|
273 | + return $this->encodeArg($e, $nestingLevel - 1); |
|
274 | + }, $arg); |
|
275 | + } |
|
276 | 276 | |
277 | - return $arg; |
|
278 | - } |
|
277 | + return $arg; |
|
278 | + } |
|
279 | 279 | |
280 | - public function serializeException(\Throwable $exception): array { |
|
281 | - $data = [ |
|
282 | - 'Exception' => get_class($exception), |
|
283 | - 'Message' => $exception->getMessage(), |
|
284 | - 'Code' => $exception->getCode(), |
|
285 | - 'Trace' => $this->encodeTrace($exception->getTrace()), |
|
286 | - 'File' => $exception->getFile(), |
|
287 | - 'Line' => $exception->getLine(), |
|
288 | - ]; |
|
280 | + public function serializeException(\Throwable $exception): array { |
|
281 | + $data = [ |
|
282 | + 'Exception' => get_class($exception), |
|
283 | + 'Message' => $exception->getMessage(), |
|
284 | + 'Code' => $exception->getCode(), |
|
285 | + 'Trace' => $this->encodeTrace($exception->getTrace()), |
|
286 | + 'File' => $exception->getFile(), |
|
287 | + 'Line' => $exception->getLine(), |
|
288 | + ]; |
|
289 | 289 | |
290 | - if ($exception instanceof HintException) { |
|
291 | - $data['Hint'] = $exception->getHint(); |
|
292 | - } |
|
290 | + if ($exception instanceof HintException) { |
|
291 | + $data['Hint'] = $exception->getHint(); |
|
292 | + } |
|
293 | 293 | |
294 | - if ($exception->getPrevious()) { |
|
295 | - $data['Previous'] = $this->serializeException($exception->getPrevious()); |
|
296 | - } |
|
294 | + if ($exception->getPrevious()) { |
|
295 | + $data['Previous'] = $this->serializeException($exception->getPrevious()); |
|
296 | + } |
|
297 | 297 | |
298 | - return $data; |
|
299 | - } |
|
298 | + return $data; |
|
299 | + } |
|
300 | 300 | |
301 | - public function enlistSensitiveMethods(string $class, array $methods): void { |
|
302 | - if (!isset($this->methodsWithSensitiveParametersByClass[$class])) { |
|
303 | - $this->methodsWithSensitiveParametersByClass[$class] = []; |
|
304 | - } |
|
305 | - $this->methodsWithSensitiveParametersByClass[$class] = array_merge($this->methodsWithSensitiveParametersByClass[$class], $methods); |
|
306 | - } |
|
301 | + public function enlistSensitiveMethods(string $class, array $methods): void { |
|
302 | + if (!isset($this->methodsWithSensitiveParametersByClass[$class])) { |
|
303 | + $this->methodsWithSensitiveParametersByClass[$class] = []; |
|
304 | + } |
|
305 | + $this->methodsWithSensitiveParametersByClass[$class] = array_merge($this->methodsWithSensitiveParametersByClass[$class], $methods); |
|
306 | + } |
|
307 | 307 | } |
@@ -167,7 +167,7 @@ |
||
167 | 167 | * @return bool |
168 | 168 | */ |
169 | 169 | public function isFlagSet(int $flag): bool { |
170 | - return (bool)($this->flags & $flag); |
|
170 | + return (bool) ($this->flags & $flag); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -10,207 +10,207 @@ |
||
10 | 10 | * Parameter for an external storage definition |
11 | 11 | */ |
12 | 12 | class DefinitionParameter implements \JsonSerializable { |
13 | - // placeholder value for password fields, when the client updates a storage configuration |
|
14 | - // placeholder values are ignored and the field is left unmodified |
|
15 | - public const UNMODIFIED_PLACEHOLDER = '__unmodified__'; |
|
16 | - |
|
17 | - /** Value constants */ |
|
18 | - public const VALUE_TEXT = 0; |
|
19 | - public const VALUE_BOOLEAN = 1; |
|
20 | - public const VALUE_PASSWORD = 2; |
|
21 | - |
|
22 | - /** Flag constants */ |
|
23 | - public const FLAG_NONE = 0; |
|
24 | - public const FLAG_OPTIONAL = 1; |
|
25 | - public const FLAG_USER_PROVIDED = 2; |
|
26 | - public const FLAG_HIDDEN = 4; |
|
27 | - |
|
28 | - /** @var string human-readable parameter tooltip */ |
|
29 | - private string $tooltip = ''; |
|
30 | - |
|
31 | - /** @var int value type, see self::VALUE_* constants */ |
|
32 | - private int $type = self::VALUE_TEXT; |
|
33 | - |
|
34 | - /** @var int flags, see self::FLAG_* constants */ |
|
35 | - private int $flags = self::FLAG_NONE; |
|
36 | - |
|
37 | - /** |
|
38 | - * @param string $name parameter name |
|
39 | - * @param string $text parameter description |
|
40 | - * @param mixed $defaultValue default value |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - private string $name, |
|
44 | - private string $text, |
|
45 | - private $defaultValue = null, |
|
46 | - ) { |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @return string |
|
51 | - */ |
|
52 | - public function getName(): string { |
|
53 | - return $this->name; |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function getText(): string { |
|
60 | - return $this->text; |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Get value type |
|
65 | - * |
|
66 | - * @return int |
|
67 | - */ |
|
68 | - public function getType(): int { |
|
69 | - return $this->type; |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Set value type |
|
74 | - * |
|
75 | - * @param int $type |
|
76 | - * @return self |
|
77 | - */ |
|
78 | - public function setType(int $type) { |
|
79 | - $this->type = $type; |
|
80 | - return $this; |
|
81 | - } |
|
82 | - |
|
83 | - /** |
|
84 | - * @return mixed default value |
|
85 | - */ |
|
86 | - public function getDefaultValue() { |
|
87 | - return $this->defaultValue; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * @param mixed $defaultValue default value |
|
92 | - * @return self |
|
93 | - */ |
|
94 | - public function setDefaultValue($defaultValue) { |
|
95 | - $this->defaultValue = $defaultValue; |
|
96 | - return $this; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - public function getTypeName(): string { |
|
103 | - switch ($this->type) { |
|
104 | - case self::VALUE_BOOLEAN: |
|
105 | - return 'boolean'; |
|
106 | - case self::VALUE_TEXT: |
|
107 | - return 'text'; |
|
108 | - case self::VALUE_PASSWORD: |
|
109 | - return 'password'; |
|
110 | - default: |
|
111 | - return 'unknown'; |
|
112 | - } |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * @return int |
|
117 | - */ |
|
118 | - public function getFlags(): int { |
|
119 | - return $this->flags; |
|
120 | - } |
|
121 | - |
|
122 | - /** |
|
123 | - * @param int $flags |
|
124 | - * @return self |
|
125 | - */ |
|
126 | - public function setFlags(int $flags) { |
|
127 | - $this->flags = $flags; |
|
128 | - return $this; |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * @param int $flag |
|
133 | - * @return self |
|
134 | - */ |
|
135 | - public function setFlag(int $flag) { |
|
136 | - $this->flags |= $flag; |
|
137 | - return $this; |
|
138 | - } |
|
139 | - |
|
140 | - /** |
|
141 | - * @param int $flag |
|
142 | - * @return bool |
|
143 | - */ |
|
144 | - public function isFlagSet(int $flag): bool { |
|
145 | - return (bool)($this->flags & $flag); |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * @return string |
|
150 | - */ |
|
151 | - public function getTooltip(): string { |
|
152 | - return $this->tooltip; |
|
153 | - } |
|
154 | - |
|
155 | - /** |
|
156 | - * @param string $tooltip |
|
157 | - * @return self |
|
158 | - */ |
|
159 | - public function setTooltip(string $tooltip) { |
|
160 | - $this->tooltip = $tooltip; |
|
161 | - return $this; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Serialize into JSON for client-side JS |
|
166 | - */ |
|
167 | - public function jsonSerialize(): array { |
|
168 | - $result = [ |
|
169 | - 'value' => $this->getText(), |
|
170 | - 'flags' => $this->getFlags(), |
|
171 | - 'type' => $this->getType(), |
|
172 | - 'tooltip' => $this->getTooltip(), |
|
173 | - ]; |
|
174 | - $defaultValue = $this->getDefaultValue(); |
|
175 | - if ($defaultValue) { |
|
176 | - $result['defaultValue'] = $defaultValue; |
|
177 | - } |
|
178 | - return $result; |
|
179 | - } |
|
180 | - |
|
181 | - public function isOptional(): bool { |
|
182 | - return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Validate a parameter value against this |
|
187 | - * Convert type as necessary |
|
188 | - * |
|
189 | - * @param mixed $value Value to check |
|
190 | - * @return bool success |
|
191 | - */ |
|
192 | - public function validateValue(&$value): bool { |
|
193 | - switch ($this->getType()) { |
|
194 | - case self::VALUE_BOOLEAN: |
|
195 | - if (!is_bool($value)) { |
|
196 | - switch ($value) { |
|
197 | - case 'true': |
|
198 | - $value = true; |
|
199 | - break; |
|
200 | - case 'false': |
|
201 | - $value = false; |
|
202 | - break; |
|
203 | - default: |
|
204 | - return false; |
|
205 | - } |
|
206 | - } |
|
207 | - break; |
|
208 | - default: |
|
209 | - if (!$value && !$this->isOptional()) { |
|
210 | - return false; |
|
211 | - } |
|
212 | - break; |
|
213 | - } |
|
214 | - return true; |
|
215 | - } |
|
13 | + // placeholder value for password fields, when the client updates a storage configuration |
|
14 | + // placeholder values are ignored and the field is left unmodified |
|
15 | + public const UNMODIFIED_PLACEHOLDER = '__unmodified__'; |
|
16 | + |
|
17 | + /** Value constants */ |
|
18 | + public const VALUE_TEXT = 0; |
|
19 | + public const VALUE_BOOLEAN = 1; |
|
20 | + public const VALUE_PASSWORD = 2; |
|
21 | + |
|
22 | + /** Flag constants */ |
|
23 | + public const FLAG_NONE = 0; |
|
24 | + public const FLAG_OPTIONAL = 1; |
|
25 | + public const FLAG_USER_PROVIDED = 2; |
|
26 | + public const FLAG_HIDDEN = 4; |
|
27 | + |
|
28 | + /** @var string human-readable parameter tooltip */ |
|
29 | + private string $tooltip = ''; |
|
30 | + |
|
31 | + /** @var int value type, see self::VALUE_* constants */ |
|
32 | + private int $type = self::VALUE_TEXT; |
|
33 | + |
|
34 | + /** @var int flags, see self::FLAG_* constants */ |
|
35 | + private int $flags = self::FLAG_NONE; |
|
36 | + |
|
37 | + /** |
|
38 | + * @param string $name parameter name |
|
39 | + * @param string $text parameter description |
|
40 | + * @param mixed $defaultValue default value |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + private string $name, |
|
44 | + private string $text, |
|
45 | + private $defaultValue = null, |
|
46 | + ) { |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @return string |
|
51 | + */ |
|
52 | + public function getName(): string { |
|
53 | + return $this->name; |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function getText(): string { |
|
60 | + return $this->text; |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Get value type |
|
65 | + * |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + public function getType(): int { |
|
69 | + return $this->type; |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Set value type |
|
74 | + * |
|
75 | + * @param int $type |
|
76 | + * @return self |
|
77 | + */ |
|
78 | + public function setType(int $type) { |
|
79 | + $this->type = $type; |
|
80 | + return $this; |
|
81 | + } |
|
82 | + |
|
83 | + /** |
|
84 | + * @return mixed default value |
|
85 | + */ |
|
86 | + public function getDefaultValue() { |
|
87 | + return $this->defaultValue; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * @param mixed $defaultValue default value |
|
92 | + * @return self |
|
93 | + */ |
|
94 | + public function setDefaultValue($defaultValue) { |
|
95 | + $this->defaultValue = $defaultValue; |
|
96 | + return $this; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + public function getTypeName(): string { |
|
103 | + switch ($this->type) { |
|
104 | + case self::VALUE_BOOLEAN: |
|
105 | + return 'boolean'; |
|
106 | + case self::VALUE_TEXT: |
|
107 | + return 'text'; |
|
108 | + case self::VALUE_PASSWORD: |
|
109 | + return 'password'; |
|
110 | + default: |
|
111 | + return 'unknown'; |
|
112 | + } |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * @return int |
|
117 | + */ |
|
118 | + public function getFlags(): int { |
|
119 | + return $this->flags; |
|
120 | + } |
|
121 | + |
|
122 | + /** |
|
123 | + * @param int $flags |
|
124 | + * @return self |
|
125 | + */ |
|
126 | + public function setFlags(int $flags) { |
|
127 | + $this->flags = $flags; |
|
128 | + return $this; |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * @param int $flag |
|
133 | + * @return self |
|
134 | + */ |
|
135 | + public function setFlag(int $flag) { |
|
136 | + $this->flags |= $flag; |
|
137 | + return $this; |
|
138 | + } |
|
139 | + |
|
140 | + /** |
|
141 | + * @param int $flag |
|
142 | + * @return bool |
|
143 | + */ |
|
144 | + public function isFlagSet(int $flag): bool { |
|
145 | + return (bool)($this->flags & $flag); |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * @return string |
|
150 | + */ |
|
151 | + public function getTooltip(): string { |
|
152 | + return $this->tooltip; |
|
153 | + } |
|
154 | + |
|
155 | + /** |
|
156 | + * @param string $tooltip |
|
157 | + * @return self |
|
158 | + */ |
|
159 | + public function setTooltip(string $tooltip) { |
|
160 | + $this->tooltip = $tooltip; |
|
161 | + return $this; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Serialize into JSON for client-side JS |
|
166 | + */ |
|
167 | + public function jsonSerialize(): array { |
|
168 | + $result = [ |
|
169 | + 'value' => $this->getText(), |
|
170 | + 'flags' => $this->getFlags(), |
|
171 | + 'type' => $this->getType(), |
|
172 | + 'tooltip' => $this->getTooltip(), |
|
173 | + ]; |
|
174 | + $defaultValue = $this->getDefaultValue(); |
|
175 | + if ($defaultValue) { |
|
176 | + $result['defaultValue'] = $defaultValue; |
|
177 | + } |
|
178 | + return $result; |
|
179 | + } |
|
180 | + |
|
181 | + public function isOptional(): bool { |
|
182 | + return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Validate a parameter value against this |
|
187 | + * Convert type as necessary |
|
188 | + * |
|
189 | + * @param mixed $value Value to check |
|
190 | + * @return bool success |
|
191 | + */ |
|
192 | + public function validateValue(&$value): bool { |
|
193 | + switch ($this->getType()) { |
|
194 | + case self::VALUE_BOOLEAN: |
|
195 | + if (!is_bool($value)) { |
|
196 | + switch ($value) { |
|
197 | + case 'true': |
|
198 | + $value = true; |
|
199 | + break; |
|
200 | + case 'false': |
|
201 | + $value = false; |
|
202 | + break; |
|
203 | + default: |
|
204 | + return false; |
|
205 | + } |
|
206 | + } |
|
207 | + break; |
|
208 | + default: |
|
209 | + if (!$value && !$this->isOptional()) { |
|
210 | + return false; |
|
211 | + } |
|
212 | + break; |
|
213 | + } |
|
214 | + return true; |
|
215 | + } |
|
216 | 216 | } |
@@ -30,24 +30,24 @@ |
||
30 | 30 | use OCP\IL10N; |
31 | 31 | |
32 | 32 | class DAV extends Backend { |
33 | - use LegacyDependencyCheckPolyfill; |
|
33 | + use LegacyDependencyCheckPolyfill; |
|
34 | 34 | |
35 | - public function __construct(IL10N $l, Password $legacyAuth) { |
|
36 | - $this |
|
37 | - ->setIdentifier('dav') |
|
38 | - ->addIdentifierAlias('\OC\Files\Storage\DAV') // legacy compat |
|
39 | - ->setStorageClass('\OC\Files\Storage\DAV') |
|
40 | - ->setText($l->t('WebDAV')) |
|
41 | - ->addParameters([ |
|
42 | - new DefinitionParameter('host', $l->t('URL')), |
|
43 | - (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
44 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
45 | - (new DefinitionParameter('secure', $l->t('Secure https://'))) |
|
46 | - ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
47 | - ->setDefaultValue(true), |
|
48 | - ]) |
|
49 | - ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
50 | - ->setLegacyAuthMechanism($legacyAuth) |
|
51 | - ; |
|
52 | - } |
|
35 | + public function __construct(IL10N $l, Password $legacyAuth) { |
|
36 | + $this |
|
37 | + ->setIdentifier('dav') |
|
38 | + ->addIdentifierAlias('\OC\Files\Storage\DAV') // legacy compat |
|
39 | + ->setStorageClass('\OC\Files\Storage\DAV') |
|
40 | + ->setText($l->t('WebDAV')) |
|
41 | + ->addParameters([ |
|
42 | + new DefinitionParameter('host', $l->t('URL')), |
|
43 | + (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
44 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
45 | + (new DefinitionParameter('secure', $l->t('Secure https://'))) |
|
46 | + ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
47 | + ->setDefaultValue(true), |
|
48 | + ]) |
|
49 | + ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
50 | + ->setLegacyAuthMechanism($legacyAuth) |
|
51 | + ; |
|
52 | + } |
|
53 | 53 | } |
@@ -30,22 +30,22 @@ |
||
30 | 30 | use OCP\IL10N; |
31 | 31 | |
32 | 32 | class OwnCloud extends Backend { |
33 | - public function __construct(IL10N $l, Password $legacyAuth) { |
|
34 | - $this |
|
35 | - ->setIdentifier('owncloud') |
|
36 | - ->addIdentifierAlias('\OC\Files\Storage\OwnCloud') // legacy compat |
|
37 | - ->setStorageClass('\OCA\Files_External\Lib\Storage\OwnCloud') |
|
38 | - ->setText($l->t('Nextcloud')) |
|
39 | - ->addParameters([ |
|
40 | - new DefinitionParameter('host', $l->t('URL')), |
|
41 | - (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
42 | - ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
43 | - (new DefinitionParameter('secure', $l->t('Secure https://'))) |
|
44 | - ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
45 | - ->setDefaultValue(true), |
|
46 | - ]) |
|
47 | - ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
48 | - ->setLegacyAuthMechanism($legacyAuth) |
|
49 | - ; |
|
50 | - } |
|
33 | + public function __construct(IL10N $l, Password $legacyAuth) { |
|
34 | + $this |
|
35 | + ->setIdentifier('owncloud') |
|
36 | + ->addIdentifierAlias('\OC\Files\Storage\OwnCloud') // legacy compat |
|
37 | + ->setStorageClass('\OCA\Files_External\Lib\Storage\OwnCloud') |
|
38 | + ->setText($l->t('Nextcloud')) |
|
39 | + ->addParameters([ |
|
40 | + new DefinitionParameter('host', $l->t('URL')), |
|
41 | + (new DefinitionParameter('root', $l->t('Remote subfolder'))) |
|
42 | + ->setFlag(DefinitionParameter::FLAG_OPTIONAL), |
|
43 | + (new DefinitionParameter('secure', $l->t('Secure https://'))) |
|
44 | + ->setType(DefinitionParameter::VALUE_BOOLEAN) |
|
45 | + ->setDefaultValue(true), |
|
46 | + ]) |
|
47 | + ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD) |
|
48 | + ->setLegacyAuthMechanism($legacyAuth) |
|
49 | + ; |
|
50 | + } |
|
51 | 51 | } |