PHP 5.6 to PHP 7.4 Issue

PHP 5.6 to PHP 7.4 Issue

ItherIther Posts: 3Questions: 1Answers: 0
edited December 2022 in Free community support

I recently upgraded my site from PHP 5.6 to 7.4 and immediately noticed none of my SSP:simple tables are working. If I downgrade my site back to 5.6 they work fine and in dev they do the same--5.6 works, 7.4 doesn't. What I see is that the query runs and keeps running until it hits my memory limit (which is at 1.5GB right now for testing).

I have no no idea why this is suddenly an issue.

Datatables 1.10 and I am using the latest SSP.class from the git.

I recognize that my $table below may not be ideal -- it worked fine all this time. I did, however, rewrite it according to the standard design on here where I entered the actual table. It still just kept running until I ran out of memory.

The error I get is this:

DataTables warning: table id=tabledt - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1

Which translates to: Fatal error: Allowed memory size of 2147483648 bytes exhausted (tried to allocate 316674048 bytes)

In 5.6 my table renders in less than 2 seconds.

Thanks everyone for any help you can provide! :smile:

DT setup

                processing: true,
        serverSide: true,
        ajax: { 
            url: "<?php echo SITE_URL; ?>/action.php/search/flightsearch",
            type: "POST"
        },

PHP script

$dbDetails = array(
            'host' => DBASE_SERVER,
            'user' => DBASE_USER,
            'pass' => DBASE_PASS,
            'db'   => DBASE_NAME
        );
        
        $table = "(SELECT a.id, a.code, a.flightnum, a.depicao, b.name AS 'depairport', a.deptime, a.arricao, c.name AS 'arrairport', a.arrtime, a.distance, a.flighttime
                        FROM wat_schedules AS a
                        INNER JOIN phpvms_airports AS b
                        ON a.`depicao` = b.`icao`
                        INNER JOIN phpvms_airports AS c
                        ON a.`arricao` = c.`icao`
                        WHERE a.code != 'WAX' AND a.code !='WAE') temp";
        
        $primaryKey = 'id';
        
        $columns = array(
            array( 'db' => 'code' ),
            array(
                'db' => 'flightnum',
                'dt' => 0,
                'formatter' => function ( $d, $row) {
                    return $row[code] . $d;
                }
            ),
            array(
                'db' => 'depicao',
                'dt' => 1,
                'formatter' => function ($d, $row) {
                    return '<strong>' . $d . '</strong><br/>' . $row[depairport] ;
                }
            ),
            array( 'db' => 'depairport' ),
            array(
                'db' => 'deptime',
                'dt' => 2,
                'formatter' => function ($row) {
                    return $row . '<br/><small> UTC</small>';
                }
            ),
            array(
                'db' => 'arricao',
                'dt' => 3,
                'formatter' => function ($d, $row) {
                    return '<strong>' . $d . '</strong><br/>' . $row[arrairport] ;
                }
            ),
            array( 'db' => 'arrairport' ),
            array(
                'db' => 'arrtime',
                'dt' => 4,
                'formatter' => function ($row) {
                    return $row . '<br/><small> UTC</small>';
                }
            ),
            array(
                'db' => 'distance',
                'dt' => 5,
                'formatter' => function ($row) {
                    return $row . ' nm';
                }
            ),
            array( 'db' => 'flighttime',
                'dt' => 6,
                'formatter' => function ($row) {
                    return $row . ' hrs';
                }
            )
        );
        
        return SSP::simple($_GET, $dbDetails, $table, $primaryKey, $columns);

Replies

  • ItherIther Posts: 3Questions: 1Answers: 0

    Disregard! I found the problem.

    In 7.4 if you use something like $row[columnname] it has to be $row['columnname'] in order to work.

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Thanks for the update. Sounds like the syntax has been tightened up (I didn't actually don't you could reference an array element without quotes in 5.x!).

    Allan

Sign In or Register to comment.