Skip to content

Commit ea82a2d

Browse files
committed
build: pin the SMW 7 set and rebuild data after an upgrade
- SMW, maps, mermaid, modern-timeline, compound-queries, scribunto and SESP pinned to the versions this release was reviewed against; a caret range let 7.2.1 resolve to 7.3.1, which added a required rebuild step - SRF pinned to a commit rather than a branch head - rebuildData runs in the background once the wiki is serving, keyed on the SMW version, and is skipped for a fresh install
1 parent 22e58a2 commit ea82a2d

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

‎mediawiki/build/Dockerfile‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,22 @@ RUN set -x; \
242242
# https://raw.githubusercontent.com/CanastaWiki/RecommendedRevisions/1df2c155b67658d999f96cc7f6e5408ab8f56243/1.43.yaml
243243
RUN set -x; \
244244
cd $MW_HOME \
245-
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-media-wiki:^7.2.1 \
245+
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-media-wiki:7.3.1 \
246246
# SRF is installed via git clone below (OSL fork), not via composer
247-
&& COMPOSER=composer.local.json composer require --no-update mediawiki/mermaid:^6.0 \
248-
&& COMPOSER=composer.local.json composer require --no-update professional-wiki/modern-timeline:^4.0 \
249-
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-compound-queries:^4.0 \
250-
&& COMPOSER=composer.local.json composer require --no-update mediawiki/maps:^14.2 \
251-
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-scribunto:^3.0 \
252-
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-extra-special-properties:^5.0 \
247+
&& COMPOSER=composer.local.json composer require --no-update mediawiki/mermaid:6.0.2 \
248+
&& COMPOSER=composer.local.json composer require --no-update professional-wiki/modern-timeline:4.0.0 \
249+
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-compound-queries:4.0.1 \
250+
&& COMPOSER=composer.local.json composer require --no-update mediawiki/maps:14.2.1 \
251+
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-scribunto:3.0.0 \
252+
&& COMPOSER=composer.local.json composer require --no-update mediawiki/semantic-extra-special-properties:5.0.2 \
253253
## SRF (git clone from OSL fork, register with composer for dependency resolution)
254254
&& cd $MW_HOME/extensions \
255255
## dev-master-smw7 is dev-master merged with upstream 6.0.0, which requires SMW >= 7.2.
256256
## dev-master stays on the 5.2.0 line for deployments still running SMW 6.
257-
&& git clone --depth 1 -b dev-master-smw7 https://github.com/OpenSemanticLab/SemanticResultFormats.git SemanticResultFormats \
257+
## Pinned: it is a branch head, so an unpinned clone makes two builds of the
258+
## same commit differ.
259+
&& git clone -b dev-master-smw7 https://github.com/OpenSemanticLab/SemanticResultFormats.git SemanticResultFormats \
260+
&& git -C SemanticResultFormats checkout --quiet ba8d6d8758eb2b16b0d5e8d0860a350c54f51558 \
258261
&& cd $MW_HOME \
259262
&& jq '.extra."merge-plugin".include += ["extensions/SemanticResultFormats/composer.json"]' < composer.local.json > tmp.$$.json && mv tmp.$$.json composer.local.json \
260263
&& cd $MW_HOME/extensions \
@@ -395,6 +398,9 @@ RUN set -x; \
395398
# Increase value for run maintenance script before web service started
396399
ENV MW_AUTOUPDATE=true \
397400
MW_MAINTENANCE_UPDATE=8 \
401+
# Changing this triggers a one-off semantic data rebuild on the next start,
402+
# in the background, because SMW 7.3 changed how some values are stored.
403+
MW_SMW_VERSION=7.3.1 \
398404
MW_MAINTENANCE_CIRRUSSEARCH_UPDATECONFIG=1 \
399405
MW_MAINTENANCE_CIRRUSSEARCH_FORCEINDEX=1 \
400406
MW_MAINTENANCE_ULS_INDEXER=1 \

‎mediawiki/build/run.sh‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,34 @@ a2enconf servername > /dev/null 2>&1
425425

426426
#apachectl -e info & #run in the background
427427

428+
# SMW 7.3 changed how URL, Annotation URI and Email values are stored and needs
429+
# a data rebuild, or queries silently miss values containing %2F, an apostrophe
430+
# or a brace, and on the SPARQLStore also parentheses and non-ASCII letters.
431+
# Run in the background: the wiki serves throughout, and on a large wiki this
432+
# takes hours. The marker lives in $MW_VOLUME, which is a named volume and so
433+
# survives recreating the container, and records the SMW version so the rebuild
434+
# happens once per upgrade. A new wiki has nothing to rebuild and the run costs
435+
# seconds, so it is not special cased: InstallSettings.php sits in the image
436+
# layer, which makes "is this a fresh install" false on every recreate, and a
437+
# recreate is exactly how an upgrade arrives.
438+
SMW_REBUILD_MARKER="$MW_VOLUME/maintenance_smw_rebuildData.info"
439+
if [ "$MW_AUTOUPDATE" == 'true' ] && [ -n "$MW_SMW_VERSION" ] \
440+
&& [ "$(cat "$SMW_REBUILD_MARKER" 2>/dev/null)" != "$MW_SMW_VERSION" ]; then
441+
echo "SMW version changed to $MW_SMW_VERSION, rebuilding semantic data in the background"
442+
# The rebuild runs as www-data, but the marker is written by this shell,
443+
# which is root: $MW_VOLUME is root owned and www-data cannot write there.
444+
# Writing it inside the su would fail after the rebuild had already
445+
# succeeded, and the rebuild would then repeat on every start.
446+
(
447+
if su -s /bin/bash -c "nohup php $MW_HOME/extensions/SemanticMediaWiki/maintenance/rebuildData.php -v" $WWW_USER; then
448+
echo "$MW_SMW_VERSION" > "$SMW_REBUILD_MARKER"
449+
echo "SMW data rebuild finished"
450+
else
451+
echo "SMW data rebuild failed, it will be retried on the next start"
452+
fi
453+
) &
454+
fi
455+
428456
su -s /bin/bash -c '/mwjobrunner.sh &' www-data #run in the background as www-data, fixes https://www.mediawiki.org/wiki/Topic:Tn0u0v07qa9cb9v8
429457
su -s /bin/bash -c '/mwmaintenance.sh &' www-data
430458
if [ "$MW_AUTOBUILD_SITEMAP" == 'true' ]; then

0 commit comments

Comments
 (0)