Hi,
A developer in our team detected a couple of issues and proposed the following solutions:
1. PHP Warning: is_writable(): open_basedir restriction in effect. File(/www/site_root_dir_here/) is not within the allowed path(s): (/www/site_root_dir_here/public:/www/site_root_dir_here/mysqleditor:/www/site_root_dir_here/web:/www/site_root_dir_here/deploy:/www/site_root_dir_here/deployment:/www/site_root_dir_here/deployments:/usr/share:/tmp) in /www/site_root_dir_here/public/wp-content/plugins/types/vendor/toolset/types/embedded/views/image.php on line 392
Solution (suppress e_warning with @ error control operator):
$dir = dirname( $img ) . DIRECTORY_SEPARATOR;
if ( ! @is_writable( $dir ) || ! is_dir( $dir ) ) {
return self::$__cache->setCache(
"writable_path_$img",
new WP_Error( __CLASS__ . '::' . __METHOD__, 'Destination dir not writable' )
);
}
=====================================
2. PHP Warning: in_array() expects parameter 2 to be array, string given in /www/site_root_dir_here/public/wp-content/plugins/wp-views/application/controllers/cache/meta/invalidator.php on line 126
PHP Fatal error: Uncaught Error: [] operator not supported for strings in /www/site_root_dir_here/public/wp-content/plugins/wp-views/application/controllers/cache/meta/invalidator.php:130
Solution (additionally check if is_array, as in some occasions empty string is returned, which is fine for get_transient() result, but not ok for in_array() and array[] operations):
$transient = $this->transient_manager->get_transient( $meta_cache::VISIBLE_KEY );
if ( false === $transient || ! is_array($transient) ) {
return;
}
if ( in_array( $meta_key, $transient, true ) ) {
return;
}
$transient[] = $meta_key;
=====================================
We hope that helps Toolset improves further.
Thank you,
Bowo
Hello Bowo and thank you for contacting the Toolset support and suggesting these improvements.
However, we'll need a context to be on the same page. Can you tell us what steps to follow to reproduce these issues?
This way, we can test before and after implementing any fix. And maybe that will reveal other things.
I wonder if this does happen with a default theme and only Toolset plugins? Or maybe this also happens because of a 3rd party component(theme/plugin)? In both cases, we'll do our best to fix them.
Thanks Jamal.
It is probably due to some custom code we implemented, or bad interaction with other plugins on the site. We currently do not have the resources to track down the exact cause and figure out steps to reproduce it, but will let you when we do.
Additionally, the developer on our team that sent the code fixes above said this about the two issues:
Warnings - ok, theoretically, maybe, could be due to some local specific configs. But I doubt.
Fatal error - absolute fail, they must know how empty string (!== false) could get into array function and what will be the result.
Thank you.
One more thing, our developer actually edited Toolset View's plugin files on these locations to prevent the warnings and fatal error, which can bring our site down.
/wp-content/plugins/wp-views/application/controllers/cache/meta/invalidator.php
Line 122:38
/wp-content/plugins/types/vendor/toolset/types/embedded/views/image.php
Line 392:20
So, on next plugin update, we either have to do it again, or hope that you'll put in place stop gap measures / fixes.
Indeed, if the plugins get updated, you will need to apply your patch on them again.
From my side, I can't really escalate a bug or suggestion to our developers without having clear steps to reproduce it, otherwise, it maybe just an exception that appears only on your website and probably because of a compatibility conflict or custom code.
If you can provide the steps to reproduce this issue, first, I'll have to confirm them on a clean install before escalating it to the developers. I will also prepare a clear bug report, with steps to reproduce, and a reproduction in one of our test sites.
So, I'll set this ticket as waiting for your feedback, which should keep it open for a couple of weeks, and once you provide more details, I'll continue from my side.