I typically create a new file upload location thusly:
The location is created and defined with the correct paths and name as specified in the master config file. Easy. My code in the master config looks like this:
1 => array(
'name' => "Article images",
'server_path' => $base_path . "/library/user_content/article_images/",
'url' => $base_url . "/library/user_content/article_images/"
)Now, if I want to delete the location, I simply delete it from the list in the CP, delete the folder from the server and delete the relevant lines of code in the Master config file. That’s fine.
But say I delete the location with an ID of 5; I then create a new location, and I’d quite like to reuse that ID 5 for the new location. It’s not being used any more, after all. But there seems no way to get EE to allow me to reuse the ID 5, even if I specify the that ID in the master config. It seems that once an ID has been allocated it can never be unallocated or reallocated, even if the original has been deleted. Currently, after creating and deleting a few different upload destinations, I have five destinations with IDs 1, 2, 3, 8 & 9. IDs 4-7 apparently cannot be re-used, even though they no longer have a destination associated with them. And, having created (and subsequently deleted) a couple more destinations in the process of testing prior to posting this, IDs 10 and 11 are now used up too.
I know it doesn’t really matter what ID something has, but it does make the code look a bit gappy and untidy.
So: am I missing something? Is there a way to get EE to ‘forget’ that an ID was once used now that it’s no longer so?
I’ve never used that ‘master config file’, but what you describe sounds like standard (mysql) database behaviour. When rows are deleted from a table (say: table “upload locations”), their IDs are not reused.
Say you got IDs 1 2 3 4 5 and ID 4 is deleted. The next insert will create ID 6, not 4, and you’ll be at 1 2 3 _ 5 6.
The only sane way to reset the inner database counter (iterator), is to truncate (empty) the table afaik. Or you could set the counter manually of course – which doesnt make sense because you’d need to set it to 4, insert a row, then set it to 6 or 7 to avoid a collision with existing ID 5.
Leave it as it is, it’s meant to be like that. 😉
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.