Skip to content

Commit dfc6b25

Browse files
committed
trying another storage with PhpConsole
1 parent 39f63bd commit dfc6b25

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/class-wp-php-console.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,8 +406,16 @@ public function init() {
406406
$_POST[ PhpConsole\Connector::POST_VAR_NAME ] = stripslashes_deep( $_POST[ PhpConsole\Connector::POST_VAR_NAME ] );
407407
}
408408

409-
$connector = PhpConsole\Connector::getInstance();
410-
$connector->setPassword( $password );
409+
/**
410+
* By default PHP Console uses PhpConsole\Storage\Session for postponed responses,
411+
* so all temporary data will be stored in $_SESSION.
412+
* But there is some problem with frameworks like WordPress that override PHP session handler.
413+
*/
414+
$connector = new PhpConsole\Connector;
415+
$connector->setPostponeStorage( new PhpConsole\Storage\File( '/tmp/pc.data' ) );
416+
417+
$connector_instance = $connector::getInstance();
418+
$connector_instance->setPassword( $password );
411419

412420
$handler = PhpConsole\Handler::getInstance();
413421
if ( PhpConsole\Handler::getInstance()->isStarted() != true ) {
@@ -416,15 +424,15 @@ public function init() {
416424

417425
$enableSslOnlyMode = isset( $options['ssl'] ) ? ( ! empty( $options['ssl'] ) ? $options['ssl'] : '' ) : '';
418426
if ( $enableSslOnlyMode == true ) {
419-
$connector->enableSslOnlyMode();
427+
$connector_instance->enableSslOnlyMode();
420428
}
421429

422430
$allowedIpMasks = isset( $options['ip'] ) ? ( ! empty( $options['ip'] ) ? explode( ',', $options['ip'] ) : '' ) : '';
423431
if ( is_array( $allowedIpMasks ) && ! empty( $allowedIpMasks ) ) {
424-
$connector->setAllowedIpMasks( (array) $allowedIpMasks );
432+
$connector_instance->setAllowedIpMasks( (array) $allowedIpMasks );
425433
}
426434

427-
$evalProvider = $connector->getEvalDispatcher()->getEvalProvider();
435+
$evalProvider = $connector_instance->getEvalDispatcher()->getEvalProvider();
428436

429437
$evalProvider->addSharedVar( 'uri', $_SERVER['REQUEST_URI'] );
430438
$evalProvider->addSharedVarReference( 'post', $_POST );
@@ -434,7 +442,7 @@ public function init() {
434442
$evalProvider->addSharedVarReference( 'dirs', $openBaseDirs );
435443
$evalProvider->setOpenBaseDirs( $openBaseDirs );
436444

437-
$connector->startEvalRequestsListener();
445+
$connector_instance->startEvalRequestsListener();
438446

439447
}
440448

0 commit comments

Comments
 (0)