pressbooks / pressbooks

Open publishing. Open web. Open source.
https://pressbooks.org/
GNU General Public License v3.0
421 stars 133 forks source link

Undefined property notice when editing Custom Styles on book in staging environment #2100

Closed SteelWagstaff closed 3 years ago

SteelWagstaff commented 3 years ago

Prerequisites

Description

When I attempt to save the custom CSS for the Open Textbooks with Students book on integrations (https://integrations.pressbooks.network/opentextbookswithstudents/wp-admin/themes.php?page=pb_custom_styles&slug=web), I see a Notice: Undefined property: stdClass::$edit_page in /srv/www/integrations.pressbooks.network/releases/20210227030651/web/wp/wp-includes/capabilities.php on line 166 message. The notice appears to be related to the way that custom post types are registered with WordPress (perhaps this issue is related to https://github.com/pressbooks/pressbooks/issues/2079?): https://github.com/WordPress/WordPress/blob/071a41414a86a528db349d8bd257a72b21b19e8d/wp-includes/capabilities.php#L157-L172

The CSS changes do appear to be saved and are functional in the book following the clearing of the notice. I have not observed the notice in other books on this or other networks (tested in sample books on integrations, textopress, and university networks). The notice is displayed when edits are made to the webbook, ebook, and PDF custom styles for this particular book.

Steps to Reproduce

  1. Visit https://integrations.pressbooks.network/opentextbookswithstudents/wp-admin/themes.php?page=pb_custom_styles&slug=web
  2. Enter or change the custom CSS in any of the stylesheets
  3. Observe a brief notice appear on the screen

This video shows the expected behavior seen in one book on the integrations network, followed by the unexpected behavior seen in the Open Textbooks with Students text: https://user-images.githubusercontent.com/13485451/109693514-99980e00-7b3e-11eb-9317-0a5c2ec13fd0.mp4

Expected behavior: CSS changes are saved with no notice.

Actual behavior: An unexpected notice is displayed before the CSS changes are saved.

Notes: the notice can be reproduced in some but not all books on the integrations network. For example, the notice does appear on https://integrations.pressbooks.network/h5p-clone/wp-admin/themes.php?page=pb_custom_styles but does not appear on https://integrations.pressbooks.network/newbook/wp-admin/themes.php?page=pb_custom_styles&slug=web or https://integrations.pressbooks.network/epubimport/wp-admin/themes.php?page=pb_custom_styles&slug=web. I cannot yet determine why the notice only appears on some books and not others.

See https://sentry.io/organizations/pressbooks/issues/2247121159/?environment=staging&project=3954026&query=edit_page&statsPeriod=14d for the issue in Sentry

SteelWagstaff commented 3 years ago

Duplicate of https://github.com/pressbooks/pressbooks/issues/2149