Roots Discourse

Having trouble with johnbillion/extended-cpts errors

(Trellis/Bedrock/Sage9 setup)
I’ve used johnbillion/extended-cpts before without any issues, but this time I’m getting lots of errors on a fresh install. Can anyone help spot what I’m missing?

Installed johnbillion/extended-cpts via composer in my ‘site’ directory. I can confirm this exists in site/vendor/johnbillion/extended-cpts.

Setup in mu-plugins directory is
require_once(dirname(__FILE__) . '/themename/post-types/casestudy.php');

Setup in above casestudy.php is:

add_action( 'init', function() {
  register_extended_post_type( 'casestudy', [

    # Show all posts on the post type archive:
    'archive' => [
      'nopaging' => true,
    ]

  ], [

    # Override the base names used for labels:
    'singular' => 'Case Study',
    'plural'   => 'Case Studies',
    'slug'     => 'casestudy',

  ] );

} );

frontend errors:

( ! ) Notice: Trying to access array offset on value of type null in /srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php on line  *176*
|1|0.0003|394016|{main}( )|.../index.php:0|
|---|---|---|---|---|
|2|0.0009|395520|require( '/srv/www/themename.co.uk/current/web/wp/wp-blog-header.php' )|.../index.php:6|
|3|0.0013|406688|require_once( '/srv/www/themename.co.uk/current/web/wp/wp-load.php' )|.../wp-blog-header.php:13|
|4|0.0018|408072|require_once( '/srv/www/themename.co.uk/current/web/wp-config.php' )|.../wp-load.php:42|
|5|0.0353|1417576|require_once( '/srv/www/themename.co.uk/current/web/wp/wp-settings.php' )|.../wp-config.php:9|
|6|0.1802|19399080|include_once( '/srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php' )|.../wp-settings.php:302|
|7|0.1802|19399240|Roots\Bedrock\Autoloader->__construct( )|.../bedrock-autoloader.php:243|
|8|0.1802|19399280|Roots\Bedrock\Autoloader->loadPlugins( )|.../bedrock-autoloader.php:94|
|9|0.1802|19399280|Roots\Bedrock\Autoloader->checkCache( )|.../bedrock-autoloader.php:104|
|10|0.1806|19326864|Roots\Bedrock\Autoloader->updateCache( )|.../bedrock-autoloader.php:153|

and

( ! ) Notice: Trying to access array offset on value of type null in /srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php on line  *176*
Call Stack
# Time Memory Function Location
1 0.0003 394016 {main}( ) .../index.php **:** 0
2 0.0009 395520 require( '/srv/www/themename.co.uk/current/web/wp/wp-blog-header.php' ) .../index.php **:** 6
3 0.0013 406688 require_once( '/srv/www/themename.co.uk/current/web/wp/wp-load.php' ) .../wp-blog-header.php **:** 13
4 0.0018 408072 require_once( '/srv/www/themename.co.uk/current/web/wp-config.php' ) .../wp-load.php **:** 42
5 0.0353 1417576 require_once( '/srv/www/themename.co.uk/current/web/wp/wp-settings.php' ) .../wp-config.php **:** 9
6 0.1802 19399080 include_once( '/srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php' ) .../wp-settings.php **:** 302
7 0.1802 19399240 Roots\Bedrock\Autoloader->__construct( ) .../bedrock-autoloader.php **:** 243
8 0.1802 19399280 Roots\Bedrock\Autoloader->loadPlugins( ) .../bedrock-autoloader.php **:** 94
9 0.1802 19399280 Roots\Bedrock\Autoloader->checkCache( ) .../bedrock-autoloader.php **:** 104
10 0.1806 19326864 Roots\Bedrock\Autoloader->updateCache( ) .../bedrock-autoloader.php **:** 153
11 0.1894 19640288 Roots\Bedrock\Autoloader->countPlugins( ) .../bedrock-autoloader.php **:** 178
12 0.1899 19640288 Roots\Bedrock\Autoloader->updateCache( ) .../bedrock-autoloader.php **:** 236

