mcguffin / acf-openstreetmap-field

WordPress ACF Field for OpenStreetMap
https://wordpress.org/plugins/acf-openstreetmap-field/
GNU General Public License v3.0
107 stars 21 forks source link

Providers are not loaded properly in the admin #61

Closed Ale- closed 3 years ago

Ale- commented 3 years ago

The map is blank in the field widget in the admin. The problem seems to be related to a null provider value. It seems the problem is related to this block in Leaflet Provider:

if ( is_null( $this->leaflet_providers ) ) { 
     $this->leaflet_providers = json_decode( $core->read_file( 'etc/leaflet-providers.json' ), true );    
}

That is related to this condition in Plugin.php:

if ( ! WP_Filesystem() ) return false;

As WP_Filesystem is false, provider is not being read properly so the map is blank.

My quick&dirty workaround right now is to hardcode the provider I'm using in the JS code, replacing it through functions.php.

This happens on a Wordpress 5.6 served by PHP 7.4.3

Ale- commented 3 years ago

After studying a bit more it seems a problem of permissions. It seems that www-data has to be the owner of all the wordpress tree to WP_Filesystem to return something else than false.

mcguffin commented 3 years ago

Thanks for bringing this to my attention! I wasn't aware, that WP_Filesystem() always checks for writeability, which is not needed in that case. I'll fix this in the upcoming release!