logo       

CVS: phpwiki/lib BlockParser.php,1.52,1.53 config.php,1.129,1.130: msg#00180

web.wiki.phpwiki.checkins

Subject: CVS: phpwiki/lib BlockParser.php,1.52,1.53 config.php,1.129,1.130

Update of /cvsroot/phpwiki/phpwiki/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4409

Modified Files:
BlockParser.php config.php
Log Message:
very important php5 fix! clone objects

Index: BlockParser.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/BlockParser.php,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -2 -b -p -d -r1.52 -r1.53
--- BlockParser.php 21 Oct 2004 19:52:10 -0000 1.52
+++ BlockParser.php 29 Jan 2005 20:36:44 -0000 1.53
@@ -202,5 +202,6 @@ class BlockParser_Input {

function advance () {
- $this->_atSpace = $this->_lines[$this->_pos++] === '';
+ $this->_atSpace = ($this->_lines[$this->_pos] === '');
+ $this->_pos++;
}

@@ -348,5 +349,7 @@ class ParsedBlock extends Block_HtmlElem

function _parse (&$input) {
- for ($block = $this->_getBlock($input); $block; $block = $nextBlock) {
+ // php5 failed to advance the block. php5 copies objects by ref.
+ // nextBlock == block, both are the same objects. So we have to clone
it.
+ for ($block = $this->_getBlock($input); $block; $block =
clone($nextBlock)) {
while ($nextBlock = $this->_getBlock($input)) {
// Attempt to merge current with following block.
@@ -393,10 +396,12 @@ class ParsedBlock extends Block_HtmlElem
$tight_top = !$this->_atSpace;
$re_set = &$this->_regexpset;
+ //FIXME: php5 fails to advance here!
for ($m = $re_set->match($line); $m; $m = $re_set->nextMatch($line,
$m)) {
- $block = $this->_block_types[$m->regexp_ind];
+ $block = clone($this->_block_types[$m->regexp_ind]);
if (DEBUG & _DEBUG_PARSER)
$input->_debug('>', get_class($block));

if ($block->_match($input, $m)) {
+ //$block->_text = $line;
if (DEBUG & _DEBUG_PARSER)
$input->_debug('<', get_class($block));
@@ -480,5 +485,4 @@ class Block_blockquote extends BlockMark
{
var $_depth;
-
var $_re = '\ +(?=\S)';

@@ -512,5 +516,4 @@ class Block_list extends BlockMarkup
| [*] (?!(?=\S)[^*]*(?<=\S)[*](?:\\s|[-)}>"\'\\/:.,;!?_*=]) )
)\ *(?=\S)';
-
var $_content = array();

@@ -1015,4 +1018,5 @@ class Block_p extends BlockMarkup
var $_tag = 'p';
var $_re = '\S.*';
+ var $_text = '';

function _match (&$input, $m) {
@@ -1067,7 +1071,4 @@ function TransformTextPre ($text, $marku
$output = new WikiText($text);

- /* if (0 and DEBUG and DEBUG & _DEBUG_VERBOSE and check_php_version(5)) {
- echo "<pre>"; var_dump($output); echo "</pre>";
- } */
return $output;
}
@@ -1089,4 +1090,7 @@ function TransformText ($text, $markup =

// $Log$
+// Revision 1.53 2005/01/29 20:36:44 rurban
+// very important php5 fix! clone objects
+//
// Revision 1.52 2004/10/21 19:52:10 rurban
// Patch #994487: Allow callers to get the parse tree for a page (danfr)

Index: config.php
===================================================================
RCS file: /cvsroot/phpwiki/phpwiki/lib/config.php,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -2 -b -p -d -r1.129 -r1.130
--- config.php 8 Jan 2005 22:53:50 -0000 1.129
+++ config.php 29 Jan 2005 20:36:44 -0000 1.130
@@ -58,8 +58,11 @@ set_magic_quotes_runtime(0);
function browserAgent() {
static $HTTP_USER_AGENT = false;
+ if ($HTTP_USER_AGENT !== false) return $HTTP_USER_AGENT;
if (!$HTTP_USER_AGENT)
$HTTP_USER_AGENT = @$GLOBALS['HTTP_SERVER_VARS']['HTTP_USER_AGENT'];
if (!$HTTP_USER_AGENT) // CGI
- $HTTP_USER_AGENT = $GLOBALS['HTTP_ENV_VARS']['HTTP_USER_AGENT'];
+ $HTTP_USER_AGENT = @$GLOBALS['HTTP_ENV_VARS']['HTTP_USER_AGENT'];
+ if (!$HTTP_USER_AGENT) // local CGI testing
+ $HTTP_USER_AGENT = 'none';
return $HTTP_USER_AGENT;
}
@@ -435,4 +438,19 @@ if (!function_exists('is_a')) {

/**
+ * safe php4 definition for clone.
+ * php5 copies objects by reference, but we need to clone "deep copy" in some
places.
+ * (BlockParser)
+ * We need to eval it as workaround for the php5 parser.
+ * See http://www.acko.net/node/54
+ */
+if (!check_php_version(5)) {
+ eval('
+ function clone($object) {
+ return $object;
+ }
+ ');
+}
+
+/**
* wordwrap() might crash between 4.1.2 and php-4.3.0RC2, fixed in 4.3.0
* See http://bugs.php.net/bug.php?id=20927 and
@@ -507,4 +525,7 @@ function getUploadDataPath() {

// $Log$
+// Revision 1.130 2005/01/29 20:36:44 rurban
+// very important php5 fix! clone objects
+//
// Revision 1.129 2005/01/08 22:53:50 rurban
// hardcode list of langs (file access is slow)



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise