Skip to content

Error when preloading is enabled #5522

@Gwemox

Description

@Gwemox

API Platform version(s) affected: 3.1.6 - 3.1.7

Description
After upgrading to v3.1.7 api-platform crashes on production where opcache.prelaod is enabled. On v3.1.5 worked fine.
Warning: Cannot declare interface ApiPlatform\Api\FilterInterface, because the name is already in use

Error similar to api-platform/api-platform#2284

How to reproduce

  • Upgrade to v3.1.7
  • Make sure opcache.preload is enabled. (I use the Symfony's default preload script);
    • opcache.preload_user=www-data
    • opcache.preload=/var/www/config/preload.php
  • Open /api or any api-platform endpoint

Possible Solution
Check if interface exist before declaration.

src/Metadata/FilterInterface.php

class_alias(FilterInterface::class, \ApiPlatform\Api\FilterInterface::class);

to

if (!interface_exists(\ApiPlatform\Api\FilterInterface::class)) {
    class_alias(FilterInterface::class, \ApiPlatform\Api\FilterInterface::class);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions