Skip to content

Commit

Permalink
Replaces importDump.php with PagePort import script (#212)
Browse files Browse the repository at this point in the history
* 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`
  • Loading branch information
vedmaka authored Sep 18, 2024
1 parent d9fb896 commit 36807fe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions _sources/canasta/DockerSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Expand Down
29 changes: 11 additions & 18 deletions _sources/scripts/run-maintenance-scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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 &
Expand Down

0 comments on commit 36807fe

Please sign in to comment.