geodesicsolutions-community / geocore-community

GeoCore Community, open source classifieds and auctions software
MIT License
9 stars 6 forks source link

SEO addon > General Setting; addons/SEO/admin.php:281 #162

Closed vicos59 closed 2 years ago

vicos59 commented 2 years ago

I found a bug on PHP 8.0 / 8.1 when click on SEO addon > General Settings


TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in /addons/SEO/admin.php:281 Stack trace:

0 /addons/SEO/admin.php(281): in_array()

1 /admin/php5_classes/Admin.class.php(543): addon_SEO_admin->display_addon_SEO_main_config()

2 /admin/index.php(16): geoAdmin->load_page()

3 {main}

I will test everything on PHP 8.0 / 8.1 before updating to this version. If I find something I will create a new bug report topic

Originally posted by @vinprom1 in https://github.com/geodesicsolutions-community/geocore-community/issues/161#issuecomment-1093308782

vicos59 commented 2 years ago

That's odd. I don't get those errors on 8.1.3 on my Docker setup. I do get the following:

Deprecated: Optional parameter $type declared before required parameter $parent is implicitly treated as a required parameter in /var/www/html/src/classes/cjax/core/classes/cjax.class.php on line 170

Can you post your exact PHP version. Does the page load at all or just dies with the error?

vinprom1 commented 2 years ago

PHP Version 8.1.4 fpm with SSL Page dies with this error. I use debugger addon on I may have missed activating a PHP module for 8.0 / 8.1, because I generally use PHP 7.4

vicos59 commented 2 years ago
                    if (function_exists('apache_get_modules')) {
                        $modules = apache_get_modules();
                    }
                    if (!is_array($modules) xor !in_array('mod_rewrite', $modules)) {
                        $tpl->assign('checks_pass', 'no');
                    }

It is essentially testing to see if apache's mod_rewrite is installed.

apache_get_modules() is a built-in PHP function which is supposed to return an array:

https://www.php.net/manual/en/function.apache-get-modules.php

Since it is complaining that the haystack ($modules) is not an array, it seems like either apache_get_modules() is not being executed or not returning an array. Maybe it should test to see if $modules is an array first, then if true, do the in_array check.

I guess you could write a simple test script to see if it exists:

if (function_exists('apache_get_modules')) {
  echo "apache_get_modules exists";
}
else {
  echo "no bueno";
}

or just this:

<?php
print_r(apache_get_modules());
?>

I do not have this error, so must be something specific to your system. None-the-less, the script should still handle the eventuality.

vicos59 commented 2 years ago

This may be the answer:

apache_get_modules() is only available when the PHP is installed as a module and not as a CGI == It doesn't work with php-fpm.

I use php-fpm, but I am running 7.4

If you just want to hack it and move on, you could just comment out the if statement where it checks for mod_rewrite and hardcode the variable that declares the check passed -- if you know that you have mod_rewrite.

vicos59 commented 2 years ago

Documenting other issues with the script:

seo-probs

vinprom1 commented 2 years ago

<?php

if (function_exists('apache_get_modules')) { echo "apache_get_modules exists"; } else { echo "no bueno"; } ?>

result is > no bueno

vinprom1 commented 2 years ago

Yes, i comment out the if statement where it checks for mod_rewrite and work fine.

I have and other problems when try to upgrade from v18.02 to 20.0.0 When use my custom template it showing errors for missing lot of /module .tpl files

One option I can think of is to copy the default theme (make new template set) and rework it first to achieve my old design or to clear the errors of the old design (theme)

vinprom1 commented 2 years ago

php-fpm, but I am running 7.4

If i use php-fpm 7.4 + SSL i not have a problem with SEO addon.

In general, PHP-fpm is little buggy, especially if you go with Apache mod_proxy like me. That's why I will stop sharing my bugs, obviously they are not so reliable :)

vicos59 commented 2 years ago

Yes, i comment out the if statement where it checks for mod_rewrite and work fine.

I have and other problems when try to upgrade from v18.02 to 20.0.0 When use my custom template it showing errors for missing lot of /module .tpl files

One option I can think of is to copy the default theme (make new template set) and rework it first to achieve my old design or to clear the errors of the old design (theme)

Which template set did you base you design on? the default or one of the 3 optional sets: fusion, marquee, or tempo?

The last 3 come in separate zip files from the main core -- which I did not upload for you. Not sure if they differ from what you already have installed. I can upload them for you.

I can't really help you much with templates.

vinprom1 commented 2 years ago

I'm not sure but think is marquee template

vicos59 commented 2 years ago

I should have told you about the extra template sets. Here they are:

https://we.tl/t-Cvof6SRP5t

You'll have to look to the instructions for info on how to install.

vicos59 commented 2 years ago

@vinprom1 Howdy, just checking in to see if you were able to get v20 to do everything you need it to do.

vinprom1 commented 2 years ago

I still don't have time to test it, but I still have a problem with the old design. I will have to rework the new theme from the beginning.