global $user;
$node = node_load($_POST['expire_offer']);
$node->revision = TRUE;
$node->uid = $user->uid;
$node->log = 'This offer expired from rate manager expire ' . date('m-j-Y');


When I remove node_save($node); it loads properly.

enter image description here

  • 1
    You should be aware of posting code and urls of your publicly accessible dev/stage-environment.
    – sgoelz
    Sep 28, 2017 at 14:17
  • Also, you will absolutely want to avoid using $_POST directly. Using Postman, I could go through and expire nodes all I want. If this is something unique per user, you should have a route set up for it like /supplier/offer/{user_id}/{offer_id}/expire and have some checks in place to see if that offer was extended to that user, and still active. Not perfect, but a step up.
    – Kevin
    Sep 28, 2017 at 22:08
  • You could also consider securing it by putting it behind /user/{uid}/offer/{offer_id}/expire. With proper permissions in place, only that user or administrative users can pass beyond /user/{uid}. Then you wouldn't need global $user, because you could pull it from the route.
    – Kevin
    Sep 28, 2017 at 22:09

2 Answers 2


Sorry, I don't have enough reputation points to comment so I should post this as an answer.

Obviously your 500 error comes from the script. The node_save($node); does not cause your error, it's just the trigger.

If you want to follow the best coding practices, you should use try and catch blocks to catch your errors before you try to modify your database.

If the "dblog" module is activated you could follow the error stack to debug your script or else you could comment out all of the lines that are assigning new values to your variables and start re-executing your script by uncommenting one line at the time utill the error is reproduced.

I hope that this helps a bit. We have all been there. Cheers.


Since node_save() usually requires a lot of resources and time to process the data, most likely you hit some PHP resource limits.

So first of all, try increasing the following PHP options in your php.ini:

  • memory_limit = 1G
  • max_execution_time = 120

Note: To identify your php.ini, check in Reports, Status and click on PHP link which will redirect you to phpinfo() page.

Then restart your Apache server. If won't work, please check your Apache and PHP log files, eventually Recent logs in Drupal for further details about your error.

If increasing limits helped, to lower the resource requirements, at first try the followings:

  • disable unneeded modules (like Devel, etc.),
  • install cache service (Memcached/Redis).

See: How do you improve Drupal performance?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.