Theme Error after Updating to PB 4.0.0 "Slate"

After upgrading Pressbooks to 4.0.0 (from 3.9.9), I’ve run into an issue where the admin area for each book created before the update is inaccessible. The error printed on the screen is:

The Pressbooks Book theme is not installed, but Pressbooks needs it in order to function properly. Please visit GitHub for installation instructions.

I am able to visit the book but not the admin area for any of these books. Thoughts?

---- EDIT ----

The issue seems to be that the Template Root for a given book created pre-4.0.0 is set to /plugins/pressbooks/themes-book, when it should be /themes, since that is where the theme gets installed via composer. Updating this Template Root path in <Site Root>/wp-admin/network/site-settings.php?id=<Book ID> should resolve the issue.

1 Like

This is the Template Root path before the change:

This is the Template Root path after the change:

The problem now is for those who run into this issue who have hundreds of books already created in prod that will have inaccessible admin areas. Doing this manually would make for sad times, indeed. :slight_smile:

Now I understand why we didn’t have this problem. We use an atomic deploy system (updates are deployed to /releases/<id>/ and then the webroot symlink is updated to point to the latest release following a deploy). Because of this, our deploy tools run a wp-cli command to make sure that the theme root is updated on all sites at the end of a successful deploy. For reference:

Note that while the link is to an Ansible playbook, you should be able to run a similar command with wp-cli on the affected books when you update to Pressbooks 4.0. Also relevant is this tip from wp-cli maintainer Daniel Bachhuber on how to loop over every site in a multisite network and run a command. Hope this helps!

Update: This command is run on most of our networks but not on Pressbooks.com, and also not in our dev environment… so I’m still puzzled about this.

Same installation error even though I followed the page - https://docs.pressbooks.org/upgrading/
when upgrading from PB 3.9.8
(Installed Themes Pressbooks-book 1.9.2 and Pressbooks-publisher-3.1.1)

However, when I upgraded to PB 3.9.10 (with above themes activated) then installed PB 4.0, no errors in administration but get an error on main site page “The theme directory “pressbooks-publisher” does not exist.”
The temporary fix was to change the site settings - Template & Stylesheet URLs > /pressbooks-publisher-3.1.1
But still getting an error on web book sites - The theme directory “…” does not exist; and admin link states “The Pressbooks Publisher theme is not installed, but Pressbooks needs it in order to function properly. Please visit GitHub for installation instructions.”
Issue appears to be naming of theme for URL ?

Note 1: manual installation of zip via FTP
Note 2: manual site - settings changing of Template & Stylesheet URLs

Is the folder called wp-content/themes/pressbooks-publisher-3.1.1? It should just be pressbooks-publisher. Please rename it and see if the issue persists.

I’ve updated the docs accordingly.

1 Like

Initially changing the unzipped folder to pressbooks-publisher (3.1.1) removed the previously mentioned issues. Now the subsite - Settings - Stylesheet - Opentextbook and - Template - pressbooks-book is displayed, as well as the main site.

However, changing to PBP 2.1 results in subsites getting the error > “The Pressbooks Book theme is not installed, but Pressbooks needs it in order to function properly. Please visit GitHub for installation instructions.” Changing back to PBP 3.1.1 for main site did not resolve error for subsites.

Side Note: When both PBP 3.11 and 2.1 are not network enabled, the previous default setting used Pressbooks Publisher 3.11 theme for the main home page. When Pressbooks Publisher 2.1 theme was network enabled and activated, the main home page is correctly displayed with the settings - stylesheet/Template - pressbooks-publisher-two
Then network enabling both PBP 3.11 & 2.1 allowed for Main site appearance changes.

ps: may be helpful to have theme version commented in readme file of theme (i.e., pressbooks-austenclassic-1.6.2.zip)

Activating Pressbooks Publisher Two as the root theme does not produce this error for me. One note is that you don’t need to network enable your root theme. Network enabling a theme makes it available for subsites, but as all your subsites will be books, they don’t need access to the root theme. So you can (and probably should) network disable both versions of Pressbooks Publisher and just activate the one you need on your root site.

Theme versions will be indicated in the readme going forward (so, the next time we update any of these themes this information will be added).

1 Like

Tested two PB 4.0 upgrades:
PBserver A has 12 sites; PBserver B has 2 sites

PBserver B upgrade to PB4 is working, however on creating a new site the settings - Template Root defaults to /plugins/pressbooks/themes-book and produces the error - “The Pressbooks Book theme is not installed, but Pressbooks needs it in order to function properly. Please visit GitHub for installation instructions.”

Modifying Template Root to /themes fixed the above error for Dashboard and site Visit


PBserver A replicated the same settings from PBserver B. Main site continues to work but subsites via Dashboard have a white screen, but Visit displays correctly.


Subsite - settings:

BEFORE
Template Root - /plugins/pressbooks/themes-book

AFTER
Template - pressbooks-book
Stylesheet - opentextbook
Current Theme - Open Textbooks
Template Root - /themes
Stylesheet Root - /plugins/pressbooks-textbook/themes-book

Mainsite - settings
Template Root - /themes
Stylesheet Root - /themes

@bryan This should be resolved in Pressbooks 4.0.1. Can you confirm?

We just installed 4.0.1 and on some books we get the same error, sometimes the theme is not loading correctly, sometimes it does.
Thank you!

PB.4.01 - No change - same issue as per above, white screen for Admin, Visit displays correctly.

Note 1: Creating a new site on existing PBServer A with 12 sites (PB v.4.01) displays a white screen for Admin.
Note 2: First - default site is not affected by issues on PBserver A.

DEBUG on PB.4.01 white screen when accessing Admin on a subsite (other than first site):

Fatal error: Uncaught Error: Undefined class constant ‘VERSION’ in website/wp-content/plugins/pressbooks/inc/modules/themeoptions/class-themeoptions.php:40 Stack trace: #0 website/wp-includes/class-wp-hook.php(298): Pressbooks\Modules\ThemeOptions\ThemeOptions->loadTabs(’’) #1 website/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array) #2 website/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 website/wp-admin/admin.php(154): do_action(‘admin_init’) #4 website/wp-admin/index.php(10): require_once(’/var/www/vhosts…’) #5 {main} thrown in website/wp-content/plugins/pressbooks/inc/modules/themeoptions/class-themeoptions.php on line 40

Fixed above error and white screen to Admin by deactivating Pressbooks mPDF v.1.6.2.3, then upgrading to v.1.7 (upgrading to 2.0 also worked).

We had our own specific plugin with a child theme and by deactivating it the issue was fixed. We need to update our code to make them compatible maybe.

Are you running the latest version of Pressbooks Textbook? We haven’t seen a white screen related to this.

Also, it would help if you added define( 'WP_DEBUG', true ); to your wp-config.php And shared whatever error appears when visiting the white screen.

I’ll get this running and let you know. cheers!

Okay. Tested locally and in a staging environment. PB 4.0.1 does seem to resolve the overarching issue. woot! However, when I clicked on a few of the books that already existed, it would still give me the error in my original post:

The Pressbooks Book theme is not installed, but Pressbooks needs it in order to function properly. Please visit GitHub for installation instructions.

When I refresh the browser, it takes me to the admin area for that book without a hitch. Possibly a cache issue?

Thanks for the continued work on dialogue on this @ned.

1 Like

Are you using Chrome? Chrome caching is pretty aggressive so that might explain it.

I am using chrome, and I bet you’re right about that.

I just tried changing the template root to something that I would expect would break it again, and, while the theme is broken in the book (expected), the admin area remains not broken (unexpected, though desired). So, I’m thinking this fix will probably work for us at Lumen. I’ll create a new thread referencing this one in the event something else related pops up.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.