php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70326 Incorrect and incomplete list of log callbacks
Submitted: 2015-08-22 14:05 UTC Modified: 2021-08-03 11:41 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: fgm at osinet dot fr Assigned:
Status: Open Package: mongodb (PECL)
PHP Version: 5.6.12 OS: Linux
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
29 + 46 = ?
Subscribe to this entry?

 
 [2015-08-22 14:05 UTC] fgm at osinet dot fr
Description:
------------
The MongoDB Context Options doc page at http://php.net/manual/en/context.mongodb.php omits two such working callbacks:

- log_query, needed to log commands including $query
- log_batchinsert, fto log batch inserts.

And it mentions log_write_batch, which does not seem to exist, maybe an old name for log_batchinsert.

By the docs, the sample script should call log_write_batch and not the other 2 loggers, but it calls them and not log_write_batch.

See PHP test file tests/mongos/stream-logger-001.phpt

Test script:
---------------
<?php
function log_batchinsert (array $server, array $docs, array $info, array $options) { 
  echo "Batch Insert " . count($docs) . " documents.\n"; 
}
function log_write_batch () { 
  echo __METHOD__ . "\n"; 
}
function log_query(array $server, array $criteria, array $queryOptions) { 
  echo "Query: " . json_encode($criteria) . "\n"; 
}

$context = stream_context_create([
  'mongodb' => ['log_batchinsert' => 'log_batchinsert', 'log_write_batch' => 'log_write_batch', 'log_query' => 'log_query'],
]);
$server = 'mongodb://localhost:27017';
$client = new \MongoClient($server, [], ['context' => $context]);
$collection = $client->selectDB('bug')->selectCollection('bug_collection');
$collection->drop();
$docs = [['foo' => 'bar'], ['baz' => 'quux']];
$result = $collection->batchInsert($docs);

Expected result:
----------------
log_write_batch

Actual result:
--------------
Query: {"drop":"bug_collection"}
Batch Insert 2 documents.
Query: {"getlasterror":1}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-08-22 17:24 UTC] fgm at osinet dot fr
Just to be sure the issue is clear, I think the result from the code is just as it should, what needs to be fixed is the manpage.
 [2021-08-03 11:41 UTC] cmb@php.net
-Package: mongo +Package: mongodb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Oct 09 00:01:27 2024 UTC