1
chippyash
How to change from databaseproxy to databasesafe modes
  • 2004/10/12 21:17

  • chippyash

  • Friend of XOOPS

  • Posts: 501

  • Since: 2004/1/29


Here's a strange one. I'm developing a new module (extending XoopsObject and XoopsModuleHandler) and am happy testing away when I get some unexpected results. My insert statements (via $this->db->query($sql) inside the handler object) aren't working any longer, (they were fine yesterday, honest). The SQL string is valid (it works fine in phpMyAdmin). It all boils down to the fact that xoopsDB is being instantiated to XoopsMySQLDatabaseProxy instead of XoopsMySQLDatabaseSafe and therefore insert statements are being killed off.

I'm sure I haven't purposely changed anything with safe/proxy mode anywhere, but you never can tell after hours at the terminal.

Where should I look to set the system to use XoopsMySQLDatabaseSafe? I can't find it in mainfile.php.

Your help is appeciated
Ashley

Addendum:
I've since found out that databasefactory instantiates teh db object dependent on XOOPS_DB_PROOXY constant that is defined in common.php l78 >
require_once XOOPS_ROOT_PATH.'/class/database/databasefactory.php';

if ($HTTP_SERVER_VARS['REQUEST_METHOD'] != 'POST' || !xoops_refcheck(XOOPS_DB_CHKREF)) {

define('XOOPS_DB_PROXY', 1);

}


Now I haven't a clue what this is doing or why. How is the 'REQUEST_METHOD' set?

2
ackbarr
Re: How to change from databaseproxy to databasesafe modes

$HTTP_SERVER_VARS['REQUEST_METHOD'] is a variable filled by PHP to tell the script how the page was requested. 'POST' is the type of request made when a form is submitted.

The second part of the if statement is important too. It checks that your request originated from a page in your XOOPS site by checking the HTTP_REFERER information (what page did this information come from). If your firewall is set to block the sending of referrer data, that could be the problem.

3
chippyash
Re: How to change from databaseproxy to databasesafe modes
  • 2004/10/13 8:32

  • chippyash

  • Friend of XOOPS

  • Posts: 501

  • Since: 2004/1/29


Thanks ackbarr

I got up this morning and it works!

From what you say I think I understand what is going on. The server is a development one inside my firewall so that can be discounted. What I have is a script called test.php located in my module directory. It's contents appended below for ref.

I think that if I go to another website first and submit some sort of form then the submit method gets stuck at 'POST', then my script works as expected. If I close the browser and re-open and go straight to my test page, it is getting set as 'GET', the result being that ..dbProxy is instantiated.

I've forced the submit method by setting $HTTP_SERVER_VARS['REQUEST_METHOD'] at the beginning of the script. This seems to work.

Regards
Ashley

>>> test.php
$HTTP_SERVER_VARS['REQUEST_METHOD']='POST';

require("header.php"); //MUST include page header

require XOOPS_ROOT_PATH."/header.php"; // include the main header file


if (isset($codeHandler)) { unset($codeHandler); }
if (isset($code)) { unset($code); }

$codeHandler =& xoops_getmodulehandler("CDMCode");
$code =& $codeHandler->create();

function pp($str) {
global $code;
global $codeHandler;
print($str."
");
$l = ($code->isDirty() ? 'TRUE' : 'FALSE');
$n = ($code->isNew() ? 'TRUE' : 'FALSE');
print("dirty = ".$l."
new = ".$n."
");
$en = @mysql_errno();
$er = @mysql_error();
print("db error = ".$en." - ".$er."
");
$vars = $code->getVars();
print_r($vars);
print( "

");
}


pp('New object instantiated');

$code->setVar('cd','ACC6');
$code->setVar('cd_value','Account#');
$code->setVar('cd_desc','An account in some book-keeping thing');
pp('values set');

//If ..DBProxy is being used the following fails
// but subsequent call to pp() does not show any sql error
// information
if (!$codeHandler->insert($code)) {
print("DB Error on insert/update
");
}

pp('new code inserted to db');


?>

Login

Who's Online

261 user(s) are online (169 user(s) are browsing Support Forums)


Members: 0


Guests: 261


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits