From 8b3d41cfa738056efadcb8c3dc935ab956fada93 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sat, 31 Aug 2024 14:31:16 +0400 Subject: [PATCH 1/4] Replaces importDump.php with PagePort import script * Introduces new `MW_AUTO_IMPORT` env variable which is `1` by default * Always loads the `PagePort` extension of the `MW_AUTO_IMPORT` is set * Performs automatic PagePort import from the `MW_IMPORT_VOLUME` if the volume is present and the ENV is set --- Dockerfile | 3 ++- _sources/canasta/DockerSettings.php | 4 +++ _sources/scripts/run-maintenance-scripts.sh | 29 ++++++++------------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/Dockerfile b/Dockerfile index b30e9f02..a6de5ae6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1059,7 +1059,8 @@ ENV MW_AUTOUPDATE=true \ MEDIAWIKI_MAINTENANCE_AUTO_ENABLED=false \ MW_SENTRY_DSN="" \ MW_USE_CACHE_DIRECTORY=1 \ - APACHE_REMOTE_IP_HEADER=X-Forwarded-For + APACHE_REMOTE_IP_HEADER=X-Forwarded-For \ + MW_AUTO_IMPORT=1 COPY _sources/configs/msmtprc /etc/ COPY _sources/configs/mediawiki.conf /etc/apache2/sites-enabled/ diff --git a/_sources/canasta/DockerSettings.php b/_sources/canasta/DockerSettings.php index 361e26ee..026d4618 100644 --- a/_sources/canasta/DockerSettings.php +++ b/_sources/canasta/DockerSettings.php @@ -606,6 +606,10 @@ function isEnvTrue( $name ): bool { $wgUseCdn = false; // make sure profile is not cached } +if ( getenv( 'MW_AUTO_IMPORT' ) ) { + wfLoadExtension( 'PagePort' ); +} + # Include all php files in config/settings directory foreach ( glob( getenv( 'MW_CONFIG_DIR' ) . '/settings/*.php' ) as $filename ) { if ( is_readable( $filename ) ) { diff --git a/_sources/scripts/run-maintenance-scripts.sh b/_sources/scripts/run-maintenance-scripts.sh index cca2bb9d..cad17ea0 100644 --- a/_sources/scripts/run-maintenance-scripts.sh +++ b/_sources/scripts/run-maintenance-scripts.sh @@ -361,25 +361,16 @@ run_autoupdate () { } run_import () { - # Import dumps if any + # Import PagePort dumps if any if mountpoint -q -- "$MW_IMPORT_VOLUME"; then - echo "Found $MW_IMPORT_VOLUME, checking for XML dump presence.." - local FILES_IMPORTED=0 - for filename in $MW_IMPORT_VOLUME/*.xml; do - echo "Found $filename file, importing.." - php maintenance/importDump.php \ - --username-prefix="" \ - --memory-limit=max \ - --report 1 \ - "$filename" - FILES_IMPORTED=$((FILES_IMPORTED + 1)) - done - if [ "$FILES_IMPORTED" -gt "0" ]; then - echo "Running post-import maintenance scripts.." - php maintenance/rebuildrecentchanges.php - php maintenance/initSiteStats.php + echo "Found $MW_IMPORT_VOLUME, running PagePort import.." + XML_TEST=($(find $MW_IMPORT_VOLUME -maxdepth 1 -name "*.xml")) + if [ ${#XML_TEST[@]} -gt 0 ]; then + echo "WARNING! The directory contains XML files, did you forget to migrate the dump to PagePort?" + return fi - echo "Imported $FILES_IMPORTED files!" + php "extensions/PagePort/maintenance/importPages.php --source $MW_IMPORT_VOLUME" + echo "Imported completed!" fi } @@ -391,7 +382,9 @@ else fi # Run import after install and update are completed -run_import +if isTrue "$MW_AUTO_IMPORT"; then + run_import +fi jobrunner & transcoder & From c6e05661524cdc0c990910daaaa23cab17156d84 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Sat, 31 Aug 2024 18:19:35 +0400 Subject: [PATCH 2/4] Fixes a typo --- _sources/scripts/run-maintenance-scripts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_sources/scripts/run-maintenance-scripts.sh b/_sources/scripts/run-maintenance-scripts.sh index cad17ea0..049e8b33 100644 --- a/_sources/scripts/run-maintenance-scripts.sh +++ b/_sources/scripts/run-maintenance-scripts.sh @@ -369,7 +369,7 @@ run_import () { echo "WARNING! The directory contains XML files, did you forget to migrate the dump to PagePort?" return fi - php "extensions/PagePort/maintenance/importPages.php --source $MW_IMPORT_VOLUME" + php extensions/PagePort/maintenance/importPages.php --source "$MW_IMPORT_VOLUME" echo "Imported completed!" fi } From 70f1f4980c345635f3140615ac73383609ed2317 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Wed, 18 Sep 2024 15:56:26 +0400 Subject: [PATCH 3/4] Runs import as maintenance user --- _sources/scripts/run-maintenance-scripts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_sources/scripts/run-maintenance-scripts.sh b/_sources/scripts/run-maintenance-scripts.sh index 049e8b33..e9e51be4 100644 --- a/_sources/scripts/run-maintenance-scripts.sh +++ b/_sources/scripts/run-maintenance-scripts.sh @@ -369,7 +369,7 @@ run_import () { echo "WARNING! The directory contains XML files, did you forget to migrate the dump to PagePort?" return fi - php extensions/PagePort/maintenance/importPages.php --source "$MW_IMPORT_VOLUME" + php extensions/PagePort/maintenance/importPages.php --source "$MW_IMPORT_VOLUME" --user 'Maintenance script' echo "Imported completed!" fi } From 3615a7b24086de4e34e2139e212282e3b3ff7de8 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Wed, 18 Sep 2024 16:13:45 +0400 Subject: [PATCH 4/4] Updates PagePort to `65cb6908c852c5483efa5f8022b8bb97b5adb208` --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a6de5ae6..feb4a3f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -546,7 +546,7 @@ RUN set -x; \ # PagePort && git clone --single-branch -b master https://github.com/WikiTeq/PagePort.git $MW_HOME/extensions/PagePort \ && cd $MW_HOME/extensions/PagePort \ - && git checkout -q a6b800c9b3f58c151cdda4ec2f1aa396536c3a7d + && git checkout -q 65cb6908c852c5483efa5f8022b8bb97b5adb208 # R RUN set -x; \