-
Notifications
You must be signed in to change notification settings - Fork 638
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
Saving new section programmatically missing section ID #3943
Comments
Can you search for that error in your |
Sorry about the delay in answering - here's the stack trace from /storage/logs/web.log:
|
@RudolfBos - this is happening when you're manually setting up the section in the admin back-end? |
Also happening for me, although, it's only happened after cloning my website and importing DB. The site it came from is fine. Additionally, I'm not able to update any System Settings on the admin backend. Here's the stack trace:
|
@maxxwv Yes! |
Happening here too: function createEventSection()
{
$section = new SectionModel([
'name' => 'Tessitura Events',
'handle' => 'tessituraEvents',
'type' => SectionModel::TYPE_CHANNEL,
'siteSettings' => [
new SectionSettingsModel([
'siteId' => Craft::$app->sites->getPrimarySite()->id,
'enabledByDefault' => true,
'hasUrls' => true,
'uriFormat' => 'tessEvents/{slug}',
'template' => 'tessEvents/_entry',
]),
]
],true);
try {
$save = Craft::$app->sections->saveSection($section);
} catch (\craft\errors\EntryTypeNotFoundException $e) {
var_dump($section->getErrors());
}
}
|
Can you folks please try running |
Unfortunately, still occurring:
|
@philbrookweb Can you email your |
I get the following:
Running an Ubuntu 18.04 Vagrant box on Windows 10 from the Admin Power Shell. Note that the storage directory has 777 permissions and is part of the www-data group, owned by vagrant user. |
@brandonkelly Done! |
@maxxwv Check the permissions on |
@brandonkelly - I must've changed something on the last spin-up of the container because this morning I'm not having permissions problems. Sorry about that. Now having successfully run the project-config/rebuild task, Craft::$app->sections->saveSection() is no longer throwing an exception, but it is returning false and I'm not seeing the section in my Sections area of the admin back-end, and I'm getting 'An unknown error occurred.' every time I refresh the plugins screen. |
Just an update on this - it appears to be working now. It does appear, though, the the handle can't have a dash in it. Is that correct? I changed the handle to "news-testing" and the unknown error appears. Dumping $section->getErrors() reporting that '"news-testing" isn't a valid handle' |
@maxxwv huh, well glad it’s working now! You are correct that sections cannot have dashes. (There’s an open request to allow them - #2276.) Going to close this. @philbrookweb I still have your email in my inbox and will get to it ASAP. |
@philbrookweb’s issue ended up being an order of operations bug – plugins are getting loaded before Craft registers its project config event handlers, so a call to To get the fix early, change your "require": {
"craftcms/cms": "dev-develop#0523421d91592d0f3dcc550b8a6739c63b8912ba as 3.1.24",
"...": "..."
} Then run |
This is working for me, thank you Brandon. |
Is this fix in 3.1.26? I'm encountering this as well, and it seems to me that 3.1.24 < 3.1.26, unless there's something I'm not understanding about dev-develop numbers being different... EDIT: Running |
Description
When using the sample code for saveSection() at https://docs.craftcms.com/api/v3/craft-services-sections.html#public-methods, I get a \Throwable error "Entry type is missing its section ID". I'm new to Craft and have the code in the main plugin file for a plugin that I've written and activated.
I'm using a custom spun Vagrant box, if that would possibly make a difference.
Steps to reproduce
Copy and paste into a plugin's main theme - in this case, my plugin is named 'Testing' and 'Testing.php' is the main entry point. I used pluginfactory.io to create the scaffold.
Instance of \Throwable is thrown with getMessage() =="Entry type is missing its section ID"
Additional info
The text was updated successfully, but these errors were encountered: