Menu

support php7 ?

2016-11-02
2020-07-31
  • YoungBin Ko

    YoungBin Ko - 2016-11-02

    MDB2 has not been updated properly since 2012.

    For better performance
    Do you plan to support php 7 ?

     
  • AceStrider1

    AceStrider1 - 2019-01-15

    I have been trying to see if I can get it working with php7 as well. It looks like one can change it to use the MDB2 Beta that uses mysqli driver, but other files I think including the smarty libraries have to change. I have not made much progress myself as I am not a php developer. Just looking to see what I can change in the code to get it working.

    -Adan

     
  • Simone Rossetto

    Simone Rossetto - 2019-10-11

    Hello Adan, starting from your idea of MDB2 beta I made some steps forward in order to have avantfax working on php7.

    Check my commit here https://github.com/droscy/avantfax/commit/c0f96fee62f96e29755f9997d26d8cd9c71aa2c5

    I have not tested sending and receiving faxes (of course the main functions) because, at the moment, I don't have a phone line, but all the other functions seem to work: searching in archive, forwarding archived faxes by email, downloading archived faxes, searching in address book, editing contacts, adding new contacts, changing settings.

    As soon as I can I'll try sending and receiving faxes.

     
  • Simone Rossetto

    Simone Rossetto - 2019-11-28

    I succeded in sending and archving faxes with some fixes to the code. Check them out here https://github.com/droscy/avantfax

     
    • AceStrider1

      AceStrider1 - 2019-11-28
      Post awaiting moderation.
  • Eryck M

    Eryck M - 2019-12-28

    Great job, Simone!
    I have just used your code on github and this is what I am getting:

    PHP Fatal error: Uncaught Error: Call to undefined method MDB2_Error::disconnect() in /var/www/html/avantfax/includes/SQL.php:120\nStack trace:\n#0 /var/www/html/avantfax/includes/SQL.php(100): SQL->disconnect()\n#1 [internal function]: SQL->__destruct()\n#2 {main}\n thrown in /var/www/html/avantfax/includes/SQL.php on line 120

    Not sure what I am missing, though.

    Edit: Ops, that was me being thick, managed to get it loading now.

    Got 2 problems:

    Can't archive faxes or change data, every time I try to do that I get a 500 error from the server.
    GET https://server/avantfax/ajax/archivefax.php?fid=1 500 (Internal Server Error)

    POST https://server/avantfax/admin/conf_modems_edit.php 500 (Internal Server Error)

    This one is just a warning but keeps coming up:

    PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/html/avantfax/includes/AFUserAccount.php on line 687

     

    Last edit: Eryck M 2019-12-29
  • Simone Rossetto

    Simone Rossetto - 2019-12-29

    Hello Eryck, thank for your feedback.

    Can't archive faxes [...] every time I try to do that I get a 500 error from the server.
    GET https://server/avantfax/ajax/archivefax.php?fid=1 500 (Internal Server Error)

    I have the fax archived by script includes/avantfaxcron.php, so probably I didn't tested a manual archiving. Which version of PHP are you using? Which web server and version are you using? Do you have any other error message from web server log?

    Can't [...] change data, every time I try to do that I get a 500 error from the server.
    POST https://server/avantfax/admin/conf_modems_edit.php 500 (Internal Server Error)

    I cannot reproduce this error. Do you have any other error message from web server log?
    I suppose you go to the "/admin" page, then you select "Configure Modem", then you click on the modem you want to edit (do you have a single modem?), then you change something (what you change?) and you get the error. Are you doing something different?
    I have not configured any "Fax Category" so I didn't try those settings.

    This one is just a warning but keeps coming up:
    PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/html/avantfax/includes/AFUserAccount.php on line 687

    It comes up doing what? In which pages?
    Probably it depends on the account (or modem) configurations. Could you post a screenshot of the settings of an account and of a medem? I'll try to configure my Avantfax like your.

    Thank, bye
    Simone

     
    • Eryck M

      Eryck M - 2019-12-29

      Hello Eryck, thank for your feedback.

      Hello Simone, not a problem at all, it's a nice piece of software and your help on getting it to work on PHP 7 has been great!

      Can't archive faxes [...] every time I try to do that I get a 500 error from the server.
      GET https://server/avantfax/ajax/archivefax.php?fid=1 500 (Internal Server Error)
      

      I have the fax archived by script includes/avantfaxcron.php, so probably I didn't tested a manual archiving. Which version of PHP are you using? Which web server and version are you using? Do you have any other error message from web server log?

      My apologies for the lack of information from my part. I am using PHP 7.2.11-1. on a Centos 8.0.1905 box, I run Apache 2.4.37-12. ( Apache/2.4.37 (centos) OpenSSL/1.1.1 mod_fcgid/2.3.9 PHP/7.2.11) .
      I don't get any errors on the server logs at all even running on debug mode, the error I see is just on the webconsole.

      Can't [...] change data, every time I try to do that I get a 500 error from the server.
      POST https://server/avantfax/admin/conf_modems_edit.php 500 (Internal Server Error)
      

      I cannot reproduce this error. Do you have any other error message from web server log?
      I suppose you go to the "/admin" page, then you select "Configure Modem", then you click on the modem you want to edit (do you have a single modem?), then you change something (what you change?) and you get the error. Are you doing something different?
      I have not configured any "Fax Category" so I didn't try those settings.*

      Same thing here, I don't see an error on the server logs, just on the webconsole.
      This happens on anything I want to edit that would go to the database it seems. For example, https://server/avantfax/settings.php , if I try to add anything and hit update, I get a blank page, no errors on the apache logs which is weird.
      If I follow what you describe on configure modem, etc, I also get the same blank page, it happens on anything I want to edit. I have changed things (password, for example), straight on the MySQL database (mariadb-10.3.11-2.) as I can't do it anyway otherwise.

      This one is just a warning but keeps coming up:
      PHP Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/html/avantfax/includes/AFUserAccount.php on line 687
      

      It comes up doing what? In which pages?
      Probably it depends on the account (or modem) configurations. Could you post a screenshot of the settings of an account and of a medem? I'll try to configure my Avantfax like your.

      I just tried to edit something on the admin user (adding something random on the company field, for example), when I click save, I get that warning and the data is not saved.
      Sure thing, attached are a screenshot of an account (admin) and a modem.

      Thanks again, Simone, much appreciated!

      Edit: Something interesting, I have enabled query logging on MariaDB and I tried to edit the only modem I have (ttyIAX0) to add a category I was able to add "General"), the update doesn't show I selected the General category:

      191229 12:25:40 2256 Connect avantfax@localhost as anonymous on avantfax
      2256 Query SET CHARACTER SET 'utf8'
      2256 Query SET NAMES 'utf8'
      2256 Query SELECT * FROM Modems WHERE device = 'ttyIAX0'
      2256 Query UPDATE Modems SET device = 'ttyIAX0', alias = 'ttyIAX0', contact = 'myemail', printer = '', faxcatid = '' WHERE devid = '1'
      2256 Quit

            Weird, right?
      
       

      Last edit: Eryck M 2019-12-29
  • Simone Rossetto

    Simone Rossetto - 2019-12-30

    It seams something wrong writing to database... maybe in MDB2 driver or in database itself. Or, perhaps, in MDB2+php7.2, I don't have a server with php 7.2 to try.

    If you manually change the database, do you see those changes in Avantfax?
    Have you set define('AFDB_ENGINE','mysqli'); (mysqli) in file include/local_config.php?
    Did you setup Avantfax database from sources or did you migrate it from a previous working installation in php5?
    Does database user (configured in include/local_config.php) have the grant to update avantfax tables?

     
    • Eryck M

      Eryck M - 2019-12-30

      It seams something wrong writing to database... maybe in MDB2 driver or in database itself. Or, perhaps, in MDB2+php7.2, I don't have a server with php 7.2 to try.

      That's ok, what is the PHP you are running on yours?

      If you manually change the database, do you see those changes in Avantfax?

      I do see the changes in AvantFax if I change them on the DB.

      Have you set define('AFDB_ENGINE','mysqli'); (mysqli) in file include/local_config.php?

      I have mysqli set there.

      Did you setup Avantfax database from sources or did you migrate it from a previous working installation in php5?

      I installed from your git

      Does database user (configured in include/local_config.php) have the grant to update avantfax tables?

      The user has all grants on the avantfax database.

      Weird or not, fax categories is something I can create on the webui different from other things.
      Just checked that I can edit anything on the Admin settings page, only difference that when I press enter, it goes to a blank page but the data is saved to the DB.

       

      Last edit: Eryck M 2019-12-30
      • Simone Rossetto

        Simone Rossetto - 2019-12-31

        what is the PHP you are running on yours?

        I have PHP 7.0.33 from Debian stretch. I'll try php 7.3.12 on my laptop and I'll let you know the results.

        I installed from your git

        I had a previous database from php5 so, actually, I never tested installing from scratch. I'll try this too, maybe I missed some steps...

         
  • Eryck M

    Eryck M - 2019-12-31

    Take your time, Simone and many thanks for the help.
    Have a smashing new year!

     
  • Simone Rossetto

    Simone Rossetto - 2020-01-02

    Hello Eryck, and happy new year.

    Installing from scratch gives me no issues, either on editing users or modems or categories. The only thing that is not working is changing modem device: the page returns Ok but the device is not changed. I'll investigate on it. However no 500 error at all. I'm suspecting php version be the root cause...

    In the mean time, could you give me the output of "composer show"? I trust composer, but just to be sure we are using the same libraries versions. This is my output:

    pear-pear.php.net/Archive_Tar        1.4.7  
    pear-pear.php.net/Console_Getopt     1.4.2  
    pear-pear.php.net/MDB2               2.5.0b5
    pear-pear.php.net/MDB2_Driver_mysqli 1.5.0b4
    pear-pear.php.net/PEAR               1.10.9 
    pear-pear.php.net/Structures_Graph   1.1.1  
    pear-pear.php.net/XML_Util           1.4.3  
    pear/console_getopt                  v1.4.2 
    pear/mail                            v1.4.1 
    pear/mail_mime                       1.10.3 
    pear/pear-core-minimal               v1.10.9
    pear/pear_exception                  v1.0.0 
    smarty/smarty                        v3.1.33
    
     
  • Eryck M

    Eryck M - 2020-01-02

    Hi Simone!

    Thanks for getting back to me, happy new year!
    Interesting that you don't see the same issue at all, I've been trying all sorts of things but they make no sense at all.
    I just did a composer show and I have the exact same versions you have for the pear packages.

    $ composer show
    pear-pear.php.net/Archive_Tar 1.4.7 This class provides handling of tar files in PHP.
    pear-pear.php.net/Console_Getopt 1.4.2 This is a PHP implementation of "getopt" supporting both
    pear-pear.php.net/MDB2 2.5.0b5 PEAR MDB2 is a merge of the PEAR DB and Metabase php database abstraction layers.
    pear-pear.php.net/MDB2_Driver_mysqli 1.5.0b4 This is the MySQLi MDB2 driver.
    pear-pear.php.net/PEAR 1.10.9 The PEAR package contains:
    pear-pear.php.net/Structures_Graph 1.1.1 Structures_Graph is a package for creating and manipulating graph datastructures. It allows building of directed
    pear-pear.php.net/XML_Util 1.4.3 Selection of methods that are often needed when working with XML documents. Functionality includes creating of attribute lists from arrays, creation of tags, validation of XML names and more.
    pear/console_getopt v1.4.2 More info available on: http://pear.php.net/package/Console_Getopt
    pear/mail v1.4.1 Class that provides multiple interfaces for sending emails.
    pear/mail_mime 1.10.3 Mail_Mime provides classes to create MIME messages
    pear/pear-core-minimal v1.10.9 Minimal set of PEAR core files to be used as composer dependency
    pear/pear_exception v1.0.0 The PEAR Exception base class.
    smarty/smarty

    Do you use MariaDB or MySQL? I ask that as I was seeing issues on my FreePBX and I got them sorted straight away when I swapped MySQL for MariaDB, just wondering if that would make any difference (same box, I use MariaDB).
    I saw something weird yesterday, I logged the SQL queries and tried to run the exact same thing manually on the DB.
    For example,trying to archive a fax, when I run the same statement:

    MariaDB [avantfax]> UPDATE FaxArchive SET faxnumid = '7', companyid = '', faxpath = '/faxes/recvd/2019/12/29/14046019001/000000002', pages = '1', faxcatid = '', didr_id = '0', description = '', lastoperation = '2019-12-29 01:49:22', lastmoduser = '', lastmoddate = '2019-12-29 01:49:22', archstamp = '2019-12-29 01:49:22', modemdev = 'ttyIAX0', userid = '', origfaxnum = '14046019001', inbox = 0, faxcontent = '' WHERE fid = '4';

    I get an error:

    ERROR 1366 (22007): Incorrect integer value: '' for column 'companyid' at row 1
    Looks like it's related to the field being set as '' and not NULL. If I change the statement to companyid = NULL, it works.

    But when I remove the fields that don't have anything (companyid, userid, etc) the query works BUT then the inbox page (URL/avantfax/inbox.php) enters in a constant loop which puzzles me.
    To get that sorted, I have to reinsert at least one fax on the FaxArchive table then it doesn't loop.

    Just thinking what else I could try apart from changing the PHP version.

    Edit: Just downgraded to PHP 7.0 and the problem remains. I am really puzzled to why this is happening, just wondering where else I could have done wrong.

    Something else I just noticed, trying to delete a number from the contacts, MariaDB shows this instead of a delete.

            12 Query    commit
         15116 Connect  avantfax@localhost as anonymous on avantfax
            12 Query    rollback
         15116 Query    SET CHARACTER SET 'utf8'
         15116 Query    SET NAMES 'utf8'
         15116 Query    SET CHARACTER SET 'utf8'
         15116 Query    SET NAMES 'utf8'
         15116 Query    SET CHARACTER SET 'utf8'
         15116 Query    SET NAMES 'utf8'
         15116 Query    SELECT * FROM AddressBook WHERE abook_id = '3'
         15116 Query    SET CHARACTER SET 'utf8'
         15116 Query    SET NAMES 'utf8'
         15116 Quit
    
     

    Last edit: Eryck M 2020-01-02
  • Eryck M

    Eryck M - 2020-01-02

    Unbelievable, I found part of the problem (archiving faxes, setting notes, etc).
    I had to add sql_mode = "" on my mariadb's configuration, after that, those things started working. Found that on ( https://stackoverflow.com/questions/14762904/incorrect-integer-value-for-column-id-at-row-1 ).

    Other problem I got sorted was the following:

    php7:warn] [pid 52606] [client IP] PHP Warning: The magic method __set() must have public visibility and cannot be static in /var/www/html/avantfax/includes/AFUserAccount.php on line 800, referer: https://URL/avantfax/inbox.php

    I went through the AFUserAccount.php and changed from private to public. I am now able to delete/add/change whatever I need anywhere.
    I am just trying to test to see if I can receive a fax properly (send works well) and I think we can say it's working great!

    Edit: And it works, I have everything on send/receive working as intended.
    Thanks a lot for the help, Simone! Let me know if you have any questions or you need me to send you any file to check. Cheers!

     

    Last edit: Eryck M 2020-01-03
  • Simone Rossetto

    Simone Rossetto - 2020-01-06

    Great Eryck, I'm glad to know that your installation is working.
    I'll fix the warning you reported and I'll improve the installation guide.

    Just for completeness, I have MariaDB 10.1.41 but I don't have that setting in my configuration. I'll try to understand why integer values like companyid are set to '' instead of NULL, so to avoid

    ERROR 1366 (22007): Incorrect integer value: '' for column 'companyid' at row 1
    Looks like it's related to the field being set as '' and not NULL. If I change the statement to companyid = NULL, it works.

    Stay tuned ;-)
    Thanks

     
  • Eryck M

    Eryck M - 2020-01-06

    Hi Simone,

    Again, great job on getting this nice piece of software working with PHP 7!
    Just to add, here are the fields I saw having '' instead of NULL.

    ompanyid = ''
    faxcatid = ''
    lastmoduser = ''
    userid = ''
    faxcontent = ''

    Whatever you need from me on this side, just shout!

     
  • AceStrider1

    AceStrider1 - 2020-07-10

    Ok, I am going to try this comming week.

     
  • AceStrider1

    AceStrider1 - 2020-07-24

    I am installing on a test box running Slackware64-Current. I am getting pretty far along using the github repo from Simone. I noticed the new requirments on the INSTALL.TXT but I am trying to see about this dependency:

    "vendor/autoload.php"

    It's not included in anything I have downloaded yet.

     
  • Eryck M

    Eryck M - 2020-07-24

    Been 6 months I've tried this but this is what I have on my vendor/autload.php:

    <?php
    
    // autoload.php @generated by Composer
    
    require_once __DIR__ . '/composer/autoload_real.php';
    
    return ComposerAutoloaderInit07f2e3d6c217d7684b35428487816b00::getLoader();
    

    Looks like it's part of composer?

     
  • Simone Rossetto

    Simone Rossetto - 2020-07-25

    Hello AceStrider1, the autoload.php is created by composer while installing required packages. Or, at least, it shoud be... :-p

     
  • AceStrider1

    AceStrider1 - 2020-07-30

    I got the web front end to load.
    I basically followed the BASH instructions on:

    https://getcomposer.org/download/

    "

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php -r "if (hash_file('sha384', 'composer-setup.php') === 'e5325b19b381bfd88ce90a5ddb7823406b2a38cff6bb704b0acc289a09c8128d4a8ce2bbafcd1fcbdc38666422fe2806') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"

    "
    Ended up Downloading the composer.phar file on to the same web root directory as avantfax.

    I then used ./composer.phar update.

    I not sure how I feel about installing it this way. I don't like having internet access depedencies. I usually like to download and install all the packages manually, but in this case I just went ahead and did it this way.

    ./composer.phar show lists the following:
    pear-pear.php.net/Archive_Tar 1.4.9
    pear-pear.php.net/Console_Getopt 1.4.3
    pear-pear.php.net/MDB2 2.5.0b5
    pear-pear.php.net/MDB2_Driver_mysqli 1.5.0b4
    pear-pear.php.net/PEAR 1.10.12
    pear-pear.php.net/Structures_Graph 1.1.1
    pear-pear.php.net/XML_Util 1.4.5
    pear/console_getopt v1.4.3
    pear/mail v1.4.1
    pear/mail_mime 1.10.9
    pear/pear-core-minimal v1.10.10
    pear/pear_exception v1.0.1
    smarty/smarty v3.1.36

    It would be nice if this information would be on a revised install.txt

    I am running on Slackware64 Current with php 7.4.8 from about a week ago today.
    The site loads, but I have yet to test anything out.

    Years ago I would use Centos for AvantFax but it is not my distribution of choice.

    I know that in May, 2020 Avantfax 3.3.6 came out. I have not investigated what has changed.

    I think it was Early Jan 2019 when I said it might be possible to use MDB2 on the second post on here. It really has taken me this long to find the time to mess around with this software.

    On the backend I would normally used HylaFax, but I when I tried downloading it earlier last week I kept getting a bad gateway error. I downloaded HylaFax+ , but like I said, I have not tested anything out yet.

    Kindest Regards,
    Adan Calderón

     
  • Simone Rossetto

    Simone Rossetto - 2020-07-31

    Hello Adan,

    I not sure how I feel about installing it this way. I don't like having internet access depedencies. I usually like to download and install all the packages manually, but in this case I just went ahead and did it this way.

    You don't have to use composer if you don't want, open the file composer.json where all required packages are listed and install them manually. I think it's a wast of time because that is the purpose of composer "A dependecy manager for PHP", but it's a matter of taste.

    Bye
    Simone

     

Log in to post a comment.