1
0
Fork 0
mirror of https://github.com/wallabag/wallabag.git synced 2025-06-27 16:36:00 +00:00
This commit is contained in:
Yassine Guedidi 2025-02-24 07:46:54 +01:00 committed by GitHub
commit a4ca746ade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 374 additions and 333 deletions

34
.env Normal file
View file

@ -0,0 +1,34 @@
SECRET="ch4n63m31fy0uc4n"
LOCALE=en
SERVER_NAME="Your wallabag instance"
DOMAIN_NAME=http://127.0.0.1:8000
DATABASE_URL=sqlite:///%kernel.project_dir%/data/db/wallabag.sqlite?charset=utf8
#DATABASE_URL=mysql://root:wallaroot@mariadb:3306/wallabag?charset=utf8mb4
#DATABASE_URL=postgres://wallabag:wallapass@postgres:5432/wallabag?charset=utf8
DATABASE_TABLE_PREFIX=wallabag_
FOSUSER_REGISTRATION=false
FOSUSER_CONFIRMATION=true
FOS_OAUTH_SERVER_ACCESS_TOKEN_LIFETIME=3600
FOS_OAUTH_SERVER_REFRESH_TOKEN_LIFETIME=1209600
TWOFACTOR_SENDER=no-reply@wallabag.org
MAILER_DSN=smtp://127.0.0.1
FROM_EMAIL=wallabag@example.com
RABBITMQ_HOST=rabbitmq
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASSWORD=guest
REDIS_SCHEME=tcp
REDIS_HOST=redis
REDIS_PORT=6379
REDIS_PATH=
REDIS_PASSWORD=
RABBITMQ_PREFETCH_COUNT=10
SENTRY_DSN=

4
.env.test Normal file
View file

@ -0,0 +1,4 @@
DATABASE_URL=sqlite:///%kernel.project_dir%/data/db/wallabag_test.sqlite?charset=utf8
#DATABASE_URL=mysql://root:wallaroot@mariadb:3306/wallabag_test?charset=utf8mb4
#DATABASE_URL=postgres://wallabag:wallapass@postgres:5432/wallabag_test?charset=utf8
FOSUSER_REGISTRATION=true

View file

