abstracttext
abstracttext copied to clipboard
JSON data table stays empty (Invalid argument supplied for foreach() in JsonContent.php)
Context: At first building the docker container failed on my machine. The culprit was importTextFiles.php which is broken in MediaWiki 1.35.0. Downgrading to MediaWiki 1.34.4 helped, but now I got another problem:
When looking at a Z-Object in the browser, the "JSON data" table stays empty. After a very long loading period (maybe a timeout), I get a warning:
Warning: Invalid argument supplied for foreach() in /var/www/html/includes/content/JsonContent.php on line 142
The raw JSON data table renders just fine. I guess my docker setup needs some more fine-tuning. Which MediaWiki version are you using? And is there anything else I should look into? Do I have to prepare anything specific in the local copy of AbstractText?
Here's the Dockerfile I used most recently for this, I believe it worked (this was back in June 2020).
FROM php:7.3-apache LABEL maintainer="[email protected]"
System dependencies
RUN set -eux;
apt-get update;
apt-get install -y --no-install-recommends
git
librsvg2-bin
imagemagick
# Required for SyntaxHighlighting
python3
;
rm -rf /var/lib/apt/lists/*
Install the PHP extensions we need
RUN set -eux;
savedAptMark="$(apt-mark showmanual)";
apt-get update;
apt-get install -y --no-install-recommends
libicu-dev
;
docker-php-ext-install -j "$(nproc)"
intl
mbstring
mysqli
opcache
;
pecl install apcu-5.1.18;
docker-php-ext-enable
apcu
;
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.' > /dev/null;
apt-mark manual $savedAptMark;
ldd "$(php -r 'echo ini_get("extension_dir");')"/.so
| awk '/=>/ { print $3 }'
| sort -u
| xargs -r dpkg-query -S
| cut -d: -f1
| sort -u
| xargs -rt apt-mark manual;
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false;
rm -rf /var/lib/apt/lists/*
Enable Short URLs
RUN set -eux;
a2enmod rewrite;
{
echo '<Directory /var/www/html>';
echo ' RewriteEngine On';
echo ' RewriteCond %{REQUEST_FILENAME} !-f';
echo ' RewriteCond %{REQUEST_FILENAME} !-d';
echo ' RewriteRule ^ %{DOCUMENT_ROOT}/index.php [L]';
echo '</Directory>';
} > "$APACHE_CONFDIR/conf-available/short-url.conf";
a2enconf short-url
set recommended PHP.ini settings
see https://secure.php.net/manual/en/opcache.installation.php
RUN {
echo 'opcache.memory_consumption=128';
echo 'opcache.interned_strings_buffer=8';
echo 'opcache.max_accelerated_files=4000';
echo 'opcache.revalidate_freq=60';
echo 'opcache.fast_shutdown=1';
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
SQLite Directory Setup
RUN set -eux;
mkdir -p /var/www/data;
chown -R www-data:www-data /var/www/data
MediaWiki setup - specify 1.35.0-wmf.38 version
RUN set -eux;
git clone https://gerrit.wikimedia.org/r/mediawiki/core.git --branch wmf/1.35.0-wmf.38 /var/www/html &&
cd /var/www/html &&
git submodule update --init
RUN apt-get update;
apt-get install -q -y curl nodejs npm
RUN npm install npm@latest -g
RUN cd /var/www/html/extensions &&
git clone https://github.com/google/abstracttext.git AbstractText
RUN cd /var/www/html/extensions/AbstractText/eneyj &&
npm install &&
npm install uuid &&
mkdir config &&
mkdir config/runs &&
node src/scripts/labelMap.js &&
cp src/scripts/calibration-initial.json config/calibration.json &&
node src/scripts/measure.js --chatty &&
node src/scripts/calibrate.js
COPY DockerLocalSettings.php /var/www/html/DockerLocalSettings.php COPY AdditionalLocalSettings.php /tmp/AdditionalLocalSettings.php COPY admin_passwd /tmp/admin_passwd
RUN cd /var/www/html &&
php maintenance/install.php --server http://localhost:8081 --dbtype sqlite --dbpath /var/www/data --scriptpath "" --passfile /tmp/admin_passwd "Lambda" "admin"
RUN cat /tmp/AdditionalLocalSettings.php >> /var/www/html/LocalSettings.php
RUN cd /var/www/html && php maintenance/update.php
RUN cd /var/www/html &&
php maintenance/importTextFiles.php -s "Import data" --prefix "M:" --overwrite extensions/AbstractText/eneyj/data/Z*
RUN chown -R www-data /var/www/data
@arthurpsmith Thanks. A few things got swallowed when you copy-pasted this. My interpretation (with a few "fixes") is here.
I couldn’t find the 1.35.0-wmf.38 branch you recommended, so I checked out tags/1.35.1 instead.
Now MediaWiki is missing some external dependencies. I guess I have some more reading to do.
However, as this is an abandoned proof-of-concept prototype, I guess it doesn’t make much sense to invest any more time. I wanted to play around with it, when I considered joining the abstract team. As this didn’t work out, I will try to keep an eye on what happens here. Best luck! I hope this project will grow and blossom!