Opened 13 years ago
Closed 13 years ago
#20506 closed defect (bug) (fixed)
Undefined variable $screen_layout_columns when filtering out screen options
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 3.4 | Priority: | normal |
Severity: | normal | Version: | 3.3.1 |
Component: | Warnings/Notices | Keywords: | has-patch dev-feedback |
Focuses: | Cc: |
Description
When using the screen_options_show_screen filter to remove the screen tab completely, an undefined variable notice appears with WP_DEBUG on. Specifically, the $screen_layout_columns variable is undefined because the current code expects it to be set and to be an integer.
This patch fixes it by setting it equal to itself while still casting it as an integer. Can't find any issues in my testing.
Attachments (9)
Change History (28)
#2
@
13 years ago
Yes, it needs to be outside out that method.
Actually, the whole method needs to be separated into two methods: one with the logic and the other with the output. I've split WP_Screen::render_screen_layout()
into the former and WP_Screen::get_screen_layout()
.
Since it's separated, I've called WP_Screen::get_screen_layout()
within the render_screen_meta
method, just before the check is made to see if the screen options should be output.
Needs some testing, but it has worked fine for me in all my tests.
#4
@
13 years ago
nacin and I discussed introducing get_user_option() and deprecating the global.
Lines like this:
echo (int) $screen_layout_columns ? (int) $screen_layout_columns : 'auto';
Would become:
echo get_current_screen()->get_user_option( 'layout_columns', 'auto' );
#5
@
13 years ago
echo get_current_screen()->get_user_option( 'layout_columns', 'auto' );
The one issue with that is the second argument is $default in this case, which is not unusual. (get_option() works the same way.) But it would be inconsistent with the WP_Screen::get_option() method, whose second argument is a specific array key of the requested option, rather than a default. I'm now kicking myself for that.
#6
follow-up:
↓ 7
@
13 years ago
I also just don't know how many of these $screen_layout_columns calls are necessary for functionality. Some of them were added in [18736] but most of that got backed out of core.
#7
in reply to:
↑ 6
;
follow-up:
↓ 8
@
13 years ago
Replying to nacin:
$screen_layout_columns was mostly needed when we used to output the right postbox container on the Edit/Write screens dependent on how many columns were selected. As that changed in 3.4 and the placement of that postbox container is fully controlled from css, perhaps we can retire the global completely.
#8
in reply to:
↑ 7
;
follow-up:
↓ 10
@
13 years ago
Replying to azaozz:
Hmm, or maybe not, I take this back :)
Implementing the user setting for columns is much more straightforward when having a method (or a global).
#11
@
13 years ago
The screen_layout_columns global is still used in edit-form-advanced.php, edit-link-form.php, and dashboard.php. The remaining uses are internal to WP_Screen.
#12
@
13 years ago
Right, [20570] was just a cleanup. The way columns work is by setting a class on the container depending on the user setting, then if the screen is narrow, overwriting the CSS to move the column(s) to the right.
#13
@
13 years ago
Ahh, gotcha. Thanks for explaining. :-)
The global could be converted into a static method I suppose, although the global appears to work fine.
@
13 years ago
Store layout columns in num_columns option rather than a global. Deprecate the global. Use get_option( 'num_columns' ) instead of the global.
#14
@
13 years ago
Move layout column setup into render_screen_meta(). Use add_option( 'num_columns' ) and get_option( 'num_columns' ) for setting and getting the user selected number of columns. Retain the screen_layout_columns global for back compat. Switch admin screens from the global to get_option().
#15
@
13 years ago
- Owner set to ryan
- Resolution set to fixed
- Status changed from new to closed
In [20579]:
#16
follow-up:
↓ 17
@
13 years ago
griffinjt, since my patch is a bit different, please try it out and let us know if it solves the problem you're seeing.
#17
in reply to:
↑ 16
@
13 years ago
Replying to ryan:
Looking good on my end - no issues that I can see. The only thing I would change in your patch (nitpicky) is that the way you have called the global doesn't follow coding standards - see https://twitter.com/#!/nacin/status/192611263321358338 by nacin regarding the issue.
Should be $GLOBALS['screen_layout_columns']
instead (only spaces is the key is a variable).
#18
@
13 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
There's a typo in the comment (20506.minor-typo-fix.patch).
There are some more instances of using unchecked
$screen_layout_columns
value (20506.patch). Perhaps we should set it somewhere outside ofWP_Screen::render_screen_layout()
if the latter is not called.