@ -17,7 +17,7 @@ Installation: How did you install wallabag? Using git clone, the docker image, a
PHP version: The version of PHP you are using PHP version: The version of PHP you are using
OS: The host running wallabag OS: The host running wallabag
Database: The storage system your instance is using (SQLite, MySQL/MariaDB or PostgreSQL) with the version Database: The storage system your instance is using (SQLite, MySQL/MariaDB or PostgreSQL) with the version
Parameters: Paste the content of your app/config/parameters.yml (hide sensitive stuff if you want) Parameters: Put the content of your environment variables (hide sensitive stuff if you want)
--> -->
### Environment ### Environment
@ -29,10 +29,37 @@ Parameters: Paste the content of your app/config/parameters.yml (hide sensitiv
* **Parameters**: * **Parameters**:
<details> <details>
<summary>My <code>app/config/parameters.yml</code> is:</summary> <summary>My environment variables are:</summary>
``` ```
PASTE HERE LOCALE=
# Make sure to hide username and password below, if any
DATABASE_URL=
DATABASE_TABLE_PREFIX=
FOSUSER_REGISTRATION=
FOSUSER_CONFIRMATION=
FOS_OAUTH_SERVER_ACCESS_TOKEN_LIFETIME=
FOS_OAUTH_SERVER_REFRESH_TOKEN_LIFETIME=
TWOFACTOR_SENDER=
# Make sure to hide username and password below, if any
MAILER_DSN=
FROM_EMAIL=
RABBITMQ_HOST=
RABBITMQ_PORT=
REDIS_SCHEME=
REDIS_HOST=
REDIS_PORT=
REDIS_PATH=
RABBITMQ_PREFETCH_COUNT=
# Make sure to hide username and password below, if any
SENTRY_DSN=
``` ```
</details> </details>

View file

@ -40,7 +40,7 @@ jobs:
run: | run: |
sudo systemctl start mysql.service sudo systemctl start mysql.service
sudo mysql -u root -proot -h 127.0.0.1 -e "CREATE DATABASE wallabag_test" sudo mysql -u root -proot -h 127.0.0.1 -e "CREATE DATABASE wallabag_test"
cp app/config/tests/parameters_test.mysql.yml app/config/parameters_test.yml cp app/config/tests/.env.mysql .env.test.local
- name: "Install dependencies with Composer" - name: "Install dependencies with Composer"
id: composer-install id: composer-install

View file

@ -89,7 +89,7 @@ jobs:
run: yarn build:dev run: yarn build:dev
- name: "Prepare database configuration" - name: "Prepare database configuration"
run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml run: cp app/config/tests/.env.${{ matrix.database }} .env.test.local
- name: "Run PHPUnit" - name: "Run PHPUnit"
run: "php bin/phpunit -v" run: "php bin/phpunit -v"
@ -140,8 +140,7 @@ jobs:
- name: "Remove database prefix" - name: "Remove database prefix"
run: | run: |
pip install --user yq sed -i 's/DATABASE_TABLE_PREFIX=wallabag_/DATABASE_TABLE_PREFIX=/' .env
yq -Y --in-place '.parameters.database_table_prefix = ""' app/config/parameters.yml.dist
- name: "Setup MySQL" - name: "Setup MySQL"
if: "${{ matrix.database == 'mysql' }}" if: "${{ matrix.database == 'mysql' }}"
@ -169,7 +168,7 @@ jobs:
run: yarn build:dev run: yarn build:dev
- name: "Prepare database configuration" - name: "Prepare database configuration"
run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml run: cp app/config/tests/.env.${{ matrix.database }} .env.test.local
- name: "Run PHPUnit" - name: "Run PHPUnit"
run: "php bin/phpunit -v" run: "php bin/phpunit -v"
@ -235,7 +234,7 @@ jobs:
run: yarn build:dev run: yarn build:dev
- name: "Prepare database configuration" - name: "Prepare database configuration"
run: cp app/config/tests/parameters_test.${{ matrix.database }}.yml app/config/parameters_test.yml run: cp app/config/tests/.env.${{ matrix.database }} .env.test.local
- name: "Run PHPUnit" - name: "Run PHPUnit"
run: "php bin/phpunit -v" run: "php bin/phpunit -v"

3
.gitignore vendored
View file

@ -17,9 +17,6 @@
phpunit.xml phpunit.xml
compose.override.yaml compose.override.yaml
# Parameters
/app/config/parameters.yml
# Managed by Composer # Managed by Composer
/vendor/ /vendor/

View file

@ -67,6 +67,12 @@ class AppKernel extends Kernel
public function registerContainerConfiguration(LoaderInterface $loader) public function registerContainerConfiguration(LoaderInterface $loader)
{ {
if (file_exists($this->getProjectDir() . '/app/config/parameters.yml')) {
$loader->load($this->getProjectDir() . '/app/config/parameters.yml');
@trigger_error('The "app/config/parameters.yml" file is deprecated and will not be supported in a future version. Move your configuration to environment variables and remove the file.', \E_USER_DEPRECATED);
}
$loader->load($this->getProjectDir() . '/app/config/config_' . $this->getEnvironment() . '.yml'); $loader->load($this->getProjectDir() . '/app/config/config_' . $this->getEnvironment() . '.yml');
$loader->load(function (ContainerBuilder $container) { $loader->load(function (ContainerBuilder $container) {
@ -75,9 +81,12 @@ class AppKernel extends Kernel
$container->addObjectResource($this); $container->addObjectResource($this);
}); });
$loader->load(function (ContainerBuilder $container) { if (file_exists($this->getProjectDir() . '/app/config/parameters.yml')) {
$this->processDatabaseParameters($container); $loader->load(function (ContainerBuilder $container) {
}); $this->loadEnvVarsFromParameters($container);
$this->defineDatabaseUrlEnvVar($container);
});
}
} }
protected function build(ContainerBuilder $container) protected function build(ContainerBuilder $container)
@ -85,7 +94,45 @@ class AppKernel extends Kernel
$container->addCompilerPass(new ImportCompilerPass()); $container->addCompilerPass(new ImportCompilerPass());
} }
private function processDatabaseParameters(ContainerBuilder $container) private function loadEnvVarsFromParameters(ContainerBuilder $container)
{
$this->setEnvVarFromParameter($container, 'DATABASE_TABLE_PREFIX', 'database_table_prefix');
$this->setEnvVarFromParameter($container, 'DOMAIN_NAME', 'domain_name');
$this->setEnvVarFromParameter($container, 'SERVER_NAME', 'server_name');
$this->setEnvVarFromParameter($container, 'MAILER_DSN', 'mailer_dsn');
$this->setEnvVarFromParameter($container, 'LOCALE', 'locale');
$this->setEnvVarFromParameter($container, 'SECRET', 'secret');
$this->setEnvVarFromParameter($container, 'TWOFACTOR_SENDER', 'twofactor_sender');
$this->setEnvVarFromParameter($container, 'FOSUSER_REGISTRATION', 'fosuser_registration');
$this->setEnvVarFromParameter($container, 'FOSUSER_CONFIRMATION', 'fosuser_confirmation');
$this->setEnvVarFromParameter($container, 'FOS_OAUTH_SERVER_ACCESS_TOKEN_LIFETIME', 'fos_oauth_server_access_token_lifetime');
$this->setEnvVarFromParameter($container, 'FOS_OAUTH_SERVER_REFRESH_TOKEN_LIFETIME', 'fos_oauth_server_refresh_token_lifetime');
$this->setEnvVarFromParameter($container, 'FROM_EMAIL', 'from_email');
$this->setEnvVarFromParameter($container, 'RABBITMQ_HOST', 'rabbitmq_host');
$this->setEnvVarFromParameter($container, 'RABBITMQ_PORT', 'rabbitmq_port');
$this->setEnvVarFromParameter($container, 'RABBITMQ_USER', 'rabbitmq_user');
$this->setEnvVarFromParameter($container, 'RABBITMQ_PASSWORD', 'rabbitmq_password');
$this->setEnvVarFromParameter($container, 'RABBITMQ_PREFETCH_COUNT', 'rabbitmq_prefetch_count');
$this->setEnvVarFromParameter($container, 'REDIS_SCHEME', 'redis_scheme');
$this->setEnvVarFromParameter($container, 'REDIS_HOST', 'redis_host');
$this->setEnvVarFromParameter($container, 'REDIS_PORT', 'redis_port');
$this->setEnvVarFromParameter($container, 'REDIS_PATH', 'redis_path');
$this->setEnvVarFromParameter($container, 'REDIS_PASSWORD', 'redis_password');
$this->setEnvVarFromParameter($container, 'SENTRY_DSN', 'sentry_dsn');
}
private function setEnvVarFromParameter(ContainerBuilder $container, string $envVar, string $parameter)
{
$_ENV[$envVar] = $_SERVER[$envVar] = (string) $container->getParameter($parameter);
$container->setParameter('env(' . $envVar . ')', (string) $container->getParameter($parameter));
}
private function defineDatabaseUrlEnvVar(ContainerBuilder $container)
{ {
switch ($container->getParameter('database_driver')) { switch ($container->getParameter('database_driver')) {
case 'pdo_mysql': case 'pdo_mysql':
@ -101,15 +148,39 @@ class AppKernel extends Kernel
throw new RuntimeException('Unsupported database driver: ' . $container->getParameter('database_driver')); throw new RuntimeException('Unsupported database driver: ' . $container->getParameter('database_driver'));
} }
$container->setParameter('database_scheme', $scheme); $user = $container->getParameter('database_user');
$password = $container->getParameter('database_password');
$host = $container->getParameter('database_host');
$port = $container->getParameter('database_port');
$name = $container->getParameter('database_name');
if ('sqlite' === $scheme) { if ('sqlite' === $scheme) {
$container->setParameter('database_name', $container->getParameter('database_path')); $name = $container->getParameter('database_path');
} }
$container->setParameter('database_user', (string) $container->getParameter('database_user')); $url = $scheme . '://' . $user . ':' . $password . '@' . $host;
$container->setParameter('database_password', (string) $container->getParameter('database_password'));
$container->setParameter('database_port', (string) $container->getParameter('database_port')); if ($port) {
$container->setParameter('database_socket', (string) $container->getParameter('database_socket')); $url .= ':' . $port;
}
$url .= '/' . $name;
$query = [];
if ($container->getParameter('database_socket')) {
$query['unix_socket'] = $container->getParameter('database_socket');
}
if ($container->getParameter('database_charset')) {
$query['charset'] = $container->getParameter('database_charset');
}
if ([] !== $query) {
$url .= '?' . http_build_query($query);
}
$_ENV['DATABASE_URL'] = $_SERVER['DATABASE_URL'] = $url;
$container->setParameter('env(DATABASE_URL)', $url);
} }
} }

View file