admin errors:
the two errors from the frontend appear again, plus:

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php:176) in /srv/www/themename.co.uk/current/web/wp/wp-includes/functions.php on line  *6221*
Call Stack
# Time Memory Function Location
1 0.0010 497680 {main}( ) .../themes.php **:** 0
2 0.0017 537016 require_once( '/srv/www/themename.co.uk/current/web/wp/wp-admin/admin.php' ) .../themes.php **:** 10
3 0.2771 26702504 do_action( ) .../admin.php **:** 170
4 0.2771 26702880 WP_Hook->do_action( ) .../plugin.php **:** 478
5 0.2771 26702880 WP_Hook->apply_filters( ) .../class-wp-hook.php **:** 311
6 0.2776 26721488 send_frame_options_header( ) .../class-wp-hook.php **:** 285
7 0.2776 26721488 [header](http://www.php.net/function.header) ( ) .../functions.php **:** 6221

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php:176) in /srv/www/themename.co.uk/current/web/wp/wp-admin/includes/misc.php on line  *1259*
Call Stack
# Time Memory Function Location
1 0.0010 497680 {main}( ) .../themes.php **:** 0
2 0.0017 537016 require_once( '/srv/www/themename.co.uk/current/web/wp/wp-admin/admin.php' ) .../themes.php **:** 10
3 0.2771 26702504 do_action( ) .../admin.php **:** 170
4 0.2771 26702880 WP_Hook->do_action( ) .../plugin.php **:** 478
5 0.2771 26702880 WP_Hook->apply_filters( ) .../class-wp-hook.php **:** 311
6 0.2801 26924088 wp_admin_headers( ) .../class-wp-hook.php **:** 287
7 0.2801 26924408 [header](http://www.php.net/function.header) ( ) .../misc.php **:** 1259

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php:176) in /srv/www/themename.co.uk/current/web/wp/wp-includes/pluggable.php on line  *1281*
Call Stack
# Time Memory Function Location
1 0.0010 497680 {main}( ) .../themes.php **:** 0
2 0.3052 26948736 wp_redirect( ) .../themes.php **:** 34
3 0.3052 26948824 [header](http://www.php.net/function.header) ( ) .../pluggable.php **:** 1281

( ! ) Warning: Cannot modify header information - headers already sent by (output started at /srv/www/themename.co.uk/current/web/app/mu-plugins/bedrock-autoloader.php:176) in /srv/www/themename.co.uk/current/web/wp/wp-includes/pluggable.php on line  *1284*
Call Stack
# Time Memory Function Location
1 0.0010 497680 {main}( ) .../themes.php **:** 0
2 0.3052 26948736 wp_redirect( ) .../themes.php **:** 34
3 0.3054 26948864 [header](http://www.php.net/function.header) ( ) .../pluggable.php **:** 1284

console error.log reads:

2020/04/25 09:13:02 [error] 1079#1079: *33 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Call to undefined function register_extended_post_type() in /srv/www/themename.co.uk/current/web/app/mu-plugins/themename/post-types/casestudy.php:6

Stack trace:

#0 /srv/www/themename.co.uk/current/web/wp/wp-includes/class-wp-hook.php(287): {closure}('')
#1 /srv/www/themename.co.uk/current/web/wp/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
#2 /srv/www/themename.co.uk/current/web/wp/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
#3 /srv/www/themename.co.uk/current/web/wp/wp-settings.php(540): do_action('init')
#4 /srv/www/themename.co.uk/current/web/wp-config.php(9): require_once('/srv/www/themen...')
#5 /srv/www/themename.co.uk/current/web/wp/wp-load.php(42): require_once('/srv/www/themen...')
#6 /srv/www/themename.co.uk/current/web/wp/wp-blog-header.php(13): require_once('/srv/www/themen...')
#7 /srv/www/themename.co.uk/current/web/index.php(6): require('/srv/www/themen...')
#8 {main}

thrown i" while reading response header from upstream, client: 192.168.50.1, server: themename.test, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm-wordpress.sock:", host: "themename.test", referrer: "http://themename.test/"

The extended-cpts are working, when I change my .env file to be ‘staging’, I can access the admin area and my casestudy CPT exists. But when the .env is ‘development’ I can’t access admin as its just a page of errors.

I have tried removing and reinstalling extended-cpts, and re-provisioning the server, but I keep coming back to the same issue. As always, any help is greatly appreciated!

It’s due to PHP 7.4. Update the autoloader mu-plugin to the latest on the Bedrock repo.

1 Like

Perfect, thanks Brandon, that’s worked!
Let me know if I can I buy you a beer to say thanks, for this, and sage directives, and blade-svg-sage, all of which I use often!! :sweat_smile:
Gareth

No problem.

If you really want too: https://github.com/sponsors/Log1x

or to Roots directly: https://www.patreon.com/rootsdev

:blush:

1 Like

Done :grinning:
Post must be at least 20 characters

1 Like

I’m having a similar issue but I’m not quite sure what this means. How do you “Update the autoloader mu-plugin”?

https://github.com/roots/bedrock/blob/master/web/app/mu-plugins/bedrock-autoloader.php pull this down and replace the existing one in your project.

Thanks for the quick response. That didn’t fix it. I’m having a different issue it seems.

This topic was automatically closed after 42 days. New replies are no longer allowed.