Notice: Array to string conversion in /var/www/app/web/wp/wp-includes/general-template.php on line 1200

Hey all

I have a fresh install of Sage9, on PHP 7.3 and without changing anything yet, I’m getting the above code.

If I comment out @php wp_head() @endphp from partials/head.blade.php then that error goes away. Has anyone found out the cause of this?

Would appreciate any assistance, thank you.

I kind of wonder if this is a hosting issue. Who is your host for this site?

Its still on localhost :frowning: Standard Docker PHP 7.3 stack which I’ve used on previous Bedrock + Sage projects.

In fact I copied over my dockerfile + related files into this new project, but grabbed latest Bedrock + Sage… enabled the theme and there there error was…

@MWDelaney is there a way I can step through what is being injected into wp_head so I can toggle stuff on + off until the problem is resolved?

Seems Sage9 is injecting something onto that, which is causing this, I just don’t know how to narrow down onto exactly what… :confused:

The actual line from which the PHP Notice is emitted:

removing add_theme_support('title-tag'); from app/setup.php:40 removes the error

But this doesn’t seem like it should be necessary? :thinking:

Does this function (after you re-enabled the title-tag theme feature) in your theme somehow return an array when the PHP notice is thrown?

Edit: But line 1200 (as previously linked) seems to involve the page numbers.

  1. I ran composer create-project roots/sage a couple days ago, and yet it installed 9.0.9 instead of 9.0.10?
  2. in any event, no when I remove that public static function title() function, the error remains… doesn’t seem to have to do with anything relating to that…

Btw. for Sage 9 there is an update branch in progress that fixes a lot of problems, notably with the webpack build:

As you are working in a development environment, could you either debug (e.g. VSCode breakpoint with XDebug or just a good old var_dump(...); exit; this particular line (1200) in the WordPress core code of the site ((web/)wp/wp-includes/general-template.php in Bedrock sites)?

What are the values of $paged and $page? Are these integers, strings or arrays?
Any plugins enabled?

would that 9.2 upgrade also fix the controller not sending data to the view?


the dump returns


@strarsis FYI when using the provided command for 9.2, i get:

composer create-project roots/sage foobar-test dev-webpack5 --repository='{"type":"vcs","url":""}'
Creating a "roots/sage" project at "./mobile-guardian"
GitHub API limit (0 calls/hr) is exhausted, could not fetch Create a GitHub OAuth token to go over the API rate limit. You can also wait until ? for the rate limit to reset.`

Ah right, you should set up a GitHub access token for your tools. This is a good idea anyway as it doesn’t cost anything and lifts the existing GitHub API quotes to normal user levels.

So the string is Page Array. This is quite a good indication that the page number (it should probably be Page 1 for example instead) is actually an array, which it shouldn’t be or at least further processed by a filter into something that can be cast to a string (what WordPress core expects). Can you also debug/print the page number related variables (as linked above in the WP core code)?

@MWDelaney FYI, thanks to @strarsis’s help with debugging this, installing Yoast SEO fixed the problem… I assume the default way that WP returns the title as an array which Yoast or similar knows how to handle, but Sage doesn’t?

I’m no expert, but just thought I’d share in case it helps identify a bug somewhere :slight_smile:

1 Like

Thanks for your help again @strarsis :fist_right::fist_left:

Whilst I have you, would you mind checking that screenshot I posted about the controller not sending data to the template view? Am I doing something stupid there?

When you disable Yoast SEO plugin and use the WordPress default theme (Twenty-Twenty-One), would this error still occur?

It seems indeed that Sage needs to add a line or two to handle arrays in the page number.

Yes this was my scenario… IE my brand new, out the box install, had this issue. I confirmed it was the theme, by switching to one of the default themes.

1 Like

Hm, shouldn’t rather so called “View Composers” be used in Sage 10 (instead of the classic sober controllers)?

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