@ -1,20 +1,18 @@
imports: imports:
- { resource: parameters.yml }
- { resource: security.yml } - { resource: security.yml }
- { resource: services.yml } - { resource: services.yml }
- { resource: wallabag.yml } - { resource: wallabag.yml }
parameters: parameters:
craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\SymfonyCacheComponentAdapter craue_config.cache_adapter.class: Craue\ConfigBundle\CacheAdapter\SymfonyCacheComponentAdapter
env(DATABASE_URL): '%database_scheme%://%database_user%:%database_password%@%database_host%:%database_port%/%database_name%?unix_socket=%database_socket%&charset=%database_charset%'
framework: framework:
#esi: ~ #esi: ~
translator: translator:
enabled: true enabled: true
fallback: "%locale%" fallback: "%env(LOCALE)%"
default_path: '%kernel.project_dir%/translations' default_path: '%kernel.project_dir%/translations'
secret: "%secret%" secret: "%env(SECRET)%"
router: router:
resource: "%kernel.project_dir%/app/config/routing.yml" resource: "%kernel.project_dir%/app/config/routing.yml"
strict_requirements: ~ strict_requirements: ~
@ -22,7 +20,7 @@ framework:
csrf_protection: ~ csrf_protection: ~
validation: validation:
enable_annotations: true enable_annotations: true
default_locale: "%locale%" default_locale: "%env(LOCALE)%"
trusted_hosts: ~ trusted_hosts: ~
session: session:
# handler_id set to null will use default session handler from php.ini # handler_id set to null will use default session handler from php.ini
@ -32,10 +30,10 @@ framework:
fragments: ~ fragments: ~
http_method_override: true http_method_override: true
assets: assets:
base_url: '%domain_name%' base_url: '%env(DOMAIN_NAME)%'
json_manifest_path: '%kernel.project_dir%/web/build/manifest.json' json_manifest_path: '%kernel.project_dir%/web/build/manifest.json'
mailer: mailer:
dsn: "%mailer_dsn%" dsn: "%env(MAILER_DSN)%"
http_client: http_client:
scoped_clients: scoped_clients:
download_images.client: download_images.client:
@ -60,8 +58,8 @@ twig:
form_themes: form_themes:
- "@SpiriitFormFilter/Form/form_div_layout.html.twig" - "@SpiriitFormFilter/Form/form_div_layout.html.twig"
globals: globals:
wallabag_url: '%domain_name%' wallabag_url: '%env(DOMAIN_NAME)%'
registration_enabled: '%fosuser_registration%' registration_enabled: '%env(bool:FOSUSER_REGISTRATION)%'
# Doctrine Configuration # Doctrine Configuration
doctrine: doctrine:
@ -84,7 +82,7 @@ doctrine:
alias: Wallabag alias: Wallabag
stof_doctrine_extensions: stof_doctrine_extensions:
default_locale: "%locale%" default_locale: "%env(LOCALE)%"
translation_fallback: true translation_fallback: true
orm: orm:
default: default:
@ -192,9 +190,9 @@ fos_user:
user_class: Wallabag\Entity\User user_class: Wallabag\Entity\User
registration: registration:
confirmation: confirmation:
enabled: "%fosuser_confirmation%" enabled: "%env(bool:FOSUSER_CONFIRMATION)%"
from_email: from_email:
address: "%from_email%" address: "%env(FROM_EMAIL)%"
sender_name: wallabag sender_name: wallabag
service: service:
mailer: Wallabag\Mailer\UserMailer mailer: Wallabag\Mailer\UserMailer
@ -208,8 +206,8 @@ fos_oauth_server:
service: service:
user_provider: fos_user.user_provider.username_email user_provider: fos_user.user_provider.username_email
options: options:
refresh_token_lifetime: "%fos_oauth_server_refresh_token_lifetime%" refresh_token_lifetime: "%env(FOS_OAUTH_SERVER_REFRESH_TOKEN_LIFETIME)%"
access_token_lifetime: "%fos_oauth_server_access_token_lifetime%" access_token_lifetime: "%env(FOS_OAUTH_SERVER_ACCESS_TOKEN_LIFETIME)%"
scheb_two_factor: scheb_two_factor:
trusted_device: trusted_device:
@ -222,12 +220,12 @@ scheb_two_factor:
google: google:
enabled: true enabled: true
issuer: "%server_name%" issuer: "%env(SERVER_NAME)%"
template: "Authentication/form.html.twig" template: "Authentication/form.html.twig"
email: email:
enabled: true enabled: true
sender_email: "%twofactor_sender%" sender_email: "%env(TWOFACTOR_SENDER)%"
digits: 6 digits: 6
template: "Authentication/form.html.twig" template: "Authentication/form.html.twig"
mailer: Wallabag\Mailer\AuthCodeMailer mailer: Wallabag\Mailer\AuthCodeMailer
@ -239,10 +237,10 @@ rulerz:
old_sound_rabbit_mq: old_sound_rabbit_mq:
connections: connections:
default: default:
host: "%rabbitmq_host%" host: "%env(RABBITMQ_HOST)%"
port: "%rabbitmq_port%" port: "%env(int:RABBITMQ_PORT)%"
user: "%rabbitmq_user%" user: "%env(RABBITMQ_USER)%"
password: "%rabbitmq_password%" password: "%env(RABBITMQ_PASSWORD)%"
vhost: / vhost: /
lazy: true lazy: true
producers: producers:
@ -320,7 +318,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.pocket' name: 'wallabag.import.pocket'
callback: wallabag.consumer.amqp.pocket callback: wallabag.consumer.amqp.pocket
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_readability: import_readability:
connection: default connection: default
exchange_options: exchange_options:
@ -329,7 +327,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.readability' name: 'wallabag.import.readability'
callback: wallabag.consumer.amqp.readability callback: wallabag.consumer.amqp.readability
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_instapaper: import_instapaper:
connection: default connection: default
exchange_options: exchange_options:
@ -338,7 +336,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.instapaper' name: 'wallabag.import.instapaper'
callback: wallabag.consumer.amqp.instapaper callback: wallabag.consumer.amqp.instapaper
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_pinboard: import_pinboard:
connection: default connection: default
exchange_options: exchange_options:
@ -347,7 +345,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.pinboard' name: 'wallabag.import.pinboard'
callback: wallabag.consumer.amqp.pinboard callback: wallabag.consumer.amqp.pinboard
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_delicious: import_delicious:
connection: default connection: default
exchange_options: exchange_options:
@ -356,7 +354,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.delicious' name: 'wallabag.import.delicious'
callback: wallabag.consumer.amqp.delicious callback: wallabag.consumer.amqp.delicious
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_wallabag_v1: import_wallabag_v1:
connection: default connection: default
exchange_options: exchange_options:
@ -365,7 +363,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.wallabag_v1' name: 'wallabag.import.wallabag_v1'
callback: wallabag.consumer.amqp.wallabag_v1 callback: wallabag.consumer.amqp.wallabag_v1
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_wallabag_v2: import_wallabag_v2:
connection: default connection: default
exchange_options: exchange_options:
@ -374,7 +372,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.wallabag_v2' name: 'wallabag.import.wallabag_v2'
callback: wallabag.consumer.amqp.wallabag_v2 callback: wallabag.consumer.amqp.wallabag_v2
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_elcurator: import_elcurator:
connection: default connection: default
exchange_options: exchange_options:
@ -383,7 +381,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.elcurator' name: 'wallabag.import.elcurator'
callback: wallabag.consumer.amqp.elcurator callback: wallabag.consumer.amqp.elcurator
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_omnivore: import_omnivore:
connection: default connection: default
exchange_options: exchange_options:
@ -392,7 +390,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.omnivore' name: 'wallabag.import.omnivore'
callback: wallabag.consumer.amqp.omnivore callback: wallabag.consumer.amqp.omnivore
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_firefox: import_firefox:
connection: default connection: default
exchange_options: exchange_options:
@ -401,7 +399,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.firefox' name: 'wallabag.import.firefox'
callback: wallabag.consumer.amqp.firefox callback: wallabag.consumer.amqp.firefox
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_chrome: import_chrome:
connection: default connection: default
exchange_options: exchange_options:
@ -410,7 +408,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.chrome' name: 'wallabag.import.chrome'
callback: wallabag.consumer.amqp.chrome callback: wallabag.consumer.amqp.chrome
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_shaarli: import_shaarli:
connection: default connection: default
exchange_options: exchange_options:
@ -419,7 +417,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.shaarli' name: 'wallabag.import.shaarli'
callback: wallabag.consumer.amqp.shaarli callback: wallabag.consumer.amqp.shaarli
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
import_pocket_html: import_pocket_html:
connection: default connection: default
exchange_options: exchange_options:
@ -428,7 +426,7 @@ old_sound_rabbit_mq:
queue_options: queue_options:
name: 'wallabag.import.pocket_html' name: 'wallabag.import.pocket_html'
callback: wallabag.consumer.amqp.pocket_html callback: wallabag.consumer.amqp.pocket_html
qos_options: {prefetch_count: "%rabbitmq_prefetch_count%"} qos_options: {prefetch_count: "%env(int:RABBITMQ_PREFETCH_COUNT)%"}
fos_js_routing: fos_js_routing:
routes_to_expose: routes_to_expose:

