This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 9 replies, has 2 voices.

Last updated by Bobby 2 months, 3 weeks ago.

Assigned support staff: Bobby.

Author Posts
July 5, 2019 at 12:25 pm #4151295

givt-sp.-z-o.o.J

CDN plugins like Google Cloud Storage are using filter upload_dir, which is replacing local urls to CDN based like hidden link.

In wmpl code you are using function wp_upload_dir() in files:
class-wpml-cache-directory.php
class-wpml-ls-model-build.php
class-wpml-flags.php
wpml-admin-lang-switcher.class.php

wp_upload_dir without parameters tries to create directory if it doesn't exist. What causes slow down of processing mostly in function filter_flag_url, because this directory cannot be created and it tries to create it over in over again. It also affect slow storage like S3.

In places when don't need to create directory (especially on page render) you should use everywhere wp_get_upload dir, or wp_upload_dir with second parameter set to false. After that change page rendering is 10 times faster.

July 6, 2019 at 1:46 am #4154237

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

thank you for your suggestions , I will be updating our developers regarding this and will update you here once i have some news

July 8, 2019 at 5:53 pm #4164805

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

if possible are you able to provide us with some additional data regarding the slow rending using your CDN and the difference afterwards ?

how are you currently measuring the speed of rendering ?

as we have not had such reports it is important to have as much information as possible so we can verify that this is not being caused by the CDN

July 9, 2019 at 7:40 am #4168205

givt-sp.-z-o.o.J

Rendering is caused not by CDN itself, but wp_mkdir_p() in wp_upload_dir() and the way you use wp_upload_dir();, because it every time tries to create directory. WP creators 3 years ago created even special parameter ($create_dir) to avoid such cases:

function wp_upload_dir( $time = null, $create_dir = true, $refresh_cache = false )

There is a discussion in their issue tracker why this parameter appeared, because directories should not be created on page rendering.

We are measuring rendering speed for example by:
curl -o /dev/null -s -w 'Total: %{time_total}s\n' hidden link etc

Of coourse on local machine

July 9, 2019 at 4:49 pm #4173243

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

do you by any chance have any data that points to wp_upload_dir() function ? any screenshots of that data would be helpful

unfortunately i am not able to visit the link you provided above

July 16, 2019 at 3:26 pm #4221739

givt-sp.-z-o.o.J

What data do you mean? Place in code? Path to file that is tried to create?

With storage plugins there are paths like:
hidden link

July 16, 2019 at 6:55 pm #4223397

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

I have been in contact with our second tier regarding this and what they are asking for is some further data, any data that points to wp_upload_dir() function

we would like to know what points you to believe that it is wp_upload_dir() function causing the issue

you mentioned in the beginning of your ticket that changing it caused your rendering to speed up, how are you measuring your speed ? do you have any screenshots of the measurements before and after ?

if possible please provide us with any additional information you have pointing towards the wp_upload_dir() function

July 17, 2019 at 11:14 am #4229329

givt-sp.-z-o.o.J

OK.

I'm measuring rendering speed by example:
curl -o /dev/null -s -w 'Total: %{time_total}s\n' hidden link

I know that it's reason because when I've replaced all ocurrences from wp_upload_dir() in WPML code to wp_get_upload() problem was solved.

Also I know why it's happening, because wp_upload_dir by default tries to create directory in filesystem, but when someone is using any CDN plugin links to upload files are not in filesystem but for example hidden link or hidden link.

Every time page is opened this function when it's running without parameters is trying to create directory, which cannot be created because it's not local.

Please forward all my messages to second tier, because everything is explained briefly there.

July 25, 2019 at 12:51 pm #4283273

givt-sp.-z-o.o.J

Any update on this?

July 25, 2019 at 10:03 pm #4286165

Bobby
Supporter

Languages: English (English )

Timezone: America/Los_Angeles (GMT-07:00)

Hello,

our developers have been updated about this

I have been asked if you currently have a working example that you can provide us with access ?

We need to see how it was and how after the fixes.

i have enabled a private field reply for access to a working example

The topic ‘[Closed] filter_flag_url function causes massive slow down of site when using CDN.’ is closed to new replies.