[PHP-BUG] Req #51939 [NEW]: Add xml_set_entity_decl_handler function

2010-05-27 Thread mchenryc at gmail dot com
From: 
Operating system: 
PHP version:  trunk-SVN-2010-05-28 (SVN)
Package:  XML related
Bug Type: Feature/Change Request
Bug description:Add xml_set_entity_decl_handler function

Description:

When parsing XML, PHP has no way to set a handler for general entities,
though a 

handler can be set for unparsed entities.



Expat has deprecated the XML_SetUnparsedEntityDeclHandler in favor of 

XML_SetEntityDeclHandler, which is called for all entity types (including
general 

and unparsed).



http://expat.cvs.sourceforge.net/viewvc/expat/expat/lib/expat.h?

revision=1.80&view=markup#l_311



PHP should add the xml_set_entity_decl_handler function to allow handling
of all 

entity declarations.



Test script:
---
$data = ']>&generalEntity;';



function
h_entity_decl($parser,$entity_name,$is_parameter_entity,$value,$base,$system_id,$public_id,$notation_name)
{

echo "$entity_name - $is_parameter_entity - $value";

};



$parser = xml_parser_create();

xml_set_entity_decl_handler($parser, 'h_entity_decl');



xml_parse($parser,$data,false) or 

die (sprintf("XML Error: %s at line %d\n", 

 xml_error_string(xml_get_error_code($parser)),

 xml_get_current_line_number($parser)));

xml_parser_free($parser);



Expected result:

It should run with the following output:



generalEntity - 0 - General Entity



Actual result:
--
Fatal Error: Call to undefined function xml_set_entity_decl_handler()



-- 
Edit bug report at http://bugs.php.net/bug.php?id=51939&edit=1
-- 
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=51939&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=51939&r=trysnapshot53
Try a snapshot (trunk):  
http://bugs.php.net/fix.php?id=51939&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=51939&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51939&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=51939&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=51939&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=51939&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=51939&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=51939&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=51939&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=51939&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=51939&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=51939&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=51939&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=51939&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=51939&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=51939&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=51939&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=51939&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=51939&r=mysqlcfg



#40503 [NEW]: json_encode integer conversion is inconsistent with PHP

2007-02-15 Thread mchenryc at gmail dot com
From: mchenryc at gmail dot com
Operating system: Windows XP
PHP version:  5CVS-2007-02-16 (snap)
PHP Bug Type: Output Control
Bug description:  json_encode integer conversion is inconsistent with PHP

Description:

json_encode converts integers to string in a different way than PHP's
integer to string conversion (at least on win32). PHP appears to either
handle unsigned values, or use more bits to encode integers, where as
json_encode converts them to floats, causing rounding errors.


Reproduce code:
---
function show_eq($x,$y) {
  echo "$x ". ($x==$y ? "==" : "!=") ." $y\n";
}

$value = 0x7FFF; #2147483647;
show_eq("$value", json_encode($value));
$value++;
show_eq("$value", json_encode($value));


Expected result:

2147483647 == 2147483647
2147483648 == 2147483648

Which shows both functions handling unsigned (or "long") integers.

Or:

2147483647 == 2147483647
2147483650 == 2147483650

Which shows both functions converting to a float with less precision.


Actual result:
--
2147483647 == 2147483647
2147483648 != 2147483650

My code makes use of the "long" or "unsigned" (not sure what's actually
happening) ability of PHP for unix timestamps, which I would dearly love
to see stay.  The real issue is that the two functions behave in different
ways, and should not.


-- 
Edit bug report at http://bugs.php.net/?id=40503&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=40503&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=40503&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=40503&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40503&r=fixedcvs
Fixed in release: 
http://bugs.php.net/fix.php?id=40503&r=alreadyfixed
Need backtrace:   http://bugs.php.net/fix.php?id=40503&r=needtrace
Need Reproduce Script:http://bugs.php.net/fix.php?id=40503&r=needscript
Try newer version:http://bugs.php.net/fix.php?id=40503&r=oldversion
Not developer issue:  http://bugs.php.net/fix.php?id=40503&r=support
Expected behavior:http://bugs.php.net/fix.php?id=40503&r=notwrong
Not enough info:  
http://bugs.php.net/fix.php?id=40503&r=notenoughinfo
Submitted twice:  
http://bugs.php.net/fix.php?id=40503&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40503&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=40503&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40503&r=dst
IIS Stability:http://bugs.php.net/fix.php?id=40503&r=isapi
Install GNU Sed:  http://bugs.php.net/fix.php?id=40503&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=40503&r=float
No Zend Extensions:   http://bugs.php.net/fix.php?id=40503&r=nozend
MySQL Configuration Error:http://bugs.php.net/fix.php?id=40503&r=mysqlcfg