View file

@ -21,4 +21,4 @@ monolog:
type: console type: console
sentry: sentry:
dsn: "%sentry_dsn%" dsn: "%env(SENTRY_DSN)%"

View file

@ -1,11 +1,11 @@
imports: imports:
- { resource: config_dev.yml } - { resource: config_dev.yml }
- { resource: parameters_test.yml }
- { resource: services_test.yml } - { resource: services_test.yml }
parameters: parameters:
fosuser_registration: true fosuser_registration: '%env(FOSUSER_REGISTRATION)%'
wallabag_dbname_suffix: '_test' database_url: '%env(resolve:DATABASE_URL)%'
domain_name: '%env(DOMAIN_NAME)%'
framework: framework:
test: ~ test: ~
@ -24,7 +24,6 @@ web_profiler:
doctrine: doctrine:
dbal: dbal:
dbname_suffix: '%wallabag_dbname_suffix%' # for MySQL and PostgreSQL
use_savepoints: true use_savepoints: true
orm: orm:

View file

@ -1,65 +0,0 @@
# This file is a "template" of what your parameters.yml file should look like
parameters:
# Uncomment these settings or manually update your parameters.yml
# to use Docker Compose
#
# database_driver: %env.database_driver%
# database_host: %env.database_host%
# database_port: %env.database_port%
# database_name: %env.database_name%
# database_user: %env.database_user%
# database_password: %env.database_password%
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: ~
database_name: wallabag
database_user: root
database_password: ~
# For SQLite, database_path should be "%kernel.project_dir%/data/db/wallabag.sqlite"
database_path: null
database_table_prefix: wallabag_
database_socket: null
# with PostgreSQL and SQLite, you must set "utf8"
database_charset: utf8mb4
domain_name: https://your-wallabag-instance.wallabag.org
server_name: "Your wallabag instance"
mailer_dsn: smtp://127.0.0.1
locale: en
# A secret key that's used to generate certain security-related tokens
secret: CHANGE_ME_TO_SOMETHING_SECRET_AND_RANDOM
# two factor stuff
twofactor_sender: no-reply@wallabag.org
# fosuser stuff
fosuser_registration: false
fosuser_confirmation: true
# how long the access token should live in seconds for the API
fos_oauth_server_access_token_lifetime: 3600
# how long the refresh token should life in seconds for the API
fos_oauth_server_refresh_token_lifetime: 1209600
from_email: no-reply@wallabag.org
# RabbitMQ processing
rabbitmq_host: localhost
rabbitmq_port: 5672
rabbitmq_user: guest
rabbitmq_password: guest
rabbitmq_prefetch_count: 10
# Redis processing
redis_scheme: tcp
redis_host: localhost
redis_port: 6379
redis_path: null
redis_password: null
# sentry logging
sentry_dsn: ~

View file

@ -1,2 +0,0 @@
parameters:
database_path: "%kernel.project_dir%/data/db/wallabag%wallabag_dbname_suffix%.sqlite"

View file

@ -45,7 +45,7 @@ security:
anonymous: true anonymous: true
remember_me: remember_me:
secret: "%secret%" secret: "%env(SECRET)%"
lifetime: 31536000 lifetime: 31536000
path: / path: /
domain: ~ domain: ~

View file

@ -15,15 +15,15 @@ services:
$projectDir: '%kernel.project_dir%' $projectDir: '%kernel.project_dir%'
$debug: '%kernel.debug%' $debug: '%kernel.debug%'
$defaultLocale: '%kernel.default_locale%' $defaultLocale: '%kernel.default_locale%'
$wallabagUrl: '%domain_name%' $wallabagUrl: '%env(DOMAIN_NAME)%'
$tablePrefix: "%database_table_prefix%" $tablePrefix: "%env(DATABASE_TABLE_PREFIX)%"
$encryptionKeyPath: "%wallabag.site_credentials.encryption_key_path%" $encryptionKeyPath: "%wallabag.site_credentials.encryption_key_path%"
$fetchingErrorMessageTitle: "%wallabag.fetching_error_message_title%" $fetchingErrorMessageTitle: "%wallabag.fetching_error_message_title%"
$fetchingErrorMessage: '%wallabag.fetching_error_message%' $fetchingErrorMessage: '%wallabag.fetching_error_message%'
$languages: '%wallabag.languages%' $languages: '%wallabag.languages%'
$lifeTime: '%wallabag.cache_lifetime%' $lifeTime: '%wallabag.cache_lifetime%'
$logoPath: 'web/img/appicon/apple-touch-icon-152.png' $logoPath: 'web/img/appicon/apple-touch-icon-152.png'
$registrationEnabled: '%fosuser_registration%' $registrationEnabled: '%env(bool:FOSUSER_REGISTRATION)%'
$restrictedAccess: '@=service(''craue_config'').get(''restricted_access'')' $restrictedAccess: '@=service(''craue_config'').get(''restricted_access'')'
$senderEmail: "%scheb_two_factor.email.sender_email%" $senderEmail: "%scheb_two_factor.email.sender_email%"
$senderName: "%scheb_two_factor.email.sender_name%" $senderName: "%scheb_two_factor.email.sender_name%"
@ -187,7 +187,7 @@ services:
Wallabag\Event\Subscriber\SchemaAdapterSubscriber: Wallabag\Event\Subscriber\SchemaAdapterSubscriber:
arguments: arguments:
$databaseTablePrefix: "%database_table_prefix%" $databaseTablePrefix: "%env(DATABASE_TABLE_PREFIX)%"
tags: tags:
- { name: doctrine.event_subscriber } - { name: doctrine.event_subscriber }
@ -249,11 +249,11 @@ services:
Predis\Client: Predis\Client:
arguments: arguments:
$parameters: $parameters:
scheme: '%redis_scheme%' scheme: '%env(REDIS_SCHEME)%'
host: '%redis_host%' host: '%env(REDIS_HOST)%'
port: '%redis_port%' port: '%env(int:REDIS_PORT)%'
path: '%redis_path%' path: '%env(REDIS_PATH)%'
password: '%redis_password%' password: '%env(REDIS_PASSWORD)%'
Wallabag\Event\Subscriber\SQLiteCascadeDeleteSubscriber: Wallabag\Event\Subscriber\SQLiteCascadeDeleteSubscriber:
tags: tags:
@ -269,7 +269,7 @@ services:
Wallabag\Command\InstallCommand: Wallabag\Command\InstallCommand:
arguments: arguments:
$databaseDriver: '%database_driver%' $databaseUrl: '%env(DATABASE_URL)%'
$defaultSettings: '%wallabag.default_internal_settings%' $defaultSettings: '%wallabag.default_internal_settings%'
$defaultIgnoreOriginInstanceRules: '%wallabag.default_ignore_origin_instance_rules%' $defaultIgnoreOriginInstanceRules: '%wallabag.default_ignore_origin_instance_rules%'

