# GN1 annotation page broken ## Tags * assigned: zsloan, pjotrp * priority: high * status: testing * type: bug * keywords: GN1, genenetwork1, annotation, from github ## Tasks * [ ] Fix PHP view * [ ] Fix CKEDITOR ## Description Turns out that it is a PHP page that is not working. Also CKEDITOR is not visible. => https://github.com/genenetwork/genenetwork2/issues/421 From GitHub => http://gn1.genenetwork.org/webqtl/main.py?FormID=annotation The annotations page in GN1 is broken. An exception stack trace is displayed, instead of the annotations page content. ## Info Lily runs a PHP from 2006(!) PHP 5.1.6 (cli) (built: Mar 18 2014 20:48:55) Copyright (c) 1997-2006 The PHP Group Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies In guix-bioinformatics we have ``` php 5.6.40 out /home/gn1/guix-bioinformatics/gn/packages/php.scm:14:2 ``` Even if this page is for windows, it is the best description of using PHP: => https://www.thesitewizard.com/php/install-php-5-apache-windows.shtml On lily: ``` AddType application/x-httpd-php .htm .html ``` And Apache: ``` [root@lily conf]# /usr/sbin/httpd -V Server version: Apache/2.2.3 Server built: Sep 16 2014 11:05:09 Server's Module Magic Number: 20051115:3 Server loaded: APR 1.2.7, APR-Util 1.2.7 Compiled using: APR 1.2.7, APR-Util 1.2.7 Architecture: 64-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with.... -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="run/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="logs/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" ``` This is similar what we have in Guix GN1. No mention of PHP in either. For simplicity we may switch to php-cgi => https://stackoverflow.com/questions/28823252/installing-php-5-3-29-from-sources-on-ubuntu-14-with-apache-2-module => https://www.bobulous.org.uk/coding/apache-php-cgi.html ## Test instance of GN1 I started a test instance that listens on port 8044 and is hosted in this dir and started with: ``` gn1@tux01:~/production/gnshare/gn-pjotr-test . .guix-deploy gn1@tux01 ~/production/gnshare/gn-pjotr-test [env]$ httpd -f `pwd`/etc/pjotr-test-httpd.conf ``` Restart with ``` pkill httpd ; sleep 1 ; httpd -f `pwd`/etc/pjotr-test-httpd.conf ``` Created a file in web/test/index.html and it displays as => http://gn1-pjotr.genenetwork.org/test/index.html Now a php version => http://gn1-pjotr.genenetwork.org/test/index.php works after setting ``` # CUSTOM: Add PHP 5 parsing (via CGI) handler and action ScriptAlias /local-bin /gnu/store/213zqkj0r6q41cqarwkz5x568ybhd62b-profile/bin AddHandler application/x-httpd-php5 php Action application/x-httpd-php5 /local-bin/php-cgi Order allow,deny Allow from all AllowOverride None Order allow,deny Allow from all ``` ## Finding PHP files All files that have ?php are in ./infoshare. Try ``` gn1@tux01:~/production/gnshare/gn-pjotr-test$ grep '?php' -r > phpfiles.txt ``` they end in .htm and .html so we need to wire that together. So adding a test in => http://gn1-pjotr.genenetwork.org/infoshare/manager/test/index.html and updating Addhandler to parse .htm and .html works. ``` AddHandler application/x-httpd-php5 php htm html ``` ## MySQL connector We need to tell GN1 to use a more recent mysql connector and drive it over sockets, rather than the web interface. This requires telling it where the INI file is. This required adding a path for Apache: ``` SetEnv PHP_INI_SCAN_DIR /home/gn1/production/gnshare/gn-pjotr-test ``` and a php.ini file with ``` [Pdo_mysql] pdo_mysql.default_socket= /run/mysqld/mysqld.sock [MySQLi] mysqli.default_socket = /run/mysqld/mysqld.sock ``` Now it remains to replace the mysql connectors with mysqli - a newer driver for PHP. For this we use a translation script from => https://github.com/rubo77/php-mysql-fix/blob/master/fix_mysql.inc.php that gets included with ``` include_once('../includes/fix_mysql.inc.php') ``` At the final step we have to fix CKEDITOR ## CKEDITOR FF console says: ``` Uncaught ReferenceError: CKEDITOR is not defined Ember ``` Turns out that lily URLs were hard-coded in the source. So, that was an easy fix. There are still some complaints about CSS links missing in the browser console, but until someone sees a difference I does not need fixing. Changing the status to testing now. ## Updating production The source code is now in sync on 'master' branch. Now I need to update guix-bioinformatics package to set up the container correctly with Apache httpd.conf.