-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed: Exports of flexible templates throw PHP 8 error when System language is not English. #5853
Comments
@djzwerg I can't reproduce the problem without the flexible_template module. But I also can't reproduce it with that module enabled. I'm also not sure what that contrib module is for. Flexible layouts are in core - why a module? I tried your steps with PHP 8.1, but see no warnings in dblog. |
@indigoxela I can reproduce the problem without the contrib module, too:
The error still occurs. Additional informationBackdrop core version: 1.23.0 |
As I see the issue won't be there if you use the standard English installation. But if you change the language to German it happens. |
Interesting, I still can't. Language and Locale module are enabled. Switched to German (/de), the export still works just fine and nothing shows up in dblog. So it doesn't seem to caused by the language. It might have to do with your template... 🤔 Wait... do you have the comment module enabled or uninstalled? The third PHP warning is caused by that (see #5469). Now for the two remaining:
This seems very odd. You DO have the "Flexible layout templates" option in your dropdown list, right? Otherwise you couldn't export it. The export per se works? Is some json displayed in the export area? |
I can confirm that the third error log has been gone with comment module enabled. |
Devel shows nothing. |
Did you already try a different path? Instead of starting on the layout overview, go to /admin/config/development/configuration/single/export And check for the items in the dropdown list for a single export - is "Flexible layout templates" available there or not? |
Wait... a suspicion: I just overwrote the url and that way I can reproduce the problem. But only if I set the URL to something non-existent. Can you post the exact URL, when getting the error? |
And to (eventually) confirm: go to /admin/config/regional/translate/translate and search for a translated string "Flexible layout templates". And if you delete that translation - does the export work again? |
@indigoxela yes that solves that issue 🪄 |
Many thanks for verifying! So the bug here is, that the dropdown menu item does not consider that this is a translatable string and blindly applies it as url param and on the other side the form blindly relies on an existing option with that key. Oh dear! 🙄 |
A PR is available for testing and review. Additionally to translating the string "on both sides" it also tries to catch errors, if the url param is not found in the select list for whatever reasons. A value that comes in with $_GET is never fully reliable. |
Since there was so much back and forth, could @djzwerg update the steps to reproduce this problem? That will help test. |
@argiepiano I updated the steps, hopefully they're complete now to reproduce. Note that this only causes an error on php 7.4, but is fatal on php 8.+ |
@argiepiano this is the way to reproduce. I don't know whether it makes a difference to install Backdrop with the German language pack. I can check the PR later. |
@indigoxela the PR solves this issue. Thanks a lot! |
I've tried both sets of direction and am still unable to reproduce the problem. I'm working with Spanish, where the phrase "Flexible layout template" is not translated in the translation file. I can't translate it manually through the UI until Backdrop actually encounters that phrase in the UI, so the only way to do this is to create the flexible template in English first, go to the Export screen and then manually translate it to Spanish after the phrase appears in the translation form. Then visit the Spanish page to export the layout... no issues whatsoever. I also tried manually adding the phrase to the I'll just let someone with better luck (and someone who reads German, where perhaps the problem exists) try testing this. |
Maybe that's the culprit? You should try to export the template, not the layout, so starting from /es/admin/structure/layouts/settings and use the "export" link from the dropdown button of your template. You should end up with a url like |
Doh!!!! 🤦🏽 Stupid mistake - I was trying with 7.4. I'll try again later. |
OK, tested in php 8. WFM! |
Thanks @indigoxela, @djzwerg, and @argiepiano! I merged backdrop/backdrop#4251 into 1.x and 1.23.x. This will be in 1.23.1. |
Description of the bug
When I'm going to export my layout the following error occurs:
natsort(): Argument #1 ($array) must be of type array, null given
Steps to reproduce:
Backdrop error logs:
Edit:
This one belongs to the comment module. It has been gone when the module is enabled.
(previously posted on https://github.com/backdrop-contrib/flexible_layout/issues/8)
Actual behavior
You'll get the error message
natsort(): Argument #1 ($array) must be of type array, null given
.Expected behavior
The export would work.
Additional information
Backdrop core version: 1.23.0
Database version: MySQL 8.0.30
PHP version: 8.0.25
For now I think this is an issue with the PHP version. Using PHP 7.4 the export feature works.
The text was updated successfully, but these errors were encountered: