I tried to schedule an action with below configuration:

EVENT:
Entity insert (Reacts after a new entity has been inserted)
Target Entity Type: content
Target Bundle: article

ACTION:
Schedule a task (Schedule a task to the future)
Target Entity Type: content
Target Bundle: article
Field: Created: Authored on [created]
Identifier: Delete article with nid: [node:nid] after 1 Month.
Scheduler:
Time offset: 1
Time Unit: Months

ACTION INSIDE THE SCHEDULE
Delete an entity
Target Entity Type: content
Target Bundle: article

When try to create a new article, the article is not created and the below error is logged:
Drupal\Core\Entity\EntityStorageException: DateTime::__construct(): Failed to parse time string (1552786750) at position 8 (5): Unexpected character in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 783 of S:\Sites\dev.####\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).

Thank you,

Comments

C.E.A created an issue. See original summary.

c.e.a’s picture

Issue summary: View changes
c.e.a’s picture

Title: Schedule action not working with php error » 'Schedule' action not working and generating a php error
c.e.a’s picture

Assigned: Unassigned » yseki
Drutech’s picture

Same error here...
Also the scheduled actions cannot be executed with returned errors

any help yet ?

thanks

yseki’s picture

It seems the way I've planned the scheduler to work wasn't matching the requirements you guys have, so I've made some changes on that, the most important one is the now the scheduled task keeps record of the entity that has triggered, allowing the update of the entity.

Example.
Lets say you want to schedule a task to update the publishing status of one node after 6 months of the last changed date.

In order to do that, we can create a Rule that is dispatched and schedule an action to update the node status that has triggered the scheduler in the first place.

It will gonna be on beta-7, hat I'm pushing today.

  • yuriseki committed 9a81a2c on 8.x-1.x
    Issue #3040833 by C.E.A, yuriseki: 'Schedule' action not working and...
c.e.a’s picture

Thank you for your time, but still the problem not fixed...

I tried to schedule an action with below configuration:

EVENT:
Entity insert (Reacts after a new entity has been inserted)
Target Entity Type: content
Target Bundle: article

ACTION:
Schedule a task (Schedule a task to the future)
Target Entity Type: content
Target Bundle: article
Field: Created: Authored on [created]
Identifier: Delete article with nid: [node:nid] after 1 Month.
Scheduler:
Time offset: 1
Time Unit: Months

ACTION INSIDE THE SCHEDULE
Delete an entity
Target Entity Type: content
Target Bundle: article

When try to create a new article, the article is not created and the below error is logged:
Drupal\Core\Entity\EntityStorageException: DateTime::__construct(): Failed to parse time string (1552786750) at position 8 (5): Unexpected character in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 783 of S:\Sites\dev.####\web\core\lib\Drupal\Core\Entity\Sql\SqlContentEntityStorage.php).

Thank you,

c.e.a’s picture

Status: Active » Needs work
c.e.a’s picture

Only if I check the below checkbox, the 'schedule action' will work without errors.

[X] Save entity as the last action of the task.
Check this option if you are changing values on the entity and you want to persist those changes on the database.

But in my case, there is no need to check this checkbox because...

Check this option if you are changing values on the entity and you want to persist those changes on the database.

as per checkbox description, Check this option if you are changing values on the entity but my scheduler is set to DELETE the entity after 'X' months.

Thank you,

c.e.a’s picture

Ok... I believe the issue still exist because I cannot perform database update...

When I visit: /update.php, I see the below:

1 PENDING UPDATE
business_rules module
8102 - Allows schedule to work with event variables. https:www.drupal.orgprojectbusiness_rulesissues3040833

and when I try to run the update, I receive the below error:

business_rules module
Update #8102
Failed: Drupal\Core\Database\SchemaObjectExistsException: Cannot add field br_schedule.update_entity: field already exists. in Drupal\Core\Database\Driver\mysql\Schema->addField() (line 414 of \web\core\lib\Drupal\Core\Database\Driver\mysql\Schema.php)

Note: every time I visit: /update.php... same scenario!

Any clue ?!

Thank you

steveoriol’s picture

I receive a similar error with "drush updb" :

d8.site       >> The following updates are pending:
d8.site       >> business_rules module :
d8.site       >>   8102 -   Allows schedule to work with event variables.  https:www.drupal.orgprojectbusiness_rulesissues3040833
d8.site       >> 
d8.site       >> Do you wish to run all pending updates? (y/n):
d8.site       >> y
d8.site       >> SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL     [error]
server version for the right syntax to use near 'NULL DEFAULT NULL COMMENT 'Save entity as the last action of the task'' at line 1: ALTER TABLE {br_schedule} ADD
`update_entity`  NULL DEFAULT NULL COMMENT 'Save entity as the last action of the task'; Array
(
)

d8.site       >> Performing business_rules_update_8102                                                                                                             [ok]
d8.site       >> Failed: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your   [error]
MySQL server version for the right syntax to use near 'NULL DEFAULT NULL COMMENT 'Save entity as the last action of the task'' at line 1: ALTER TABLE {br_schedule}
ADD `update_entity`  NULL DEFAULT NULL COMMENT 'Save entity as the last action of the task'; Array
(
)

d8.site       >> Cache rebuild complete.                                                                                                                           [ok]
d8.site       >> Finished performing updates.
yseki’s picture

Status: Needs work » Needs review

Hi guys,

Sorry about that, here is the patch https://www.drupal.org/project/business_rules/issues/3043734#comment-130...

It's updated on dev as well.

c.e.a’s picture

@yuriseki the patch provided here (#3043734: Update to beta7 fails: SQLSTATE[42000] Assigned to: yseki) solved the creation of the schedule but still cannot edit the scheduled action.

c.e.a’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.