opencats / OpenCATS

Applicant Tracking System (maintained code base)
http://www.opencats.org
Other
511 stars 243 forks source link

Installation failed in PHP-7 #171

Open libregeek opened 7 years ago

libregeek commented 7 years ago

Tried to install OpenCATS (master branch) in PHP-7.0.13 (Fedora 25 running MariaDB-10.1.19). Following is the error message:

PHP MySQL extension (mysql) is not loaded. Check your settings in php.ini.

The above error is due to the following check in lib/InstallationTests.php

if (!self::DEBUG_FAIL && extension_loaded('mysql') && function_exists('mysql_connect'))
        {
            echo '<tr class="pass"><td>PHP MySQL extension (mysql) is loaded.</td></tr>';
            return true;
        }

There is also another check in index.php

if (!function_exists('mysql_connect') || !function_exists('session_start'))
{
    die('CATS Error: All required PHP extensions are not loaded.');
}

mysql_connect is deprecated as of PHP-5.5 and it's removed in PHP-7. Refer: http://www.php.net/mysql_connect

I think we should use extension_loaded() method instead of function_exists(). http://php.net/manual/en/function.extension-loaded.php

The root cause of this issue can be solved by changing mysql_connect to mysqli_connect.

Do we need to maintain backward compatibility till PHP-4?

mlespiau commented 7 years ago

Hi,

I think there are more deprecated functions. Now the code needs php 5.6+ as per composer libraries

On Dec 1, 2016 9:08 AM, "Manilal" notifications@github.com wrote:

Tried to install OpenCATS (master branch) in PHP-7.0.13 (Fedora 25 running MariaDB-10.1.19). Following is the error message:

PHP MySQL extension (mysql) is not loaded. Check your settings in php.ini.

The above error is due to the following checking in index.php

if (!function_exists('mysql_connect') || !function_exists('session_start')) { die('CATS Error: All required PHP extensions are not loaded.'); }

and if (!self::DEBUG_FAIL && extension_loaded('mysql') && function_exists('mysql_connect')) { echo 'PHP MySQL extension (mysql) is loaded.'; return true; } mysql_connect is deprecated as of PHP-5.5 and it's removed in PHP-7. Refer: http://www.php.net/mysql_connect

I think we should use extension_loaded() method instead of function_exists(). http://php.net/manual/en/function.extension-loaded.php

I think we should change mysql_connect to mysqli_connect.

Do we need to maintain backward compatibility till PHP-4?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/opencats/OpenCATS/issues/171, or mute the thread https://github.com/notifications/unsubscribe-auth/AACE-W1h41dC_G-l8VKDiUE95asTwYghks5rDrjQgaJpZM4LBUU0 .

libregeek commented 7 years ago

OK. This means it's safe to go for mysqli. Another thought is to use PDO instead of mysqli. This way we could start expanding the application to use other databases (PostgreSQL, Oracle, etc..). It's a long and complex process, but can we start with PDO+MySQL (MariaDB)?

@mlespiau @RussH @skrchnavy @amaisonneuve What are your thoughts?

RussH commented 7 years ago

I expect mysqli is the quick solution - if we went PDO I assume it's only because there's a higher performance database we'd use instead..?!

libregeek commented 7 years ago

I agree that mysqli is the quick solution. I was just trying to see if there are anyone interested in an alternate database.

Can we have a new version compatible with PHP-7, if I quickly fix these issues?

mlespiau commented 7 years ago

Hi @libregeek, probably it will be harder than that. You might want to get an idea of the scope by running this tool https://github.com/sstalle/php7cc

One of the reasons y wanted to move to composer and replace abandoned dependencies such as simple test was to be able to move to php7

libregeek commented 7 years ago

You are right @mlespiau. The scope of this change is really big. I have attached the results of php7cc here. Making the app to work with PHP7 is defintely going to take time. I will initiate a new branch for this.

Another question is about the backward compatibility. If we are sticking only to mysqli, then it might break existing installations. Having both mysqli and mysql in the lib files will duplicate the code and makes it cumbersome to fix bugs. So I think PDO is a better option. opencats-php7cc.txt

libregeek commented 7 years ago

@mlespiau thanks for pointing me to php7cc. It's an excellent tool

skrchnavy commented 7 years ago

I also support using an ORM, my doubt is if it is possible to extract objects from DB to use existing DB structure and do further migrations using some tools. Writing manual migrations is time consuming and risky process, fortunately we need to support just one DB type migration.

libregeek commented 7 years ago

I did a quick fix to make OpenCATS running in PHP-7. It was really a nasty attempt. It seems the original authors didn't have any clue on how to share DB object across the application. I saw at least 3 places in which the DB connection is instantiated. I didn't touched other deprecated methods since the basic functionality is working fine. Here is the results of the latest compatibility check using php7cc opencats-php7cc-161207a.txt

skrchnavy commented 7 years ago

I found repo from @rankinp where are thes commits: https://github.com/rankinp/OpenCATS/commits/patch-1 https://github.com/rankinp/OpenCATS/commits/patch-2 Could be helpful in this issue.

cptr13 commented 7 years ago

Throwing my opinion in on this. I have been putting workarounds in the documentation and install videos. For example, Ubuntu 16.04 defults to php7. The documentation is written to clearly walk people through installing phpp5.6 through an additional repository. Centos7 defaults to php5.5, I did the same thing in that.

This, from my perspective, works fine for a while. At some point we will need to upgrade php compatibility.

