cedaro / satispress

Expose installed WordPress plugins and themes as Composer packages.
500 stars 48 forks source link

non well formed numeric value encountered in pclzip dependency #149

Closed alapiere closed 3 years ago

alapiere commented 3 years ago

Hi, when composer-update on client website , during development testing :

<br />
<b>Notice</b>:  A non well formed numeric value encountered in <b>/www/wpcontroljengo_729/public/wp-content/plugins/satispress-develop/vendor/pclzip/pclzip/pclzip.lib.php</b> on line <b>1797</b><br />
{"packages":{"

I had debug mode activated on satispress server, so it fails to parse packages.json which returns this notice first .. Obviously it's fine when deactivating WP_DEBUG. Could be quite annoying for debugging , testing and development environments though.

bradyvercher commented 3 years ago

@alapiere That version of PclZip should only be a development dependency that's used for running tests. How exactly did you install SatisPress?

Also, looking at that line of code where the error was generated, I see this:

$v_memory_limit = $v_memory_limit * 1048576;

And that $v_memory_limit variable comes from line 1787:

$v_memory_limit = ini_get('memory_limit');
$v_memory_limit = trim($v_memory_limit);
$last           = strtolower(substr($v_memory_limit, -1));

That would seem to suggest it's a configuration issue with your server. Is that what you're seeing?

alapiere commented 3 years ago

Hi @bradyvercher , I saw you cut dependency with pclzip, so problem solved ! to answer your question, for trace, I donwloaded zip then run composer update to fetch dependencies. I'm not aware of any server misconfiguration, my wp is managed (kinsta).

bradyvercher commented 3 years ago

Thanks for the update, @alapiere. I thought something like that may have been the case. For posterity's sake, WordPress uses a forked/patched version of PclZip as far as I know. The lines from above in the WordPress version look like this:

$v_memory_limit = ini_get('memory_limit');
$v_memory_limit = trim($v_memory_limit);
$v_memory_limit_int = (int) $v_memory_limit;
$last = strtolower(substr($v_memory_limit, -1));

There is that extra line ensuring the value from the ini_get() call is an integer, which is what would have prevented the error you were getting.

In the future, you can download a packaged zip with all the dependencies already bundled from the releases page.

Or if you want to continue installing dependencies with Composer and you're not managing the whole site with Composer, then use something like this instead:

composer install --no-dev

That will install only the packages needed to run SatisPress and not the ones used for development.

alapiere commented 3 years ago

I now understand better the composer philsophy : I think an even better proper way is to manage the master wordpress installation with composer as well, and pull satispress through git dependency : Doing things this way, a composer install / update always apply --no-dev by default :)