FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix SQLite notices related to undefined properties by aristath · Pull Request #600 · WordPress/performance · GitHub

Fix SQLite notices related to undefined properties - #600

Merged
mukeshpanchal27 merged 3 commits into
trunkfrom
fix/sqlite-undefined-prop
Dec 15, 2022
Merged

Fix SQLite notices related to undefined properties#600
mukeshpanchal27 merged 3 commits into
trunkfrom
fix/sqlite-undefined-prop

Conversation

aristath commented Dec 14, 2022
edited
Loading

Copy link
Copy Markdown
Member

Summary

Fixes #599

In addition to the above fix, I encountered some other notices when testing various plugins:

PHP Notice:  Undefined property: stdClass::$name in class-perflab-sqlite-pdo-engine.php on line 1338
PHP Notice:  Undefined property: stdClass::$type in class-perflab-sqlite-pdo-engine.php on line 1339
PHP Notice:  Undefined property: stdClass::$notnull in class-perflab-sqlite-pdo-engine.php on line 1340
PHP Notice:  Undefined property: stdClass::$pk in class-perflab-sqlite-pdo-engine.php on line 1341
PHP Notice:  Undefined property: stdClass::$dflt_value in class-perflab-sqlite-pdo-engine.php on line 1342

This PR adds some additional checks to ensure that $row is an object, and the properties exist before using them.

  • PR has either [Focus] or Infrastructure label.
  • PR has a [Type] label.
  • PR has a milestone or the no milestone label.

aristath added [Type] Bug An existing feature is broken [Focus] Database labels Dec 14, 2022
aristath added this to the 1.8.0 milestone Dec 14, 2022
aristath requested a review from OllieJones as a code owner December 14, 2022 08:17
aristath changed the title SQLite fix: Check if properties exist before using them SQLite bugfixes Dec 14, 2022
*/
function _real_escape( $str ) {
return SQLite3::escapeString( $str );
return addslashes( $str );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is the line that fixes #599

Comment on lines +1338 to +1356
if ( ! is_object( $row ) ) {
continue;
}
if ( property_exists( $row, 'name' ) ) {
$_columns['Field'] = $row->name;
}
if ( property_exists( $row, 'type' ) ) {
$_columns['Type'] = $row->type;
}
if ( property_exists( $row, 'notnull' ) ) {
$_columns['Null'] = $row->notnull ? 'NO' : 'YES';
}
if ( property_exists( $row, 'pk' ) ) {
$_columns['Key'] = $row->pk ? 'PRI' : '';
}
if ( property_exists( $row, 'dflt_value' ) ) {
$_columns['Default'] = $row->dflt_value;
}
$_results[] = new Perflab_SQLite_Object_Array( $_columns );

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is some additional defensive coding to ensure there are no errors.

felixarntz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

@aristath Great work!

felixarntz changed the title SQLite bugfixes Fix SQLite notices related to undefined properties Dec 14, 2022

mukeshpanchal27 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks @aristath Now everything is good with import.

mukeshpanchal27 merged commit 2a7f89a into trunk Dec 15, 2022
mukeshpanchal27 deleted the fix/sqlite-undefined-prop branch December 15, 2022 04:15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Bug An existing feature is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sqlite module: Notices thrown during WordPress import

3 participants


Back | FazBrowse Home | New Git URL