Conversion of Resource (stream) in php bringing unexpected results

Asked

Viewed 15 times

1

Environments

  • Local
    • AS: Linux Mint 19.3;
    • Bench: Postgresql 12.2 (Ubuntu 12.2-2.pgdg18.04+1);
    • PHP: 7.3.17-1+ubuntu18.04.1+deb.sury.org+1.
  • Amazon
    • AS: Amazon Linux 2018 V1 - Beanstalk V2.9.3;
    • Bank (RDS): Postgresql 12.2 on x86_64-pc-linux-gnu;
    • PHP: 7.3.15

I have a queue table that has a field like bytea, it stores various information on json, when retrieved in PHP it is identified as a Resource (stream)...

In the local environment, the conversion using stream_get_contents, works normally... but in AWS environment (machine created through Beanstalk + Pipeline) no, example:

Local

// Antes da conversão
var_dump(stream_get_meta_data($r['job']));

// Resultado
array (size=7)
  'timed_out' => boolean false
  'blocked' => boolean true
  'eof' => boolean false
  'stream_type' => string 'MEMORY' (length=6)
  'mode' => string 'w+b' (length=3)
  'unread_bytes' => int 0
  'seekable' => boolean true

// Conversão
$r['job'] = stream_get_contents($r['job']);

// Resultado
var_dump($r['job']);
string(532) '{"class":"common\jobs\EmailJob","from": ........'

AWS

// Antes da conversão
var_dump(stream_get_meta_data($r['job']));

// Resultado
array (size=7)
  'timed_out' => boolean false
  'blocked' => boolean true
  'eof' => boolean false
  'stream_type' => string 'MEMORY' (length=6)
  'mode' => string 'w+b' (length=3)
  'unread_bytes' => int 0
  'seekable' => boolean true

// Conversão
$r['job'] = stream_get_contents($r['job']);

// Resultado
var_dump($r['job']);
string(1077) "x7b22636c617373223a22636f6d6d6f6e5c5c6a6f62735c5c456d61696c4a6f62222c2266726f6d223a7b2272616661656c2e7769746....."

The code was tested locally by other developers, including in Windows environment, and this problem did not occur... What may be causing this conversion divergence on the server?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.