View file

@ -0,0 +1 @@
DATABASE_URL=mysql://root:root@127.0.0.1:3306/wallabag?charset=utf8mb4

View file

@ -0,0 +1 @@
DATABASE_URL=postgres://wallabag:wallabagrocks@localhost/wallabag?charset=utf8

View file

@ -0,0 +1 @@
DATABASE_URL=sqlite:///%kernel.project_dir%/data/db/wallabag.sqlite?charset=utf8

View file

@ -1,2 +0,0 @@
parameters:
env(DATABASE_URL): mysql://root:root@127.0.0.1:3306/wallabag?charset=utf8mb4

View file

@ -1,2 +0,0 @@
parameters:
env(DATABASE_URL): postgres://wallabag:wallabagrocks@localhost/wallabag?charset=utf8

View file

@ -1,2 +0,0 @@
parameters:
env(DATABASE_URL): sqlite:///%kernel.project_dir%/data/db/wallabag%wallabag_dbname_suffix%.sqlite?charset=utf8

View file

@ -25,7 +25,7 @@ parameters:
el: 'Ελληνικά' el: 'Ελληνικά'
gl: 'Galego' gl: 'Galego'
wallabag.items_on_page: 12 wallabag.items_on_page: 12
wallabag.language: '%locale%' wallabag.language: '%env(LOCALE)%'
wallabag.feed_limit: 50 wallabag.feed_limit: 50
wallabag.reading_speed: 200 wallabag.reading_speed: 200
wallabag.cache_lifetime: 10 wallabag.cache_lifetime: 10

View file

