Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

345
Vistas
Why is the inline version not throwing an exception?

I am using the symfony2/finder component to access an Amazon S3 bucket via the stream wrapper of the aws/aws-sdk-php. I was upgrading the finder component from 2.7.4 to its latest 2.7.25 version (2.7.25) via:

composer require symfony/finder:2.7.25

In the process, I discovered that when a directory had a trailing slash in its path no files were found.

    $directory = "s3://{$bucket}/{$taskHandle}/transmissions-{$thread}/"; // valid for finder 2.7.4, yet not >=2.7.5 due to traling slash at the end

I was especially confused as to why there was no exception or error thrown. Yet when debugging I discovered this odder behavior:

This will execute just fine, yet produce empty output (false positive execution):

    $files = (new Finder())
        ->name('*')
        ->in($directory)
        ->filter(
            function (SplFileInfo $file) use ($lastRuntime) {
                return $file->isFile() && ($file->getMTime() < $lastRuntime);
            }
        )
        ->files();

Yet when I remove the inline of the callback and do this instead:

        ...
        ->filter(
            function (SplFileInfo $file) use ($lastRuntime) {
                $isFile = $file->isFile(); // will now trigger a fatal error
                $modifiedAt = $file->getMTime();

                return $isFile && ($modifiedAt < $lastRuntime);
            }
        )

Then I do see the fatal error:

Fatal error: Uncaught RuntimeException: File or directory not found: s3://somebucket/somekey/foo/bar.csv in vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php:738 Stack trace: #0 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(738): trigger_error('File or directo...', 512) #1 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(912): Aws\S3\StreamWrapper->triggerError('File or directo...', 0) #2 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(301): Aws\S3\StreamWrapper->boolCall(Object(Closure), 0) #3 vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php(246): Aws\S3\StreamWrapper->createStat('s3://...', 0) #4 [internal function]: Aws\S3\StreamWrapper->url_stat('s3://...', 0) #5 
... SplFileInfo->getMTime() #6 [internal function]: UserInterface\Con in vendor/aws/aws-sdk-php/src/S3/StreamWrapper.php on line 738

This makes no sense to me. From where I am standing, the code should be equivalent. What I am not getting?

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda