wordpressmagento-1.9fishpig

Why Fishpig is asking for write-permission on wp-includes/i10n.php?


I'm updating Fishpig Wordpress-Integration to version 4.5.1.5 (with addons ACF, CPT, CS, Root, Multisite) in a new ansible-deployment. Now I get the follwoing error in the Magento-Backend :

Permissions     The following file must be writable: /path/to/magento/wp/wp-includes/l10n.php

Why at all should a magento-module have write-permissions on a wordpress-core-file?

We prefer strongly to have separate concerns, so that the wp-core-files can't be compromised by anything from magento-side.

The questions are:

Would be great to get some clarification about this point.


Solution

  • This file needs to be modified because both Magento and WordPress have a PHP function with the same name, specifically the translation function:

    function __($args);
    

    It is not possible to have multiple functions in PHP with the same name. The only way to include the WP code base into Magento and make it available is to stop either Magento or WordPress from defining this function. The module chooses to modify the WP file instead of the Magento file.

    The modification it makes it a simple one. It simply wraps the function definition in WordPress with a call to function_exists. This checks whether the function has already been defined (ie. in Magento) and if it has, it doesn't define it again. If it hasn't been defined, it defines it.

    if (!function_exists('__')) {
      function __($args);
    }
    

    This allows WordPress to work on it's own and when included into the Magento code. Without this modification, it is not possible to use Magento and WordPress together.

    Write permissions are only required if the file does not include the modification. If the file already includes the modification then write permissions are not required. If you don't want to give write permissions on your live server, have the file modification take place either on a dev/staging server or make the file modification yourself as part of your deployment process.