[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.

eZ debug

Timing: Jan 18 2025 16:10:22
Script start
Timing: Jan 18 2025 16:10:22
Module start 'layout'
Timing: Jan 18 2025 16:10:22
Module start 'content'
Timing: Jan 18 2025 16:10:23
Module end 'content'
Timing: Jan 18 2025 16:10:23
Script end

Main resources:

Total runtime0.8210 sec
Peak memory usage4,096.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0050 589.1641152.6406
Module start 'layout' 0.00500.0034 741.804739.4766
Module start 'content' 0.00840.8110 781.2813559.8125
Module end 'content' 0.81940.0015 1,341.093816.1250
Script end 0.8209  1,357.2188 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3908160.0002
Check MTime0.00130.1634160.0001
Mysql Total
Database connection0.00070.084910.0007
Mysqli_queries0.761592.7591600.0127
Looping result0.00060.0673580.0000
Template Total0.793496.620.3967
Template load0.00210.261620.0011
Template processing0.791296.375820.3956
Template load and register function0.00020.023410.0002
states
state_id_array0.00070.085810.0007
state_identifier_array0.00070.082520.0003
Override
Cache load0.00190.2320640.0000
Sytem overhead
Fetch class attribute can translate value0.00070.085020.0003
Fetch class attribute name0.00100.118950.0002
XML
Image XML parsing0.00050.065420.0003
class_abstraction
Instantiating content class attribute0.00000.001350.0000
General
dbfile0.00080.0989170.0000
String conversion0.00000.001240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
10content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 23
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs