WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#9393 closed defect (bug) (fixed)

PHP notices for WordPress 2.8

Reported by: Viper007Bond Owned by:
Milestone: 2.8 Priority: lowest
Severity: minor Version: 2.8
Component: Warnings/Notices Keywords: has-patch tested commit
Focuses: Cc:

Description

Been catching a lot of PHP notices lately and rather than making a ton of more tickets, I figured one per milestone would be better.

So here's one for 2.8. Feel free to attach patches of your own to this ticket.

Other notice tickets: #9292 #9309 #9333 #9336 #9365 #9366 #9367 #9369 #9370 #9392 (plus more probably)

Attachments (18)

9393-wp_explain_nonce.patch (641 bytes) - added by Viper007Bond 5 years ago.
wp_explain_nonce() fix for custom nonces
9393-plugin-editor.diff (967 bytes) - added by sivel 5 years ago.
check if variable is set rather than counting it
9393_theme-install.patch (2.6 KB) - added by Viper007Bond 5 years ago.
Notice fixes for the theme installer
9393-admin-php.diff (372 bytes) - added by sivel 5 years ago.
Notice fix for media upload. check if WP_ADMIN is defined before trying to define it.
9393-media-fixes.diff (1.9 KB) - added by sivel 5 years ago.
Misc media fixes, viewing and editing an image in the image library
9393-media-fixes.2.diff (4.1 KB) - added by sivel 5 years ago.
Update to 9393-media-fixes.diff. More notice fixes found through the media area.
9393-registration.diff (1.6 KB) - added by sivel 5 years ago.
Only check for unique user_nicename when updating since a user_id hasn't been created for a new user yet
9393-wp_handle_upload.diff (721 bytes) - added by sivel 5 years ago.
Set empty file type if skipping file type check. Fixes notices when importing.
9393-widgets.diff (545 bytes) - added by nbachiyski 5 years ago.
Deleting a widget, which is beng used generates non-existing array key notices
9393-sticky.diff (639 bytes) - added by nbachiyski 5 years ago.
Sometimes the sticky option has value of 'Array'. It has been fixed, but until changing it I get the notices. Another check won't harm.
9393-widgets-var-notice.diff (724 bytes) - added by sivel 5 years ago.
If there are no widgets don't try looping through them
template.diff (520 bytes) - added by mrmist 5 years ago.
wp-admin\includes\template.php
9393-registration.2.diff (1.2 KB) - added by sivel 5 years ago.
9393-template.php (833 bytes) - added by sivel 5 years ago.
Replaces template.diff as this fixes the notice in 2 locations where as the other missed one
post_template.patch (724 bytes) - added by mrmist 5 years ago.
Uses get_the_author_meta instead of get_author_name()
9393-template.2.php (833 bytes) - added by sivel 5 years ago.
This patch replaces post_template.patch. Replaces get_author_name in all locations in which it is used
9393-get_author_name.diff (3.5 KB) - added by sivel 5 years ago.
This patch replaces post_template.patch. Replaces get_author_name in all locations in which it is used
9393-the_author_url.diff (2.0 KB) - added by sivel 5 years ago.
Last round of replacements for deprecated get_the_author_* and the_author_* functions.

Download all attachments as: .zip

Change History (49)

Viper007Bond5 years ago

wp_explain_nonce() fix for custom nonces

comment:1 markjaquith5 years ago

(In [10857]) PHP Notice fix for non-normative nonce action strings. props Viper007Bond. see #9393

sivel5 years ago

check if variable is set rather than counting it

Viper007Bond5 years ago

Notice fixes for the theme installer

comment:2 Viper007Bond5 years ago

Don't commit 9393_theme-install.patch. It's deprecated as I didn't see #9508.

comment:3 sivel5 years ago

  • Keywords tested added

comment:4 cyberhobo5 years ago

I included a fix for a notice (Undefined index: metakeyselect in admin-ajax.php) in #7541.

sivel5 years ago

Notice fix for media upload. check if WP_ADMIN is defined before trying to define it.

sivel5 years ago

Misc media fixes, viewing and editing an image in the image library

sivel5 years ago

Update to 9393-media-fixes.diff. More notice fixes found through the media area.

sivel5 years ago

Only check for unique user_nicename when updating since a user_id hasn't been created for a new user yet

comment:5 azaozz5 years ago

(In [11052]) Notice fixes, props sivel, see #9393

sivel5 years ago

Set empty file type if skipping file type check. Fixes notices when importing.

comment:6 sivel5 years ago

Patches still waiting:

9393-plugin-editor.diff
9393-registration.diff
9393-wp_handle_upload.diff

comment:7 ryan5 years ago

  • Component changed from General to Warnings/Notices
  • Owner anonymous deleted

nbachiyski5 years ago

Deleting a widget, which is beng used generates non-existing array key notices

nbachiyski5 years ago

Sometimes the sticky option has value of 'Array'. It has been fixed, but until changing it I get the notices. Another check won't harm.

comment:8 nbachiyski5 years ago

Two more tiny notice patches.

sivel5 years ago

If there are no widgets don't try looping through them

comment:9 sivel5 years ago

  • Cc matt@… added

Patches still waiting:

9393-plugin-editor.diff
9393-registration.diff
9393-wp_handle_upload.diff
9393-widgets.diff
9393-sticky.diff
9393-widgets-var-notice.diff

mrmist5 years ago

wp-admin\includes\template.php

comment:10 mrmist5 years ago

Added patch for wp-admin\includes\template.php fixes notice for author ID function.

comment:11 sivel5 years ago

  • Keywords commit added

comment:12 westi5 years ago

(In [11226]) Notice fix for plugin editor when no functions found. See #9393 props sivel.

comment:13 westi5 years ago

(In [11227]) Set empty file type if skipping file type check. Fixes notices when importing. See #9393 props sivel.

comment:14 westi5 years ago

(In [11229]) Fix notices when an in-use widget is deleted. See #9393 props nbachiyski

comment:15 westi5 years ago

(In [11230]) Prevent notice check on invalid sticky settings. See #9393 props nbachiyski.

comment:16 westi5 years ago

Todo:

  • 9393-registration.diff - need to spend a little time understanding issue
  • 9393-widgets-var-notice.diff - no longer applies
  • template.diff - need more detail to understand issue.

comment:17 sivel5 years ago

Perhaps a better way to handle 9393-registration.diff is to instead of excluding ID of the user being updated created is to use the user_login.

When creating a user the users ID does not exist and is of course not in the database yet. So a notice is thrown reporting that $ID is undefined. Instead of using ID perhaps user_login would be better.

sivel5 years ago

comment:18 mrmist5 years ago

template.diff - need more detail to understand issue

The patch changes the call to the_author_ID which otherwise on current trunk produces PHP Notice: the_author_ID is deprecated since version 2.8! on the edit posts screen.

sivel5 years ago

Replaces template.diff as this fixes the notice in 2 locations where as the other missed one

comment:19 sivel5 years ago

Apologies on the file extension for that last one. I don't know what I was thinking.

comment:20 automattor5 years ago

(In [11322]) Use the_author_meta(). Props sivel. see #9393

mrmist5 years ago

Uses get_the_author_meta instead of get_author_name()

comment:21 mrmist5 years ago

Added patch for post_template to use get_the_author_meta ('display_name') instead of deprecated get_author_name function, fixes notice shown on publishing new posts.

comment:22 ryan5 years ago

(In [11331]) Use user_login instead of ID to check if user exists when creating unique nicenames. ID isn't available when inserting new users. Props sivel. see #9393

sivel5 years ago

This patch replaces post_template.patch. Replaces get_author_name in all locations in which it is used

comment:23 sivel5 years ago

Accidental attachment of incorrect patch. Ignore the previous attachment.

sivel5 years ago

This patch replaces post_template.patch. Replaces get_author_name in all locations in which it is used

comment:24 westi5 years ago

(In [11370]) Migrate final get_author_name() calls to use get_the_author_meta() instead. See #9393 props sivel.

comment:25 follow-up: Viper007Bond5 years ago

current_theme_info() is still throwing notices.

comment:26 in reply to: ↑ 25 scribu5 years ago

Also getting a notice while trying to add a category in edit.php (rev. 11372):

Notice: Trying to get property of non-object in /home/cristi/svn/wp/wp-includes/category-template.php on line 91

sivel5 years ago

Last round of replacements for deprecated get_the_author_* and the_author_* functions.

comment:27 ryan5 years ago

(In [11416]) Use get_the_author_meta(). Props sivel. see #9393

comment:28 follow-up: mrmist5 years ago

A few notices on the new widgets page now -

PHP Notice: Undefined index: count in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 493 PHP Notice: Undefined index: hierarchical in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 494 PHP Notice: Undefined index: dropdown in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 495 PHP Notice: Undefined index: title in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 595 PHP Notice: Undefined index: number in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 596 PHP Notice: Undefined index: title in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 1017 PHP Notice: Undefined index: filter in E:\webpage\svn\trunk\wp-includes\default-widgets.php on line 415
No patch from me yet, sorry.

comment:29 sirzooro5 years ago

When DB Cache plugin is active, WP shows following warning many times:

Notice: Undefined index: debug in C:\wordpress28.local\wp-content\db.php on line 646

I am not sure if this is a WP or plugin issue. I am using WP 2.8 beta 2.

comment:30 dd325 years ago

When DB Cache plugin is active, WP shows following warning many times:

Thats a issue in the DB Cache plugin, not WordPress.

Its probably got code such as this:

if ( $this->options['debug'] ) {
...

Which is wrong, Really, it should be written like this:

if ( isset($this->options['debug']) && $this->options['debug'] ) {
or just
if ( !empty($this->options['debug']) ) {

comment:31 in reply to: ↑ 28 Denis-de-Bernardy5 years ago

  • Resolution set to fixed
  • Status changed from new to closed

see #10025

Note: See TracTickets for help on using tickets.