r69648 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r69647‎ | r69648 | r69649 >
Date:23:19, 20 July 2010
Author:awjrichards
Status:deferred (Comments)
Tags:
Comment:
* removed line that causes fatal error in activemq_stomp.php (at least in MW 1.16)
* added some code to Stomp.php to get around a bug that afflicts some versions of PHP causing Stomp connections to hang
Modified paths:
  • /trunk/extensions/DonationInterface/activemq_stomp/Stomp.php (modified) (history)
  • /trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DonationInterface/activemq_stomp/activemq_stomp.php
@@ -36,7 +36,8 @@
3737 function efStompSetup(&$parser) {
3838 global $wgParser, $wgOut;
3939
40 - $parser->disableCache();
 40+ //redundant and causes Fatal Error
 41+ //$parser->disableCache();
4142
4243 $wgParser->setHook( 'stomp', 'efStompTest' );
4344
Index: trunk/extensions/DonationInterface/activemq_stomp/Stomp.php
@@ -484,6 +484,7 @@
485485 }
486486
487487 $data = $stompFrame->__toString();
 488+
488489 $r = fwrite($this->_socket, $data, strlen($data));
489490 if ($r === false || $r == 0) {
490491 $this->_reconnect();
@@ -510,21 +511,26 @@
511512 */
512513 public function readFrame ()
513514 {
514 - /* if (!$this->hasFrameToRead()) {
 515+ if (!$this->hasFrameToRead()) {
515516 return false;
516 - } */
 517+ }
517518
 519+ stream_set_timeout($this->_socket, 5);
518520 $rb = 1024;
519521 $data = '';
520522 do {
521523 $read = fgets($this->_socket, $rb);
522 - if ($read === false) {
523 - $this->_reconnect();
524 - return $this->readFrame();
 524+ $info = stream_get_meta_data($this->_socket);
 525+ if ($info['timed_out']) {
 526+ return FALSE;
525527 }
 528+ //if ($read === false) {
 529+ // $this->_reconnect();
 530+ // return $this->readFrame();
 531+ //}
526532 $data .= $read;
527533 $len = strlen($data);
528 - } while (($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n")));
 534+ } while ($read && ($len < 2 || ! ($data[$len - 2] == "\x00" && $data[$len - 1] == "\n")));
529535
530536 list ($header, $body) = explode("\n\n", $data, 2);
531537 $header = explode("\n", $header);
@@ -539,6 +545,7 @@
540546 }
541547 }
542548 $frame = new Stomp_Frame($command, $headers, trim($body));
 549+
543550 if (isset($frame->headers['amq-msg-type']) && $frame->headers['amq-msg-type'] == 'MapMessage') {
544551 require_once 'Stomp/Message/Map.php';
545552 return new Stomp_Message_Map($frame);
@@ -554,6 +561,8 @@
555562 */
556563 public function hasFrameToRead()
557564 {
 565+ return TRUE; // http://bugs.php.net/bug.php?id=46024
 566+
558567 $read = array($this->_socket);
559568 $write = null;
560569 $except = null;

Comments

#Comment by Tfinc (talk | contribs)   22:35, 21 July 2010

Feel free to drop old chunks of code rather then commenting them out. We can always retrieve those from the revision history.

Status & tagging log