From 36807fe776d3604869183ed856b414874d89c275 Mon Sep 17 00:00:00 2001 From: Vedmaka Date: Wed, 18 Sep 2024 17:54:14 +0400 Subject: [PATCH] Replaces importDump.php with PagePort import script (#212) * 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 * Runs import as maintenance user * Updates PagePort to `65cb6908c852c5483efa5f8022b8bb97b5adb208` --- Dockerfile | 5 ++-- _sources/canasta/DockerSettings.php | 4 +++ _sources/scripts/run-maintenance-scripts.sh | 29 ++++++++------------- 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index b30e9f02..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; \ @@ -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..e9e51be4 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" --user 'Maintenance script' + 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 &