@ -3,25 +3,40 @@
use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput; use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\ErrorHandler\Debug;
// if you don't want to setup permissions the proper way, just uncomment the following PHP line if (!in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
// read https://symfony.com/doc/current/setup.html#checking-symfony-application-configuration-and-setup echo 'Warning: The console should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
// for more information }
//umask(0000);
set_time_limit(0); set_time_limit(0);
require __DIR__.'/../vendor/autoload.php'; require dirname(__DIR__).'/vendor/autoload.php';
$input = new ArgvInput(); if (!class_exists(Application::class) || !class_exists(Dotenv::class)) {
$env = $input->getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev', true); throw new LogicException('You need to add "symfony/framework-bundle" and "symfony/dotenv" as Composer dependencies.');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption('--no-debug', true) && $env !== 'prod';
if ($debug) {
Debug::enable();
} }
$kernel = new AppKernel($env, $debug); $input = new ArgvInput();
if (null !== $env = $input->getParameterOption(['--env', '-e'], null, true)) {
putenv('APP_ENV='.$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $env);
}
if ($input->hasParameterOption('--no-debug', true)) {
putenv('APP_DEBUG='.$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
}
(new Dotenv())->bootEnv(dirname(__DIR__).'/.env');
if ($_SERVER['APP_DEBUG']) {
umask(0000);
if (class_exists(Debug::class)) {
Debug::enable();
}
}
$kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$application = new Application($kernel); $application = new Application($kernel);
$application->run($input); $application->run($input);

View file

@ -21,7 +21,6 @@ $config
'ergebnis/composer-normalize', 'ergebnis/composer-normalize',
'friendsofphp/php-cs-fixer', 'friendsofphp/php-cs-fixer',
'friendsoftwig/twigcs', 'friendsoftwig/twigcs',
'incenteev/composer-parameter-handler',
'j0k3r/graby-site-config', 'j0k3r/graby-site-config',
'laminas/laminas-code', 'laminas/laminas-code',
'lcobucci/jwt', 'lcobucci/jwt',

View file

@ -77,7 +77,6 @@
"friendsofsymfony/user-bundle": "^3.2.1", "friendsofsymfony/user-bundle": "^3.2.1",
"guzzlehttp/psr7": "^2.6.2", "guzzlehttp/psr7": "^2.6.2",
"html2text/html2text": "^4.3.1", "html2text/html2text": "^4.3.1",
"incenteev/composer-parameter-handler": "^2.2",
"j0k3r/graby": "^2.4.5", "j0k3r/graby": "^2.4.5",
"j0k3r/graby-site-config": "^1.0", "j0k3r/graby-site-config": "^1.0",
"javibravo/simpleue": "^2.1", "javibravo/simpleue": "^2.1",
@ -122,6 +121,7 @@
"symfony/dependency-injection": "^5.4.35", "symfony/dependency-injection": "^5.4.35",
"symfony/doctrine-bridge": "^5.4.35", "symfony/doctrine-bridge": "^5.4.35",
"symfony/dom-crawler": "^5.4.35", "symfony/dom-crawler": "^5.4.35",
"symfony/dotenv": "^5.4.35",
"symfony/error-handler": "^5.4.35", "symfony/error-handler": "^5.4.35",
"symfony/event-dispatcher": "^5.4.35", "symfony/event-dispatcher": "^5.4.35",
"symfony/event-dispatcher-contracts": "^2.5.2", "symfony/event-dispatcher-contracts": "^2.5.2",
@ -222,9 +222,6 @@
"sort-packages": true "sort-packages": true
}, },
"extra": { "extra": {
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"public-dir": "web", "public-dir": "web",
"symfony": { "symfony": {
"allow-contrib": true, "allow-contrib": true,
@ -239,7 +236,6 @@
"@post-cmd" "@post-cmd"
], ],
"post-cmd": [ "post-cmd": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"bin/console cache:clear --no-warmup", "bin/console cache:clear --no-warmup",
"bin/console assets:install web --symlink --relative" "bin/console assets:install web --symlink --relative"
] ]

130
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "a85056bec7fa90b9be4aa16c34464c0e", "content-hash": "14496bc12cd56950bd548fb244a8c769",
"packages": [ "packages": [
{ {
"name": "babdev/pagerfanta-bundle", "name": "babdev/pagerfanta-bundle",
@ -4159,63 +4159,6 @@
}, },
"time": "2021-07-21T13:50:14+00:00" "time": "2021-07-21T13:50:14+00:00"
}, },
{
"name": "incenteev/composer-parameter-handler",
"version": "v2.2.0",
"source": {
"type": "git",
"url": "https://github.com/Incenteev/ParameterHandler.git",
"reference": "90bffce926e96b365579a2ef024aab457f4b80c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Incenteev/ParameterHandler/zipball/90bffce926e96b365579a2ef024aab457f4b80c5",
"reference": "90bffce926e96b365579a2ef024aab457f4b80c5",
"shasum": ""
},
"require": {
"php": ">=7.4",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"require-dev": {
"composer/composer": "^2.0@dev",
"phpspec/prophecy-phpunit": "^2.1",
"phpunit/phpunit": "^9.6",
"symfony/filesystem": "^5.4 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^6.4.1 || ^7.0.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
},
"autoload": {
"psr-4": {
"Incenteev\\ParameterHandler\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Christophe Coevoet",
"email": "stof@notk.org"
}
],
"description": "Composer script handling your ignored parameter file",
"homepage": "https://github.com/Incenteev/ParameterHandler",
"keywords": [
"parameters management"
],
"support": {
"issues": "https://github.com/Incenteev/ParameterHandler/issues",
"source": "https://github.com/Incenteev/ParameterHandler/tree/v2.2.0"
},
"time": "2023-12-09T10:31:14+00:00"
},
{ {
"name": "j0k3r/graby", "name": "j0k3r/graby",
"version": "2.4.5", "version": "2.4.5",
@ -9569,6 +9512,77 @@
], ],
"time": "2024-10-22T13:05:35+00:00" "time": "2024-10-22T13:05:35+00:00"
}, },
{
"name": "symfony/dotenv",
"version": "v5.4.48",
"source": {
"type": "git",
"url": "https://github.com/symfony/dotenv.git",
"reference": "08013403089c8a126c968179179b817a552841ab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dotenv/zipball/08013403089c8a126c968179179b817a552841ab",
"reference": "08013403089c8a126c968179179b817a552841ab",
"shasum": ""
},
"require": {
"php": ">=7.2.5",
"symfony/deprecation-contracts": "^2.1|^3"
},
"require-dev": {
"symfony/console": "^4.4|^5.0|^6.0",
"symfony/process": "^4.4|^5.0|^6.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Symfony\\Component\\Dotenv\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Registers environment variables from a .env file",
"homepage": "https://symfony.com",
"keywords": [
"dotenv",
"env",
"environment"
],
"support": {
"source": "https://github.com/symfony/dotenv/tree/v5.4.48"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-11-27T09:33:00+00:00"
},
{ {
"name": "symfony/error-handler", "name": "symfony/error-handler",
"version": "v5.4.46", "version": "v5.4.46",

View file

@ -1,9 +1,2 @@
MYSQL_ROOT_PASSWORD=wallaroot MYSQL_ROOT_PASSWORD=wallaroot
MYSQL_DATABASE=wallabag MYSQL_DATABASE=wallabag
DATABASE_DRIVER=pdo_mysql
DATABASE_HOST=mariadb
DATABASE_PORT=3306
DATABASE_NAME=wallabag
DATABASE_USER=root
DATABASE_PASSWORD=wallaroot
DATABASE_CHARSET=utf8mb4

View file

@ -1,50 +0,0 @@
parameters:
database_driver: ${DATABASE_DRIVER:-pdo_sqlite}
database_host: ${DATABASE_HOST:-127.0.0.1}
database_port: ${DATABASE_PORT:-~}
database_name: ${DATABASE_NAME:-symfony}
database_user: ${DATABASE_USER:-root}
database_password: ${DATABASE_PASSWORD:-~}
database_path: ${DATABASE_PATH:-"%kernel.project_dir%/data/db/wallabag.sqlite"}
database_table_prefix: ${DATABASE_TABLE_PREFIX:-wallabag_}
database_socket: ${DATABASE_SOCKET:-~}
database_charset: ${DATABASE_CHARSET:-utf8}
domain_name: ${DOMAIN_NAME:-https://www.example.com}
server_name: ${SERVER_NAME:-"Your wallabag instance"}
mailer_dsn: ${MAILER_DSN:-"smtp://127.0.0.1"}
locale: ${LOCALE:-en}
# A secret key that's used to generate certain security-related tokens
secret: ${SECRET:-~}
# two factor stuff
twofactor_sender: ${TWOFACTOR_SENDER:-no-reply@wallabag.org}
# fosuser stuff
fosuser_registration: ${FOSUSER_REGISTRATION:-false}
fosuser_confirmation: ${FOSUSER_CONFIRMATION:-true}
fos_oauth_server_access_token_lifetime: ${FOS_OAUTH_SERVER_ACCESS_TOKEN_LIFETIME:-3600}
fos_oauth_server_refresh_token_lifetime: ${FOS_OAUTH_SERVER_REFRESH_TOKEN_LIFETIME:-1209600}
from_email: ${FROM_EMAIL:-wallabag@example.com}
# RabbitMQ processing
rabbitmq_host: ${RABBITMQ_HOST:-rabbitmq}
rabbitmq_port: ${RABBITMQ_PORT:-5672}
rabbitmq_user: ${RABBITMQ_USER:-guest}
rabbitmq_password: ${RABBITMQ_PASSWORD:-guest}
rabbitmq_prefetch_count: ${RABBITMQ_PREFETCH_COUNT:-10}
# Redis processing
redis_scheme: ${REDIS_SCHEME:-tcp}
redis_host: ${REDIS_HOST:-redis}
redis_port: ${REDIS_PORT:-6379}
redis_path: ${REDIS_PATH:-~}
redis_password: ${REDIS_PASSWORD:-~}
# Sentry
sentry_dsn: ${SENTRY_DSN:-~}

View file

@ -1,6 +1,5 @@
#!/bin/sh #!/bin/sh
envsubst < /opt/wallabag/config/wallabag-php.ini > /usr/local/etc/php/conf.d/wallabag-php.ini envsubst < /opt/wallabag/config/wallabag-php.ini > /usr/local/etc/php/conf.d/wallabag-php.ini
envsubst < /opt/wallabag/config/parameters.yml > /var/www/html/app/config/parameters.yml
exec "$@" exec "$@"

View file

@ -1,12 +1,3 @@
DATABASE_DRIVER=pdo_sqlite
DATABASE_HOST=127.0.0.1
DATABASE_PORT=~
DATABASE_NAME=symfony
DATABASE_USER=root
DATABASE_PASSWORD=~
DATABASE_PATH='"%kernel.project_dir%/data/db/wallabag.sqlite"'
DOMAIN_NAME=http://localhost:8000
SECRET=ch4n63m31fy0uc4n
PHP_SESSION_SAVE_PATH=tcp://redis:6379?database=2 PHP_SESSION_SAVE_PATH=tcp://redis:6379?database=2
PHP_SESSION_HANDLER=redis PHP_SESSION_HANDLER=redis
TRUSTED_PROXIES=0.0.0.0/0 TRUSTED_PROXIES=0.0.0.0/0

View file

@ -1,10 +1,3 @@
POSTGRES_USER=wallabag POSTGRES_USER=wallabag
POSTGRES_PASSWORD=wallapass POSTGRES_PASSWORD=wallapass
POSTGRES_DB=wallabag POSTGRES_DB=wallabag
DATABASE_HOST=postgres
DATABASE_PORT=5432
DATABASE_NAME=wallabag
DATABASE_USER=wallabag
DATABASE_PASSWORD=wallapass
DATABASE_DRIVER=pdo_pgsql
DATABASE_PATH=null

View file

@ -6,6 +6,8 @@ parameters:
paths: paths:
- src - src
- tests - tests
bootstrapFiles:
- tests/phpstan-bootstrap.php
symfony: symfony:
container_xml_path: %rootDir%/../../../var/cache/dev/AppKernelDevDebugContainer.xml container_xml_path: %rootDir%/../../../var/cache/dev/AppKernelDevDebugContainer.xml

View file

@ -19,7 +19,7 @@
<php> <php>
<ini name="error_reporting" value="-1"/> <ini name="error_reporting" value="-1"/>
<server name="KERNEL_CLASS" value="AppKernel"/> <server name="KERNEL_CLASS" value="AppKernel"/>
<server name="APP_ENV" value="test"/> <server name="APP_ENV" value="test" force="true"/>
<server name="APP_DEBUG" value="0"/> <server name="APP_DEBUG" value="0"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/> <env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
</php> </php>

View file

@ -7,6 +7,7 @@ use Doctrine\DBAL\Exception\DriverException;
use Doctrine\DBAL\Platforms\MySQLPlatform; use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\PostgreSQLPlatform; use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform; use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Tools\DsnParser;
use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration; use Doctrine\Migrations\Metadata\Storage\TableMetadataStorageConfiguration;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use FOS\UserBundle\Event\UserEvent; use FOS\UserBundle\Event\UserEvent;
@ -41,17 +42,17 @@ class InstallCommand extends Command
private EventDispatcherInterface $dispatcher; private EventDispatcherInterface $dispatcher;
private UserManagerInterface $userManager; private UserManagerInterface $userManager;
private TableMetadataStorageConfiguration $tableMetadataStorageConfiguration; private TableMetadataStorageConfiguration $tableMetadataStorageConfiguration;
private string $databaseDriver; private string $databaseUrl;
private array $defaultSettings; private array $defaultSettings;
private array $defaultIgnoreOriginInstanceRules; private array $defaultIgnoreOriginInstanceRules;
public function __construct(EntityManagerInterface $entityManager, EventDispatcherInterface $dispatcher, UserManagerInterface $userManager, TableMetadataStorageConfiguration $tableMetadataStorageConfiguration, string $databaseDriver, array $defaultSettings, array $defaultIgnoreOriginInstanceRules) public function __construct(EntityManagerInterface $entityManager, EventDispatcherInterface $dispatcher, UserManagerInterface $userManager, TableMetadataStorageConfiguration $tableMetadataStorageConfiguration, string $databaseUrl, array $defaultSettings, array $defaultIgnoreOriginInstanceRules)
{ {
$this->entityManager = $entityManager; $this->entityManager = $entityManager;
$this->dispatcher = $dispatcher; $this->dispatcher = $dispatcher;
$this->userManager = $userManager; $this->userManager = $userManager;
$this->tableMetadataStorageConfiguration = $tableMetadataStorageConfiguration; $this->tableMetadataStorageConfiguration = $tableMetadataStorageConfiguration;
$this->databaseDriver = $databaseDriver; $this->databaseUrl = $databaseUrl;
$this->defaultSettings = $defaultSettings; $this->defaultSettings = $defaultSettings;
$this->defaultIgnoreOriginInstanceRules = $defaultIgnoreOriginInstanceRules; $this->defaultIgnoreOriginInstanceRules = $defaultIgnoreOriginInstanceRules;
@ -103,13 +104,24 @@ class InstallCommand extends Command
$status = '<info>OK!</info>'; $status = '<info>OK!</info>';
$help = ''; $help = '';
if (!\extension_loaded($this->databaseDriver)) { /** @see \Doctrine\DBAL\DriverManager::$driverSchemeAliases */
$params = (new DsnParser([
'mysql' => 'pdo_mysql',
'mysql2' => 'pdo_mysql', // Amazon RDS, for some weird reason
'postgres' => 'pdo_pgsql',
'postgresql' => 'pdo_pgsql',
'pgsql' => 'pdo_pgsql',
'sqlite' => 'pdo_sqlite',
'sqlite3' => 'pdo_sqlite',
]))->parse($this->databaseUrl);
if (!\extension_loaded($params['driver'])) {
$fulfilled = false; $fulfilled = false;
$status = '<error>ERROR!</error>'; $status = '<error>ERROR!</error>';
$help = 'Database driver "' . $this->databaseDriver . '" is not installed.'; $help = 'Database driver "' . $params['driver'] . '" is not installed.';
} }
$rows[] = [\sprintf($label, $this->databaseDriver), $status, $help]; $rows[] = [\sprintf($label, $params['driver']), $status, $help];
// testing if connection to the database can be established // testing if connection to the database can be established
$label = '<comment>Database connection</comment>'; $label = '<comment>Database connection</comment>';

View file

@ -100,7 +100,6 @@
<tr><td>hoa/visitor</td><td>BSD-3-Clause</td></tr> <tr><td>hoa/visitor</td><td>BSD-3-Clause</td></tr>
<tr><td>hoa/zformat</td><td>BSD-3-Clause</td></tr> <tr><td>hoa/zformat</td><td>BSD-3-Clause</td></tr>
<tr><td>htmlawed/htmlawed</td><td>GPL-2.0+ or LGPL-3.0</td></tr> <tr><td>htmlawed/htmlawed</td><td>GPL-2.0+ or LGPL-3.0</td></tr>
<tr><td>incenteev/composer-parameter-handler</td><td>MIT</td></tr>
<tr><td>j0k3r/graby</td><td>MIT</td></tr> <tr><td>j0k3r/graby</td><td>MIT</td></tr>
<tr><td>j0k3r/graby-site-config</td><td>Public domain</td></tr> <tr><td>j0k3r/graby-site-config</td><td>Public domain</td></tr>
<tr><td>j0k3r/php-readability</td><td>Apache-2.0</td></tr> <tr><td>j0k3r/php-readability</td><td>Apache-2.0</td></tr>

View file

@ -19,6 +19,8 @@ use Wallabag\Command\InstallCommand;
class InstallCommandTest extends WallabagTestCase class InstallCommandTest extends WallabagTestCase
{ {
private string $originalDatabaseUrl;
public static function setUpBeforeClass(): void public static function setUpBeforeClass(): void
{ {
// disable doctrine-test-bundle // disable doctrine-test-bundle
@ -38,22 +40,28 @@ class InstallCommandTest extends WallabagTestCase
/** @var Connection $connection */ /** @var Connection $connection */
$connection = $this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection(); $connection = $this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection();
$originalDatabaseUrl = $this->getTestClient()->getContainer()->getParameter('env(DATABASE_URL)'); $this->originalDatabaseUrl = $this->getTestClient()->getContainer()->getParameter('database_url');
$dbnameSuffix = $this->getTestClient()->getContainer()->getParameter('wallabag_dbname_suffix'); $tmpDatabaseName = 'wallabag_test_' . bin2hex(random_bytes(5));
$tmpDatabaseName = 'wallabag_' . bin2hex(random_bytes(5));
if ($connection->getDatabasePlatform() instanceof SqlitePlatform) { if ($connection->getDatabasePlatform() instanceof SqlitePlatform) {
$tmpDatabaseUrl = str_replace('wallabag' . $dbnameSuffix . '.sqlite', $tmpDatabaseName . $dbnameSuffix . '.sqlite', $originalDatabaseUrl); $tmpDatabaseName = $this->getTestClient()->getContainer()->getParameter('kernel.project_dir') . '/data/db/' . $tmpDatabaseName . '.sqlite';
/** @see \Doctrine\DBAL\Tools\DsnParser::parse */
$url = preg_replace('#^((?:pdo-)?sqlite3?):///#', '$1://localhost/', $this->originalDatabaseUrl);
$tmpDatabaseUrl = (string) (new Uri($url))->withPath($tmpDatabaseName);
// Add back the leading "/" that was removed by withPath, and remove the "localhost" part
$tmpDatabaseUrl = str_replace('//localhost', '///', $tmpDatabaseUrl);
} else { } else {
$tmpDatabaseUrl = (string) (new Uri($originalDatabaseUrl))->withPath($tmpDatabaseName); $tmpDatabaseUrl = (string) (new Uri($this->originalDatabaseUrl))->withPath($tmpDatabaseName);
} }
putenv("DATABASE_URL=$tmpDatabaseUrl"); $_ENV['DATABASE_URL'] = $_SERVER['DATABASE_URL'] = $tmpDatabaseUrl;
if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) { if ($connection->getDatabasePlatform() instanceof PostgreSQLPlatform) {
// PostgreSQL requires that the database exists before connecting to it // PostgreSQL requires that the database exists before connecting to it
$tmpTestDatabaseName = $tmpDatabaseName . $dbnameSuffix; $connection->executeQuery('CREATE DATABASE ' . $tmpDatabaseName);
$connection->executeQuery('CREATE DATABASE ' . $tmpTestDatabaseName);
} }
// The environnement has been changed, recreate the client in order to update connection // The environnement has been changed, recreate the client in order to update connection
@ -62,16 +70,18 @@ class InstallCommandTest extends WallabagTestCase
protected function tearDown(): void protected function tearDown(): void
{ {
$databaseUrl = getenv('DATABASE_URL'); $databaseUrl = $_SERVER['DATABASE_URL'];
/** @var Connection $connection */ /** @var Connection $connection */
$connection = $this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection(); $connection = $this->getTestClient()->getContainer()->get(ManagerRegistry::class)->getConnection();
if ($connection->getDatabasePlatform() instanceof SqlitePlatform) { if ($connection->getDatabasePlatform() instanceof SqlitePlatform) {// Remove the real environnement variable
// Remove the real environnement variable $_ENV['DATABASE_URL'] = $_SERVER['DATABASE_URL'] = $this->originalDatabaseUrl;
putenv('DATABASE_URL');
$databasePath = parse_url($databaseUrl, \PHP_URL_PATH); /** @see \Doctrine\DBAL\Tools\DsnParser::parse */
$url = preg_replace('#^((?:pdo-)?sqlite3?):///#', '$1://localhost/', $databaseUrl);
$databasePath = parse_url($url, \PHP_URL_PATH);
if (file_exists($databasePath)) { if (file_exists($databasePath)) {
unlink($databasePath); unlink($databasePath);
@ -80,8 +90,7 @@ class InstallCommandTest extends WallabagTestCase
$testDatabaseName = $connection->getDatabase(); $testDatabaseName = $connection->getDatabase();
$connection->close(); $connection->close();
// Remove the real environnement variable $_ENV['DATABASE_URL'] = $_SERVER['DATABASE_URL'] = $this->originalDatabaseUrl;
putenv('DATABASE_URL');
// Create a new client to avoid the error: // Create a new client to avoid the error:
// Transaction commit failed because the transaction has been marked for rollback only. // Transaction commit failed because the transaction has been marked for rollback only.

View file

@ -41,12 +41,6 @@ class WallabagRestControllerTest extends WallabagApiTestCase
// create a new client instead of using $this->client to be sure client isn't authenticated // create a new client instead of using $this->client to be sure client isn't authenticated
$client = $this->createUnauthorizedClient(); $client = $this->createUnauthorizedClient();
if (!$client->getContainer()->getParameter('fosuser_registration')) {
$this->markTestSkipped('fosuser_registration is not enabled.');
return;
}
$client->getContainer()->get(Config::class)->set('api_user_registration', 1); $client->getContainer()->get(Config::class)->set('api_user_registration', 1);
$client->request('GET', '/api/info'); $client->request('GET', '/api/info');

View file

@ -85,13 +85,6 @@ class SecurityControllerTest extends WallabagTestCase
public function testEnabledRegistration() public function testEnabledRegistration()
{ {
$client = $this->getTestClient(); $client = $this->getTestClient();
if (!$client->getContainer()->getParameter('fosuser_registration')) {
$this->markTestSkipped('fosuser_registration is not enabled.');
return;
}
$client->followRedirects(); $client->followRedirects();
$client->request('GET', '/register'); $client->request('GET', '/register');
$this->assertStringContainsString('registration.submit', $client->getResponse()->getContent()); $this->assertStringContainsString('registration.submit', $client->getResponse()->getContent());

View file

@ -1,10 +1,13 @@
<?php <?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
require __DIR__ . '/../vendor/autoload.php'; require __DIR__ . '/../vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
(new Filesystem())->remove(__DIR__ . '/../var/cache/test'); (new Filesystem())->remove(__DIR__ . '/../var/cache/test');
if (!isPartialRun()) { if (!isPartialRun()) {

View file

@ -0,0 +1,7 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require __DIR__ . '/../vendor/autoload.php';
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');

View file

@ -1,10 +1,16 @@
<?php <?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
require __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../vendor/autoload.php';
$kernel = new AppKernel('prod', false); putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'prod');
putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '0');
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
$kernel = new AppKernel($_SERVER['APP_ENV'], (bool )$_SERVER['APP_DEBUG']);
//$kernel = new AppCache($kernel); //$kernel = new AppCache($kernel);
// When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter

View file

@ -1,5 +1,6 @@
<?php <?php
use Symfony\Component\Dotenv\Dotenv;
use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\ErrorHandler\Debug;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
@ -19,9 +20,15 @@ if (isset($_SERVER['HTTP_CLIENT_IP'])
} }
require __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../vendor/autoload.php';
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = 'dev');
putenv('APP_DEBUG=' . $_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = '1');
(new Dotenv())->bootEnv(dirname(__DIR__) . '/.env');
Debug::enable(); Debug::enable();
$kernel = new AppKernel('dev', true); $kernel = new AppKernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals(); $request = Request::createFromGlobals();
$response = $kernel->handle($request); $response = $kernel->handle($request);
$response->send(); $response->send();