Opened 4 years ago

Closed 4 years ago

#9393 closed defect (bug) (fixed)

PHP notices for WordPress 2.8

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

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 4 years ago.
wp_explain_nonce() fix for custom nonces
9393-plugin-editor.diff (967 bytes) - added by sivel 4 years ago.
check if variable is set rather than counting it
9393_theme-install.patch (2.6 KB) - added by Viper007Bond 4 years ago.
Notice fixes for the theme installer
9393-admin-php.diff (372 bytes) - added by sivel 4 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 4 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 4 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 4 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 4 years ago.
Set empty file type if skipping file type check. Fixes notices when importing.
9393-widgets.diff (545 bytes) - added by nbachiyski 4 years ago.
Deleting a widget, which is beng used generates non-existing array key notices
9393-sticky.diff (639 bytes) - added by nbachiyski 4 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 4 years ago.
If there are no widgets don't try looping through them
template.diff (520 bytes) - added by mrmist 4 years ago.
wp-admin\includes\template.php
9393-registration.2.diff (1.2 KB) - added by sivel 4 years ago.
9393-template.php (833 bytes) - added by sivel 4 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 4 years ago.
Uses get_the_author_meta instead of get_author_name()
9393-template.2.php (833 bytes) - added by sivel 4 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 4 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 4 years ago.
Last round of replacements for deprecated get_the_author_* and the_author_* functions.

Download all attachments as: .zip

Change History (49)

wp_explain_nonce() fix for custom nonces

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

sivel4 years ago

check if variable is set rather than counting it

Notice fixes for the theme installer

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

  • Keywords tested added

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

sivel4 years ago

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

sivel4 years ago

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

sivel4 years ago

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

sivel4 years ago

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

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

sivel4 years ago

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

Patches still waiting:

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

comment:7   ryan4 years ago

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

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

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.

Two more tiny notice patches.

sivel4 years ago

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

  • 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

mrmist4 years ago

wp-admin\includes\template.php

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

  • Keywords commit added

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

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

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

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

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.

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.

sivel4 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.

sivel4 years ago

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

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

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

mrmist4 years ago

Uses get_the_author_meta instead of get_author_name()

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.

(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

sivel4 years ago

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

Accidental attachment of incorrect patch. Ignore the previous attachment.

sivel4 years ago

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

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

comment:25 follow-up: ↓ 26   Viper007Bond4 years ago

current_theme_info() is still throwing notices.

comment:26 in reply to: ↑ 25   scribu4 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

sivel4 years ago

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

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

comment:28 follow-up: ↓ 31   mrmist4 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.

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.

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-Bernardy4 years ago

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

see #10025

Note: See TracTickets for help on using tickets.