Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Criterion9 php 8 db handling #904

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions owa_db.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function getOneRow() {

$this->limit(1);
$ret = $this->_selectQuery();
return $ret[0];
return is_null($ret)?null:$ret[0];
}

function _setSql($sql) {
Expand Down Expand Up @@ -1147,4 +1147,4 @@ function getAffectedRows() {
}
}

?>
?>
39 changes: 21 additions & 18 deletions plugins/db/owa_db_mysql.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,25 +196,28 @@ function query( $sql ) {

owa_coreAPI::profile($this, __FUNCTION__, __LINE__, $sql);

$result = mysqli_query( $this->connection, $sql );

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
// Log Errors

if ( mysqli_errno( $this->connection ) ) {

$this->e->debug(
sprintf(
'A MySQL error ocured. Error: (%s) %s. Query: %s',
mysqli_errno( $this->connection ),
htmlspecialchars( mysqli_error( $this->connection ) ),
$sql
)
);
try {
$result = @mysqli_query( $this->connection, $sql );

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
// Log Errors

if ( mysqli_errno( $this->connection ) ) {

$this->e->debug(
sprintf(
'A MySQL error ocured. Error: (%s) %s. Query: %s',
mysqli_errno( $this->connection ),
htmlspecialchars( mysqli_error( $this->connection ) ),
$sql
)
);
}

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);
} catch(\Exception $e) {
$result = false;
Copy link

Choose a reason for hiding this comment

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

can we log the exception in $this->e->debug() as well, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may sound silly, but I'm not sure how to edit/update a PR. This would be the first one I have submitted with a request for changes. Is there a preferred process here?

Copy link

Choose a reason for hiding this comment

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

You can push any changes to the branch you used and they will automatically be included in the PR.

You can also edit individual files manually on GH.com (see menu on right side):

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added logging of the caught exception. Please let me know if I missed anything getting the PR updated.

Copy link

Choose a reason for hiding this comment

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

lgtm 👍

}

owa_coreAPI::profile($this, __FUNCTION__, __LINE__);

$this->new_result = $result;

return $this->new_result;
Expand Down