[Solution] to stop DB flood , do u have better ?

Author Message

Selmah Maxim

Monday 02 June 2003 5:15:22 am

Hi ..

Try this, click here New Reply, check the the url, check the long number, then click back, then agian New Reply, u will find the is increased with one, this mean new entry, as much you repeat this as much you increase the DB with empty values, which gonna slow down the site !
Also when new visitor try to register, when he just open the register page new record will be added to the DB, also if didn`t register !

The best way i had found to check the db if user have copy or draft in the, if it`s exists, the redirect him to this copy, else create new one.
I hade create new module, and users just with this mudole can submit to the site, so i had put this lines in the module action :

// Find if he have copy in the DB //
$db = eZDb::instance();
$DBCheck =& $db->arrayQuery( "select id , current_version from ezcontentobject where
contentclass_id = '15' and
owner_id = '$userID' order by current_version desc limit 1 ");

if($DBCheck[0][id]) // Get the old one//
{
$module->redirectTo( '/content/edit' . '/' . $DBCheck[0][id] . '/' . $DBCheck[0][current_version] );
}
else // create new one//
{
$module->redirectTo( '/content/edit' . '/' . $contentObject->attribute( 'id' ) . '/' . $contentObject->attribute( 'current_version' ) );
}

To stop the user register flood :

$DBCheck =& $db->arrayQuery( "select id , current_version from ezcontentobject where
contentclass_id = '4' and published ='0' and modified='0' and status='0'
order by current_version desc limit 1 ");

The user will get the 1st empty record id from the DB ..

so do you have better idea ?

Bård Farstad

Monday 02 June 2003 6:32:22 am

This is a good idea. It's much the same way as we do when a user edits an object.

However this does not work if you want the users to be able to have several drafts of the same class. E.g. I would like to have two drafts of an article.

Mabye we could create a setting for the default behaviour or handle users in a special way.

--bård

Documentation: http://ez.no/doc

Selmah Maxim

Monday 02 June 2003 6:50:56 am

User can have 2 draft, but not if class id is 15, i made this coz i have section where user can submit some data about his work or what ever, and i don`t wanna let him spam this section with his ads, so if submit once he can just modify it, he cann`t submit again, and this is just for user group 12, the resgistered users, editors ,and admin can have drafts.

Now am trying with user register, i cann`t get work :

if ( $module->isCurrentAction( 'Publish' ) )
{
$http =& eZHTTPTool::instance();
$user =& eZUser::currentUser();

$db = eZDb::instance();
$DBCheck =& $db->arrayQuery( "select id , current_version from ezcontentobject where
contentclass_id = '4' and published ='0' and modified='0'
order by current_version desc limit 1 ");
if(count($DBCheck) > 0)
{
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $DBCheck[0][id],
'version' => $DBCheck[0][current_version] ) );
}
else
{
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ),
'version' => $version->attribute( 'version') ) );
}

it`s not work , coz the $object->attribute( 'id' ) is not equal $DBCheck[0][id] , and don`t know how set the $object->attribute( 'id' ) to $DBCheck[0][id] !

do u have idea about this ?

Selmah Maxim

Monday 02 June 2003 8:36:29 am

didn`t work !!

coz of nodeAssignment value, i cann`t get the Assignment id :( , coz of this the object will take the ObjectID as parentid :(

I cann`t figure out the db map, to huge for me to do it alone :(

I hope in next version will be way to do this, or somthing to clean the DB from unactive records!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.