Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

GCS: Execution of filter 'upload_dir' takes a long time #52

Open

Description

@stijnjanmaat

The 'upload_dir' filter makes it a GCS-path. In the core wp_upload_dir function, the first time in the request it is called wp_mkdir_p checks existence of the folder on the GCS bucket. The subsequent filter calls are taken from cache in the wp_upload_dir function.

Maybe we're doing something wrong, but this first time execution of 'wp_mkdir_p' takes a very long time, 0.8 seconds often, run from a PHP7.1 GAE instance, built with this Google codelabs toturial.

This probably has to do with the StreamWrapper being much slower than the regular filesystem operations. Is this supposed to happen? Or is there any way we can get around this, or cache this check?

Thanks!

Activity

  1. michalzubkowicz commented on Jul 5, 2019

    @michalzubkowicz

    It's not a fault of of this plugin directly.
    wp_mkdir_p tries to create directory with path like gs://xxx, what obviously is not possible. You can see in the code that after protocol remove it points to root of filesystem. Worst thing is that wp_upload_dir is executed hundreds of times during processing of template, so every directory is tried to create over and over again.

    For us helped a lot using object cache plugin like:
    https://wordpress.org/plugins/redis-cache/

    Without it rendering time makes this plugin unusable.

    Second solution is to change definition of function wp_upload_dir to have default false, but I didn't test it much.

    In our case finally this problems is caused by WPML, because it's using function wp_upload_dir not wp_get_upload_dir (which doesn't try to create directory)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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