Skip to content

Commit

Permalink
Merge pull request #981 from enterprisemediawiki/30.x-php7
Browse files Browse the repository at this point in the history
Use PHP7
  • Loading branch information
jamesmontalvo3 committed Jun 19, 2018
2 parents ba3b0fa + a8089b5 commit 5a2c6d5
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 15 deletions.
5 changes: 3 additions & 2 deletions config/core/MezaCoreExtensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ list:
version: "{{ mediawiki_default_branch }}"
- name: PageForms
repo: https://gerrit.wikimedia.org/r/mediawiki/extensions/PageForms.git
version: tags/4.3
# 18-JUN-2018 with several fixes since latest version 4.3.1
version: "0ba6735e3daeb0e4a82568c8f9b5e90416a59a0f"
- name: DismissableSiteNotice
repo: https://gerrit.wikimedia.org/r/mediawiki/extensions/DismissableSiteNotice.git
version: "{{ mediawiki_default_branch }}"
Expand Down Expand Up @@ -202,7 +203,7 @@ list:
legacy_load: true
- name: TalkRight
repo: https://github.com/enterprisemediawiki/TalkRight.git
version: extreg
version: master
legacy_load: true
- name: AdminLinks
repo: https://gerrit.wikimedia.org/r/mediawiki/extensions/AdminLinks.git
Expand Down
2 changes: 2 additions & 0 deletions config/core/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ mediawiki_version: "1.30.0"
# Branch to use on many extensions extensions and skins
mediawiki_default_branch: "REL1_30"

# PHP version
php_ius_version: "php70u"

# Parsoid v0.5.2 on May 2, 2016
# MediaWiki REL1_28 branch point on 2016-10-25
Expand Down
10 changes: 5 additions & 5 deletions src/roles/apache-php/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
include_role:
name: composer

- name: Ensure PHP profiling configured
include: profiling.yml
# http://docs.ansible.com/ansible/playbooks_roles.html#dynamic-versus-static-includes
static: yes
when: m_setup_php_profiling
# - name: Ensure PHP profiling configured
# include: profiling.yml
# # http://docs.ansible.com/ansible/playbooks_roles.html#dynamic-versus-static-includes
# static: yes
# when: m_setup_php_profiling

# If profiling not enabled, disable MongoDB if it exists (e.g. profiling had
# previously been enabled)
Expand Down
110 changes: 110 additions & 0 deletions src/roles/apache-php/tasks/mssql_driver_for_php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
---

- name: Ensure prerequisites for sqlsrv in place
yum:
name: "{{item}}"
state: installed
with_items:
- re2c
- gcc-c++

# Install ODBC driver
- name: install mssql-server repo (CentOS, RedHat)
get_url:
url: https://packages.microsoft.com/config/rhel/7/prod.repo
dest: /etc/yum.repos.d/mssql-release.repo
when: ansible_distribution in ['CentOS', 'RedHat']

- name: Ensure conflicting ODBC drivers removed
yum:
name: "{{item}}"
state: absent
with_items:
- unixODBC-utf16
- unixODBC-utf16-devel

- name: install MS ODBC driver package
yum:
name: msodbcsql17
state: latest
environment:
ACCEPT_EULA: 'y'
notify:
- restart apache

- name: install ODBC driver devel package
yum:
name: unixODBC-devel
state: latest


# If mssql tools desired:
# sudo ACCEPT_EULA=Y yum install mssql-tools
# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
# echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
# source ~/.bashrc


#
# Compiling the PHP drivers with PECL with PHP 7.2 requires a more recent GCC than the default:
#
#
# # CENTOS: sudo yum install centos-release-scl
# - name: install centos-release-scl
# yum:
# name: centos-release-scl
# state: latest
# when: ansible_distribution == "CentOS"
#
# - name: install devtoolset-7 on CentOS
# yum:
# name: devtoolset-7
# state: latest
# when: ansible_distribution == "CentOS"
#
# # REDHAT: sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
# - name: enable rhel-server-rhscl-7-rpms
# yum:
# name: devtoolset-7
# state: latest
# enablerepo: rhel-server-rhscl-7-rpms
# when: ansible_distribution == "RedHat"
#
# - name: Enable devtoolset-7 with SCL
# shell: "scl enable devtoolset-7 bash"


#
# Install sqlsrv drivers from PECL
#
# Or maybe this is better?
# sudo pecl install sqlsrv-5.2.0
# sudo pecl install pdo_sqlsrv-5.2.0
#
- name: Install sqlsrv and pdo_sqlsrv PECL packages
pear:
name: "{{ item }}"
state: present
with_items:
- pecl/sqlsrv
- pecl/pdo_sqlsrv
notify:
- restart apache

- template:
src: 30-pdo_sqlsrv.ini.j2
dest: /etc/php.d/30-pdo_sqlsrv.ini
owner: root
group: root
mode: 0644
notify:
- restart apache

- template:
src: 20-sqlsrv.ini.j2
dest: /etc/php.d/20-sqlsrv.ini
owner: root
group: root
mode: 0644
notify:
- restart apache
52 changes: 50 additions & 2 deletions src/roles/apache-php/tasks/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
- name: Get IUS repository
include: ius.yml

- name: Ensure PHP IUS packages installed
- name: Ensure PHP 5.6 packages removed
yum:
name: "{{item}}"
state: installed
state: absent
with_items:
- php56u
- php56u-cli
Expand All @@ -63,6 +63,54 @@
- php56u-mcrypt
- php56u-mssql

- name: Ensure PHP IUS packages installed
yum:
name: "{{item}}"
state: installed
with_items:
# The following items exist in php56u, php70u, php71u, and php72u
- "{{ php_ius_version }}"
- "{{ php_ius_version }}-cli"
- "{{ php_ius_version }}-common"
- "{{ php_ius_version }}-devel"
- "{{ php_ius_version }}-gd"
- "{{ php_ius_version }}-pspell"
- "{{ php_ius_version }}-snmp"
- "{{ php_ius_version }}-xml"
- "{{ php_ius_version }}-xmlrpc"
- "{{ php_ius_version }}-mysqlnd"
- "{{ php_ius_version }}-pdo"
- "{{ php_ius_version }}-odbc"
- "{{ php_ius_version }}-process"
- "{{ php_ius_version }}-bcmath"
- "{{ php_ius_version }}-intl"
- "{{ php_ius_version }}-opcache"
- "{{ php_ius_version }}-soap"
- "{{ php_ius_version }}-mbstring"

# php56u has memcache and memcached; php7Xu only has memcached
# legacy Meza used php56u-pecl-memcache
- "{{ php_ius_version }}-pecl-memcached"

# Available for php56u, php70u, and php71u. NOT for php72u.
- "{{ php_ius_version }}-mcrypt"

# Available for php56u and php70u. NOT php71u or php72u
- "{{ php_ius_version }}-pear"

# Not available for PHP 7, due to being built into PHP 7
# - php56u-pecl-jsonc

# Not available in PHP 7
# Get alternative method of accessing SQL Server:
# https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-2017#installing-the-drivers-on-red-hat-7
# - php56u-mssql

- name: Install MS SQL driver for PHP
include: mssql_driver_for_php.yml
when: install_ms_sql_driver is defined and install_ms_sql_driver


- name: Write php.ini file
template:
src: php.ini.j2
Expand Down
2 changes: 1 addition & 1 deletion src/roles/apache-php/tasks/profiling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
state: present
with_items:
- pecl/xhprof-beta
- pecl/mongo
- pecl/mongodb