One potential issue that comes from doing this (especially in Ubuntu 16.04+) is if someone has a machine with app#1 that requires php7 and app#2 that requires php5.6. I'm under the impression that it's possible, but I haven't managed to do it yet, so I don't know. That could be a big stumbling block for someone in that situation to adopt OpenCATS.

My point is this, if you guys are discussing these changes as a fix...cool. If it's a temporary band-aid to deal with the problem, I think the documentation will have it covered fine for a while...and maybe time/efforts are better spent on other things.

What do y'all think?

KamalJoshiDelhi commented 5 years ago

One potential issue that comes from doing this (especially in Ubuntu 16.04+) is if someone has a machine with app#1 that requires php7 and app#2 that requires php5.6. I'm under the impression that it's possible, but I haven't managed to do it yet, so I don't know. That could be a big stumbling block for someone in that situation to adopt OpenCATS.

Hi OpenCATS Team, I have been a user of OpenCATS but had to stop using it because of this issue somewhere around mid 2017... Please let me know if there is any progress on this issue and if OpenCATS now works with another APP that uses php7...

KamalJoshiDelhi commented 5 years ago

Hi Team, In continuation of my earlier comment yesterday I thought of reporting the progress since yesterday... I am using 'CATS Version 0.9.3 Inferno. Powered by CATS' and was not able to use my ATS, as due to some other important APP of mine needing me to upgrade my server to php7.0... was desperately looking for a solution to run both OpenCATS and the other APP of mine on same server...

Finally it could be achieved after I implemented all the changes suggested in the commit https://github.com/libregeek/OpenCATS/commit/f9c51749a1961cddfc572640bdd2e87a2e00f093

Fixed opencats#171 Used mysqli procedural methods instead of mysql mehods. This is a quick fix to make OpenCATS compatible with PHP7. Showing 16 chaged files with 105 additions and 102 deletions.

The purpose of my writing back to you guys is 2 fold... One, I thought, this will help your other users who are facing a similar situation to be able to use the suggested quickfix method of using OpenCATS with php7...

Second is the error log file messages after it has started running successfully shows some issues still unattended with fonts and labels... As I am not a technical programer, I could not make out much of this but I guess it is because of this on my index page now I am not able to view the 'Hiring Overview' graph... The error is copied from my error log below and if a solution for this can be suggested to me it would be great...

=============================== [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1696 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1719 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1696 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1719 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1696 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1719 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1696 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1719 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1696 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1719 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1696 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: Only variables should be passed by reference in /home/mywebserver/public_html/ats/lib/DataGrid.php on line 1719 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: A non well formed numeric value encountered in /home/mywebserver/public_html/ats/lib/artichow/inc/Label.class.php on line 238 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: A non well formed numeric value encountered in /home/mywebserver/public_html/ats/lib/artichow/inc/Axis.class.php on line 335 [13-Dec-2018 09:23:24 Etc/GMT] PHP Notice: A non well formed numeric value encountered in /home/mywebserver/public_html/ats/lib/artichow/inc/Axis.class.php on line 320 [13-Dec-2018 09:23:24 Etc/GMT] PHP Fatal error: Uncaught Error: Call to undefined function split() in /home/mywebserver/public_html/ats/lib/artichow/inc/Font.class.php:252 Stack trace:

0 /home/mywebserver/public_html/ats/lib/artichow/inc/Label.class.php(522): awTTFFont->getTextWidth(Object(awText))

1 /home/mywebserver/public_html/ats/lib/artichow/inc/Axis.class.php(719): awLabel->draw(Object(awDrawer), Object(awPoint), 0)

2 /home/mywebserver/public_html/ats/lib/artichow/inc/Axis.class.php(590): awAxis->drawLabels(Object(awDrawer))

3 /home/mywebserver/public_html/ats/lib/artichow/Plot.class.php(522): awAxis->draw(Object(awDrawer))

4 /home/mywebserver/public_html/ats/lib/artichow/Image.class.php(308): awPlot->drawEnvelope(Object(awDrawer), 25, 10, 388, 206)

5 /home/mywebserver/public_html/ats/lib/artichow/Graph.class.php(256): awImage->drawComponent(Object(BarPlotDashboard))

6 /home/mywebserver/public_html/ats/lib/GraphGenerator.php(355): awGraph->draw()

7 /home/mywebserver/public_html/ats/modules/graphs/GraphsUI.php(460): pipelineStatisticsGraph->draw()

8 /home/mywebserver/publ in /home/mywebserver/public_html/ats/lib/artichow/inc/Font.class.php on line 252

===============================

The code is presented here as it appears in error log file... Kamal Joshi New Delhi India

KamalJoshiDelhi commented 5 years ago

Could get the graphs back on my dashboard by solving: PHP Fatal error: Uncaught Error: Call to undefined function split() in /home/mywebserver/public_html/ats/lib/artichow/inc/Font.class.php:252

Used explode instead of split in line 252 and line 195 of lib/artichow/inc/Font.class.php

Rest of the error messages stay as it is...

RussH commented 5 years ago

Hi @KamalJoshiDelhi thanks for the feedback. @libregeek submitted what a proof of concept PHP v7 compatibility. A more fully developed commit for PHPv7 built on his work and was submitted by @gohanman in #362 It'll be tested and added into the next release.

jsaqqa commented 5 years ago

Hello guys, any idea when I can test a version of OpenCATS over php 7.x?