Opened 11 years ago
Closed 10 years ago
#24889 closed defect (bug) (wontfix)
Widget ID number in the database starts from 2
Reported by: | alexvorn2 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | trivial | Version: | |
Component: | Widgets | Keywords: | close |
Focuses: | Cc: |
Description
Steps to replicate:
- Fresh install of WordPress
- print_r( get_option('sidebars_widgets') );
you will get this:
Array ( [wp_inactive_widgets] => Array ( ) [sidebar-1] => Array ( [0] => search-2 [1] => recent-posts-2 [2] => recent-comments-2 [3] => archives-2 [4] => categories-2 [5] => meta-2 ) [sidebar-2] => Array ( ) [array_version] => 3 )
I think instead 2 we should see 1 because no more widgets were created.
maybe be use 0 instead of 1, but not definitely 2.
Change History (5)
#2
in reply to:
↑ 1
@
11 years ago
Replying to markoheijnen:
I can't remember I ever had this issue. That said it isn't something important as long as the ids are unique.
Agree, but their id starts from 2?
#3
@
10 years ago
Related: #12163
This has been like that since the default widgets have been introduced in 13033 almost 5 years ago.
I'm not sure why 2
has been used instead of 0
or 1
, but I feel that @ryan would have a clue. Or perhaps @azaozz would be able to recall.
But this indeed does not break anything, so I'm not sure if it is worth changing.
#4
@
10 years ago
- Keywords close added
When support for multi-use widgets was introduced, a lot of widgets got converted from "single" to "multi" at the same time.
To keep backward compatibility and not break the existing widgets, there was some conversion code that would set the "single" widgets instances to *-1
(not sure why not *-0
, it was a long time ago). In order to not overwrite the converted data, the new multi-widgets instances had to start form 2
.
As @tyxla mentions, this doesn't break anything and if changed to -0
or -1
, in theory can still overwrite someone's single widgets.
I can't remember I ever had this issue. That said it isn't something important as long as the ids are unique.