You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "matikij (via GitHub)" <gi...@apache.org> on 2023/05/19 00:04:03 UTC
[GitHub] [skywalking-php] matikij opened a new pull request, #76: Fix hook for Doctrine PDO class
matikij opened a new pull request, #76:
URL: https://github.com/apache/skywalking-php/pull/76
When using doctrine the return type of PDO->prepare is Doctrine\DBAL\Driver\PDO\Statement and the hook didn't work. Changed the if to a match statement and added a bunch of debug statements. Fixed a minor typo.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] jmjoy commented on a diff in pull request #76: Fix hook for Doctrine PDO class
Posted by "jmjoy (via GitHub)" <gi...@apache.org>.
jmjoy commented on code in PR #76:
URL: https://github.com/apache/skywalking-php/pull/76#discussion_r1198461169
##########
src/plugin/plugin_pdo.rs:
##########
@@ -198,8 +198,17 @@ fn after_hook(
);
}
} else if let Some(obj) = return_value.as_mut_z_obj() {
- if obj.get_class().get_name() == &"PDOStatement" {
- return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ let cls=obj.get_class().get_name().to_str()?;
+ match cls {
+ "PDOStatement" => {
Review Comment:
Use `"PDOStatement" | r"Doctrine\DBAL\Driver\PDO\Statement"` here so you can merge the condition?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] jmjoy commented on pull request #76: Fix hook for Doctrine PDO class
Posted by "jmjoy (via GitHub)" <gi...@apache.org>.
jmjoy commented on PR #76:
URL: https://github.com/apache/skywalking-php/pull/76#issuecomment-1553886039
Please format the code with: `cargo +nightly fmt --all`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] matikij commented on a diff in pull request #76: Fix hook for Doctrine PDO class
Posted by "matikij (via GitHub)" <gi...@apache.org>.
matikij commented on code in PR #76:
URL: https://github.com/apache/skywalking-php/pull/76#discussion_r1198776425
##########
src/plugin/plugin_pdo.rs:
##########
@@ -198,8 +198,17 @@ fn after_hook(
);
}
} else if let Some(obj) = return_value.as_mut_z_obj() {
- if obj.get_class().get_name() == &"PDOStatement" {
- return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ let cls=obj.get_class().get_name().to_str()?;
+ match cls {
+ "PDOStatement" => {
+ return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ }
+ r"Doctrine\DBAL\Driver\PDO\Statement" => {
+ return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ }
+ _ => {
+ debug!(cls, "not a valid class");
+ }
Review Comment:
Indeed this is a much better approach and it works for my case. Addressed in next commit, run cargo fmt and went back from match to if/else
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] jmjoy commented on a diff in pull request #76: Fix hook for Doctrine PDO class
Posted by "jmjoy (via GitHub)" <gi...@apache.org>.
jmjoy commented on code in PR #76:
URL: https://github.com/apache/skywalking-php/pull/76#discussion_r1198466601
##########
src/plugin/plugin_pdo.rs:
##########
@@ -198,8 +198,17 @@ fn after_hook(
);
}
} else if let Some(obj) = return_value.as_mut_z_obj() {
- if obj.get_class().get_name() == &"PDOStatement" {
- return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ let cls=obj.get_class().get_name().to_str()?;
+ match cls {
+ "PDOStatement" => {
+ return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ }
+ r"Doctrine\DBAL\Driver\PDO\Statement" => {
+ return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ }
+ _ => {
+ debug!(cls, "not a valid class");
+ }
Review Comment:
Is `Doctrine\DBAL\Driver\PDO\Statement` the subclass of `PDOStatement`?
Maybe it's better to [is_instance_of](https://docs.rs/phper/latest/phper/classes/struct.ClassEntry.html#method.is_instance_of) to detect.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] jmjoy merged pull request #76: Fix hook for Doctrine PDO class
Posted by "jmjoy (via GitHub)" <gi...@apache.org>.
jmjoy merged PR #76:
URL: https://github.com/apache/skywalking-php/pull/76
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] jmjoy commented on a diff in pull request #76: Fix hook for Doctrine PDO class
Posted by "jmjoy (via GitHub)" <gi...@apache.org>.
jmjoy commented on code in PR #76:
URL: https://github.com/apache/skywalking-php/pull/76#discussion_r1198779008
##########
src/plugin/plugin_pdo.rs:
##########
@@ -198,8 +198,17 @@ fn after_hook(
);
}
} else if let Some(obj) = return_value.as_mut_z_obj() {
- if obj.get_class().get_name() == &"PDOStatement" {
- return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ let cls=obj.get_class().get_name().to_str()?;
+ match cls {
+ "PDOStatement" => {
+ return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ }
+ r"Doctrine\DBAL\Driver\PDO\Statement" => {
+ return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ }
+ _ => {
+ debug!(cls, "not a valid class");
+ }
Review Comment:
Good job!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [skywalking-php] jmjoy commented on a diff in pull request #76: Fix hook for Doctrine PDO class
Posted by "jmjoy (via GitHub)" <gi...@apache.org>.
jmjoy commented on code in PR #76:
URL: https://github.com/apache/skywalking-php/pull/76#discussion_r1198461169
##########
src/plugin/plugin_pdo.rs:
##########
@@ -198,8 +198,17 @@ fn after_hook(
);
}
} else if let Some(obj) = return_value.as_mut_z_obj() {
- if obj.get_class().get_name() == &"PDOStatement" {
- return after_hook_when_pdo_statement(get_this_mut(execute_data)?, obj);
+ let cls=obj.get_class().get_name().to_str()?;
+ match cls {
+ "PDOStatement" => {
Review Comment:
Use `"PDOStatement" | r"Doctrine\DBAL\Driver\PDO\Statement"` here so you can merge the condition?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org