- name: Ensure XHGui present
git:
Expand Down
1 change: 1 addition & 0 deletions src/roles/apache-php/templates/20-sqlsrv.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=sqlsrv.so
1 change: 1 addition & 0 deletions src/roles/apache-php/templates/30-pdo_sqlsrv.ini.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extension=pdo_sqlsrv.so
5 changes: 2 additions & 3 deletions src/roles/apache-php/templates/httpd.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ ServerRoot "/etc/httpd"
# LoadModule foo_module modules/mod_foo.so
#
Include conf.modules.d/*.conf
LoadModule php5_module modules/libphp5.so

<IfModule unixd_module>
#
Expand Down Expand Up @@ -426,7 +425,7 @@ Listen 8080

{% if m_setup_php_profiling -%}
# Prepends file all files to initiate profiling
php_admin_value auto_prepend_file "{{ m_profiling_xhgui_directory }}/external/header.php"
# php_admin_value auto_prepend_file "{{ m_profiling_xhgui_directory }}/external/header.php"
{% endif %}

</VirtualHost>
Expand Down Expand Up @@ -473,7 +472,7 @@ Listen 8090
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule !php5_module>
<IfModule !php7_module>
<FilesMatch "\.ph(p[2-6]?|tml)$">
Order allow,deny
Deny from all
Expand Down
8 changes: 7 additions & 1 deletion src/scripts/unite-the-wikis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ WIKI="$wiki_id" php "$m_scripts/uniteTheWikis.php" "--mergedwiki=$wiki_id" "--so
# letting bash control repeated calls to the script gets around this.
while [[ `WIKI="$wiki_id" php "$m_scripts/uniteTheWikis.php" --imports-remaining` != "0" ]]; do
echo -e "\n\n*********************\nANOTHER ROUND\n******************\n"
echo "Clean out hoards of temp files"
find /tmp -name "importupload*" -print0 | xargs -0 rm -f
echo "run uniteTheWikis.php again"
WIKI="$wiki_id" php "$m_scripts/uniteTheWikis.php"
done;

Expand All @@ -107,7 +110,7 @@ echo "Beginning rebuildrecentchanges.php script"
WIKI="$wiki_id" php "$m_mediawiki/maintenance/rebuildrecentchanges.php"

# num_pages=$(WIKI="$wiki_id" php "$m_mediawiki/maintenance/showSiteStats.php" | grep "Total pages" | sed 's/[^0-9]*//g')
num_pages=$(mysql -s -r -e"USE wiki_issmerged; SELECT page_id FROM page ORDER BY page_id DESC LIMIT 1;" | sed -n "1p")
num_pages=$(mysql -s -r -e"USE wiki_$wiki_id; SELECT page_id FROM page ORDER BY page_id DESC LIMIT 1;" | sed -n "1p")
end_id=0
delta=2000

Expand All @@ -126,6 +129,9 @@ start_id=$(($end_id + 1))
echo "Running final refreshLinks.php in case there are more pages beyond num_pages, beyond $start_id"
WIKI="$wiki_id" php "$m_mediawiki/maintenance/refreshLinks.php" "$start_id"

# Merge watchlists
echo -e "\nMerging watchlists..."
WIKI="$wiki_id" php "$m_scripts/uniteTheWikis.php" --merge-watchlists

# Don't clean up merge table until rebuild all and images are imported. That
# way if this needs to stop and restart it won't try to reimport.
Expand Down
15 changes: 14 additions & 1 deletion src/scripts/uniteTheWikis.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ public function __construct () {

$this->addOption( 'imports-remaining', 'How many imports left' );

$this->addOption( 'merge-watchlists', 'Do merging of watchlists' );
}

public function execute () {

if ( $this->hasOption( 'cleanup' ) ) {
$this->output( "Do cleanup" );
$this->cleanupDatabase();
}

Expand All @@ -116,8 +118,14 @@ public function execute () {
return; // don't want the \n at the end of this function
}

else if ( $this->hasOption( 'merge-watchlists' ) ) {
$this->output( 'Merging watchlists...' );
$this->mergeWatchlists();
}

// if there's already stuff in the merge table, process it
else if ( $this->checkDB() ) {
$this->output( "Importing new set" );
$this->importSet();
}

Expand All @@ -128,9 +136,9 @@ public function execute () {
// 1. Merge user groups (if they were sysop in one wiki, they're sysop in the merged)
// 2. Then go pull all the pages to merge from the source wikis
else {
$this->output( "Merge user groups, get pages" );
$this->mergeUserGroups();
$this->getPages();
$this->mergeWatchlists();
}

$this->output( "\n" ); // basically always want to end with a newline
Expand Down Expand Up @@ -592,6 +600,11 @@ protected function cleanupDatabase () {
*/
protected function mergeWatchlists () {

if ( ! $this->checkDB() ) {
$this->output( "\nFailed to get config from database" );
exit;
}

// Get distinct list of users
$usersDBResult = $this->getWatchlistUsers();

Expand Down

0 comments on commit 5a2c6d5

Please sign in to comment.