This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

'Validate' case in hook_nodeapi

Hi all,

Is case "validate" (from hook_nodeapi) normally called when you create a new node?

According to http://drupaldocs.org/api/4.6/function/hook_nodeapi:

"validate": The user has just finished editing the node and is trying to preview or submit it. This hook can be used to check or even modify the node.

I understand it shouldn't be called at the moment of node creation, but this is not what's happening on my module. Everytime I access

node/add/page

the case "validate" is executed.

Is it right or am I missing anything, please?

Thanks, Andre.

A simple solution for resource locking and race condition prevention for Drupal (beyond DB row locking!)

Hi,

The lack of tools to deal with race conditions and resource locking in Drupal was irritating me lately so I wrote some code to fix my problem. Maybe it will be of use to somebody.

The problem
Web server is threaded and HTTP is stateless. What can happen on high traffic sites is that a user, or multiple users, may try to access some resource (a file, a DB row, a stream, and more often an AJAX request).

A simple example:
In the following HTML form we use a link to submit instead of a submit button (maybe it makes the site look cooler, ask the designers ;-).

<form name="myform">
  <input type="text" name="data" />
  <a href="" onclick="document.myform.submit(); return false;">The Submit Link</a>
</form>

What can happen here as a user can click the link multiple times thereby sending multiple requests to the web server. If they are timed correctly multiple requests may be processed! The result may be as simple as a duplicate comment or email, but could be as bad as duplicate 1000$ products charged to a clients credit card (uh oh...).

Of course we could use some fancy javascript to make the button unclickable, or many other things, but those solutions sometimes just aren't enough. For instance, if this were a form to redeem a promo code (free iTunes bucks maybe) there might be many people trying to sneak a few extra bucks out of the system. Of course this example can be entirely prevented via row locking in the DB but other problems cannot (those examples are usually more complicated ;-).

Javascript includes in filters

Hopefully this is a simple question, I have a module which operates as a filter and part of the filter inserts some minimal javascript to call functions in a separate js include file. In order for this to work the js file needs to be included in the page header which can be accomplished using drupal_add_js under normal circumstances and when the filter is actually applied.

New module to display deletion statistics

Hi!

I just committed a tiny module that displays deletion statistics in a block.

http://cvs.drupal.org/viewcvs/drupal/contributions/modules/deleted/?only...

The module is limited to the DRUPAL-4-6 branch and has not been tested on 4.7

Menu Bug with Views ?

I am trying out the views module this afternoon to try and create a tabbed view (http://www.rideonby.co.uk/taxonomy/vocabulary/1) and not only do the menu tabs disappear but I also get a side menu entry as well.

I am just wondering if this is something I am doing or if it is a bug in views (Ive not checked issues yet) ?

problem with inventory in e-commerce module in 4.4.6

hi all,
i have installed E-Commerce module and developed small site.
My problem is i have selected one product
then in product we have {VIEW EDIT AND PRODUCT} i have selected product then i that
Inventory management for this item:Enabled
then no: of stocks 3.

But when other person selecting more than 3 items say 4 it is accepting and calculating amount.
so how can i say to them that maximum you can select is 3 or shoping is over.

please help me

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions