onOffice-Web-Org / oo-wp-plugin

onOffice for WP-Websites
https://wp-plugin.onoffice.com
GNU General Public License v3.0
9 stars 9 forks source link

P#77252 PHP notices break page load when saving estate lists and pages with shortcodes #309

Closed jmaas-onoffice closed 1 year ago

jmaas-onoffice commented 2 years ago

Current state

When trying to save an estate list, the following errors are output. The page only shows these errors and does not load correctly.

Notice: Undefined property: stdClass::$defaultvalue-lang in /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Gui/AdminPageSettingsBase.php on line 309

Notice: Undefined property: stdClass::$customlabel-lang in /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Gui/AdminPageSettingsBase.php on line 312

Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Gui/AdminPageSettingsBase.php:309) in /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/pluggable.php on line 1421

Warning: Cannot modify header information - headers already sent by (output started at /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Gui/AdminPageSettingsBase.php:309) in /www/htdocs/w01bb2af/testinstanz-jmaa.onofficeweb.com/htdocs/wp-includes/pluggable.php on line 1424

This only happens when the website is configured to output errors. For example, by installing the Query Monitor plugin which captures the error output and displays it separately, it works.

The error "Cannot modify header information" indicates that maybe the error output messes up rendering the page which makes the page load stop and leaves the incomplete page with only the error messages.

Additionally, there is the following notice when trying to create a new estate list:

Notice: Undefined index: id in /www/htdocs/w01bebba/testinstanz-mr.onofficeweb.com/htdocs/wp-content/plugins/onoffice-for-wp-websites/plugin/Gui/AdminPageSettingsBase.php on line 167

Furthermore, a similar problem happens when saving a WordPress page with an estate list shortcode (this might actually happen for all pages, but I know it happens in this case). Here, the errors are:

Notice: Undefined index: list_shortcode in /var/www/clients/client1/web185/web/wp-content/plugins/onoffice-for-wp-websites/plugin/Controller/DetailViewPostSaveController.php on line 173

Notice: Undefined index: list_shortcode in /var/www/clients/client1/web185/web/wp-content/plugins/onoffice-for-wp-websites/plugin/Controller/DetailViewPostSaveController.php on line 447

Notice: Undefined index: list_shortcode in /var/www/clients/client1/web185/web/wp-content/plugins/onoffice-for-wp-websites/plugin/Controller/DetailViewPostSaveController.php on line 451

Notice: Undefined index: list_shortcode in /var/www/clients/client1/web185/web/wp-content/plugins/onoffice-for-wp-websites/plugin/Controller/DetailViewPostSaveController.php on line 444

Desired state

All warnings and errors should be fixed.

  1. For estate list settings, the properties should be accessed in a way that does not trigger an error message.
  2. For estate lists, the undefined index problem should be fixed.
  3. For WordPress pages, the index access problem when saving WordPress pages should be fixed.
LongTrong-exe commented 2 years ago

@jmaas-onoffice I cannot reproduce error "Warning: Cannot modify header information...", but I think I know why it happened and I fixed it. If you can reproduce it, please check it out for me.

jmaas-onoffice commented 1 year ago

@LongTrong-exe I think the "headers already sent" might only happen if you have WP_DEBUG_DISPLAY to true so that it outputs the errors. (At least we had this issue already somewhere else.)

But it should be enough to focus on fixing the other errors. ;)