Skip to content
Snippets Groups Projects

Minimal approach with shutdown function

2 unresolved threads

Closes #3405976

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • mondrake @mondrake started a thread on the diff
  • 753 *
    754 * If drupal_register_shutdown_function() exists the commit will occur during
    755 * shutdown so that it occurs at the latest possible moment.
    756 *
    757 * @param bool $shutdown
    758 * Internal param to denote that the method is being called by
    759 * _drupal_shutdown_function().
    760 *
    761 * @return void
    762 *
    763 * @internal
    764 * This method exists only to work around a bug caused by Drupal incorrectly
    765 * relying on object destruction order to commit transactions. Xdebug 3.3.0
    766 * changes the order of object destruction when the develop mode is enabled.
    767 */
    768 public static function commitAllOnShutdown(bool $shutdown = FALSE): void {
    • So this function has two different paths depending on the value of $shutdown? False to register the callback and true to do the actual thing? Wouldn't it be better to have two spearate functions?

    • Author Maintainer

      I think this is the lesser of two not great paths... having two static methods is ickier than the internal static. All the ickiness is in one self contained method.

    • Please register or sign in to reply
  • mondrake @mondrake started a thread on the diff
  • 812 $manager = $testConnection->transactionManager();
    813 $reflectionMethod = new \ReflectionMethod($manager, 'addStackItem');
    814 $reflectionMethod->invoke($manager, 'bar', new StackItem('qux', StackItemType::Root));
    815 // Ensure transaction state can be determined during object destruction.
    816 // This is necessary for the test to pass when xdebug.mode has the 'develop'
    817 // option enabled.
    818 $reflectionProperty = new \ReflectionProperty(TransactionManagerBase::class, 'connectionTransactionState');
    819 $reflectionProperty->setValue($manager, ClientConnectionTransactionState::Active);
    812 820
    813 821 $this->expectException(\AssertionError::class);
    814 822 $this->expectExceptionMessageMatches("/^Transaction .stack was not empty\\. Active stack: bar\\\\qux/");
    823 // Ensure that __destruct() results in an assertion error. Note that this
    824 // will normally be called by PHP during the object's destruction but Drupal
    825 // will commit all transactions when a database is closed thereby making
    826 // this impossible to test unless it is called directly.
    827 $manager->__destruct();
  • Alex Pott added 1 commit
  • closed

  • Please register or sign in to reply
    Loading