nguyenanhung / codeigniter3-vercel-skeleton

CodeIgniter v3 Vercel Skeleton Application
https://codeigniter3-vercel-skeleton.vercel.app/
3 stars 3 forks source link

PHP in HTML script tag cut off #4

Open R-N opened 16 hours ago

R-N commented 16 hours ago

I'm using bs-charts. I'm loading the data by echoing JSON into JS variable in HTML script tag (It's far from ideal, I know). Somehow it breaks into uh I don't how to put it.

Here's my template.

    <script src="<?=base_url();?>assets/js/bs-charts.js"></script>
    <script>
      var dataChartPesananHarian = {
        "type": "bar",
        "data": {
          "labels": <?=json_encode(array_map(create_function('$o', 'return $o->HARI;'), $dataPesananHarian));?>,
          "datasets": [
            {
              "label": "Pesanan Bulanan",
              "backgroundColor": "#0041ff",
              "borderColor": "rgba(78, 115, 223, 1)",
              "data": <?=json_encode(array_map(create_function('$o', 'return $o->JUMLAH;'), $dataPesananHarian));?>
            }
          ]
        },
        ...

It becomes this. It's really just cut off there.

    <script src="https://raja-laundry.vercel.app/assets/js/bs-charts.js"></script>
    <script>
      var dataChartPesananHarian = {
        "type": "bar",
        "data": {
          "labels": <script async data-explicit-opt-in="true" data-cookie-opt-in="true" src="https://vercel.live/_next-live/feedback/feedback.js"></script>

If I open it from incognito window, Vercel's script doesn't get added but it's still cut off at the same point.

    <script src="https://raja-laundry.vercel.app/assets/js/bs-charts.js"></script>
    <script>
      var dataChartPesananHarian = {
        "type": "bar",
        "data": {
          "labels": 

I don't know if the issue is with Vercel or the CI or my project. It ran fine locally, but the environments are different, so it doesn't mean much.

R-N commented 1 hour ago

Okay I found it. Yeah there is an error right there, due to PHP version difference (obsolete function removed). However I still find it weird that no errors were shown even in the raw HTML, it's just cut off. Is there a debug flag for this? The previous one was db_debug and this wasn't a db error.

A PHP Error was encountered

nguyenanhung commented 6 minutes ago

Hey @R-N , the problem is in create_function, this is a dangerous function, usually in production platforms this function is rarely enabled :)

My advice: You should not use this function in the future, it will potentially contain many security errors.

nguyenanhung commented 2 minutes ago

@R-N I just found it in the official documentation: https://www.php.net/manual/en/function.create-function.php

This function has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0. Relying on this function is highly discouraged.

and, Vercel run is PHP 8.3.0