Make WordPress Core

Opened 11 years ago

Closed 9 years ago

#24889 closed defect (bug) (wontfix)

Widget ID number in the database starts from 2

Reported by: alexvorn2's profile alexvorn2 Owned by:
Milestone: Priority: normal
Severity: trivial Version:
Component: Widgets Keywords: close
Focuses: Cc:

Description

Steps to replicate:

  1. Fresh install of WordPress
  2. 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)

#1 follow-up: @markoheijnen
11 years ago

  • Severity changed from normal to trivial

I can't remember I ever had this issue. That said it isn't something important as long as the ids are unique.

#2 in reply to: ↑ 1 @alexvorn2
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 why their id starts from 2?

Last edited 11 years ago by alexvorn2 (previous) (diff)

#3 @tyxla
9 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 @azaozz
9 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.

Last edited 9 years ago by azaozz (previous) (diff)

#5 @helen
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.