Skip to content

Commit df1aef0

Browse files
scarastronk7
authored andcommitted
Install solr extension from source
Using 2.4.0 release + custom patch (from macports project) seems to be the only working combination right now. Read the comments in the code and the links there. Resolves solr issue in moodlehq#16, waiting for the upstream as described in moodlehq#19
1 parent e2db66d commit df1aef0

File tree

3 files changed

+69
-4
lines changed

3 files changed

+69
-4
lines changed

root/tmp/setup/php-extensions.sh

+14-3
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,29 @@ docker-php-ext-install -j$(nproc) gd
5858
docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/
5959
docker-php-ext-install -j$(nproc) ldap
6060

61-
# Note solr is missing. Ref: https://github.com/moodlehq/moodle-php-apache/issues/19
62-
6361
# Memcached, MongoDB, Redis, APCu, igbinary.
6462
pecl install memcached mongodb redis apcu igbinary
65-
docker-php-ext-enable memcached redis apcu igbinary
63+
docker-php-ext-enable memcached mongodb redis apcu igbinary
6664

6765
# ZIP
6866
docker-php-ext-configure zip --with-libzip
6967
docker-php-ext-install zip
7068

7169
echo 'apc.enable_cli = On' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini
7270

71+
# Install custom solr extension. Last release (2.4.0) is not working at all
72+
# with php72 and php73 and upstream has not either! Solution:
73+
# - current master (as of 21th May 2019):
74+
# https://github.com/php/pecl-search_engine-solr/commit/98a8bf540bcb4e9b2e1378cce2f3a9bf6cd772b8
75+
# - this patch, applied already upstream:
76+
# https://github.com/php/pecl-search_engine-solr/commit/744e32915d5989101267ed2c84a407c582dc6f31
77+
# So, following the experience with Macports, and https://bugs.php.net/bug.php?id=75631
78+
# we are going to try 2.4.0 release + macports patch. Old, but working right now.
79+
# References:
80+
# - https://github.com/moodlehq/moodle-php-apache/issues/16 (part of the php72 image discussion)
81+
# - https://github.com/moodlehq/moodle-php-apache/issues/19 (awaiting for a better solution)
82+
/tmp/setup/solr-extension.sh
83+
7384
# Install Microsoft dependencies for sqlsrv.
7485
# (kept apart for clarity, still need to be run here
7586
# before some build packages are deleted)

root/tmp/setup/solr-extension.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
# Install 2.4.0 release version + macports patch. Only combination working right now.
6+
# See #16 and #19 for more information.
7+
hash=6e9e097c981e810d452657f23bf1945b7955f3cf
8+
patch=https://raw.githubusercontent.com/macports/macports-ports/master/php/php-solr/files/php72.patch
9+
10+
# Download our 'tagged' source code from git.
11+
echo "Downloading solr extension source archive (${hash})"
12+
curl --location \
13+
https://github.com/php/pecl-search_engine-solr/archive/${hash}.tar.gz \
14+
-o /tmp/pecl-search_engine-solr-${hash}.tar.gz
15+
16+
# Download patch
17+
if [ -n $patch ]; then
18+
curl --location \
19+
$patch \
20+
-o /tmp/solr.patch
21+
fi
22+
23+
# Extract the compressed archive.
24+
cd /tmp
25+
tar -xvzf pecl-search_engine-solr-${hash}.tar.gz
26+
cd pecl-search_engine-solr-${hash}
27+
28+
# Apply the patch
29+
if [ -n $patch ]; then
30+
patch -p0 < ../solr.patch
31+
fi
32+
33+
# Compile the extension as required by a manual PECL installation.
34+
echo "Compile solr extension"
35+
phpize
36+
./configure
37+
make
38+
39+
# Finally, install it.
40+
echo "Install solr extension"
41+
make install
42+
43+
# Remove all the sources.
44+
echo "Cleanup temporary folder and files"
45+
rm /tmp/pecl-search_engine-solr-${hash} -rf
46+
rm /tmp/pecl-search_engine-solr-${hash}.tar.gz -f
47+
rm /tmp/solr.patch -f
48+
49+
# Enable it.
50+
docker-php-ext-enable solr
51+
52+
# Done with this hack.
53+
# Please, follow https://github.com/moodlehq/moodle-php-apache/issues/19.

tests/fixtures/test.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
'intl',
88
'ldap',
99
'memcached',
10+
'mongodb',
1011
'mysqli',
1112
'oci8',
1213
'pgsql',
1314
'redis',
14-
// 'solr', Ref: https://github.com/moodlehq/moodle-php-apache/issues/19
15+
'solr',
1516
'soap',
1617
'sqlsrv',
1718
'xsl',

0 commit comments

Comments
 (0)