PHP is 7.2.3. Tried downgrading to 7.1 – the same. It turns out I don’t even have to add any code. When I open editor and just click save – I get an error.
Hi @psubraty
sorry for the delayed response, I went through a bout of sickness and lots of work to catch up.
That’s odd, this error only happens for PHP version < 5.5
PHP is 7.2.3. Tried downgrading to 7.1 – the same.
Are you sure your server is using php 7? it is possible that you have v7 installed, but if you do not configure your apache server to use it, it is quite possible that it is using v5.4.
Follow these instructions to double check your php version.
Yes, I triple checked. Also right now using this method You pointed. PHP Version 7.1.15
mmmh, that’s odd. I am using php 7 on my local machine. I will give it a try to see if I can reproduce the error.
Hi. Were You able to find the problem?
Psubraty
No. Did you check you php with php_info() or using the command line php -version?
As I sad, I triple checked. Including all the methodes mentioned in the link You provided. I really know the version of PHP on my server. I can give You an access to the wordpress to test it.
It’s very strange, this is an error that occurs with php versions prior to v7.
So the only issue can I see is that your php is somewhat referring to an older library… maybe your installation of pho had an issue and some libraries were not upgraded to v7?
My suggestion would be to upgrade your server to v7.3 (the lastest version) or at least try to re-install your current version.
If this is not possible then the only solution is to hack the plugin code to make it compatible with your specific setup, in which case I can tell you which lines to change to make it work.
let me know what you want to do.
This is a shared server, I’ll ask my hosting provider about the possible problems You mentioned. Meanwhile it would be great if You could provide the code to be replaced 🙂
HI there, I realised I never got back to your with the code…
Replace the lines 188-193 which have this code,
$pattern = get_shortcode_regex();
// if shortcode 'book' exists
if ( preg_match_all( '/'. $pattern .'/s', $content, $matches )
&& array_key_exists( 2, $matches )
&& !empty(array_intersect( $shortcodes, $matches[2] )) ) {
with the following lines of code,
$pattern = get_shortcode_regex();
$search_shortcodes = array_intersect( $shortcodes, $matches[2] );
// if shortcode 'book' exists
if ( preg_match_all( '/'. $pattern .'/s', $content, $matches )
&& array_key_exists( 2, $matches )
&& !empty($search_shortcodes) ) {
Hi,
I am able to save this change, but I am getting an error while loading any page:
Warning: array_intersect(): Argument #2 is not an array in /home/users/woof/public_html/ogrod.ptakipolskie.pl/wp-content/plugins/post-my-contact-form-7/public/class-cf7-2-post-public.php on line 189
Now I can’t go back to old code neither. This time I get an error while trying to save code:
Line 193: && !empty(array_intersect( $shortcodes, $matches[2] )) ) {
Can’t use function return value in write context
-
This reply was modified 7 years, 1 month ago by
psubraty.
ah, yes, I see my mistake, apologies for this, please replace with the following lines instaed,
$pattern = get_shortcode_regex();
$isMatch = preg_match_all( '/'. $pattern .'/s', $content, $matches );
if($isMatch) $search_shortcodes = array_intersect( $shortcodes, $matches[2] );
// if shortcode 'book' exists
if ( $isMatch && array_key_exists( 2, $matches ) && !empty($search_shortcodes) ) {
works like charm, thank You!
oh, one more thing. Will this change in code be implemented in “standard”? If not, it will get updated after next patch and I will have to switch code manually?
No i don’t plan to put it as std. The only people who have faced a similar issue (in this plugin or other plugins i maintain) where all running php 5.6 or lower. The issue systematically went away when users upgraded to php 7.
So i am still not sure why you’re facing this issue with php 7.2. It is possible the php installation was incomplete and some libraries are from5.6.
Could you test your installation on a different server running php 7?