DDC-979: ArrayHydrator::updateResultPointer() must be an array, string given #1223

Closed
opened 2026-01-22 13:06:26 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 12, 2011).

Originally assigned to: @guilhermeblanco on GitHub.

Jira issue originally created by user tbo:

I have the following MySQL tables + data


CREATE TABLE `agent` (
  `agentID` bigint(20) NOT NULL AUTO_INCREMENT,
  `company` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`agentID`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='module=agent';

CREATE TABLE `file` (
  `fileID` bigint(20) NOT NULL AUTO_INCREMENT,
  `filename` varchar(100) DEFAULT NULL,
  `mimetype` varchar(100) DEFAULT NULL,
  `extension` varchar(5) DEFAULT NULL,
  `path` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`fileID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='module=agent';

CREATE TABLE `agentFile` (
  `agentID` bigint(20) NOT NULL COMMENT 'orderBy=orderNr&order=asc',
  `fileID` bigint(20) NOT NULL,
  `orderNr` int(11) DEFAULT NULL,
  PRIMARY KEY (`agentID`,`fileID`),
  KEY `agentFileAgent` (`agentID`),
  KEY `agentFileFile` (`fileID`),
  CONSTRAINT `agentFileAgent` FOREIGN KEY (`agentID`) REFERENCES `agent` (`agentID`) ON DELETE CASCADE ON UPDATE NO ACTION,
  CONSTRAINT `agentFileFile` FOREIGN KEY (`fileID`) REFERENCES `file` (`fileID`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='module=agent';


INSERT INTO `agent` (agentID,company) VALUES (1,'Company 1');
INSERT INTO `agent` (agentID,company) VALUES (2,'Company 2');
INSERT INTO `file` (fileID,filename,mimetype,extension,path) VALUES (1,'logoCompany2',NULL,NULL,NULL);
INSERT INTO `agentFile` (agentID,fileID,orderNr) VALUES (2,1,0);

Everything works fine if I do the following:

$query = $em->createQuery('SELECT a, af, f FROM Agent*Model_Agent a LEFT JOIN a._agentFileRefAgent af WITH af._orderNr=0 LEFT JOIN af.*file f');
$results = $query->getResult();

But I get an error when I replace getResult with getArrayResult.

$query = $em->createQuery('SELECT a, af, f FROM Agent*Model_Agent a LEFT JOIN a._agentFileRefAgent af WITH af._orderNr=0 LEFT JOIN af.*file f');
$results = $query->getArrayResult();

Error:

Catchable fatal error: Argument 1 passed to Doctrine\ORM\Internal\Hydration\ArrayHydrator::updateResultPointer() must be an array, string given, called in /var/www/vhost/issue/htdocs/externals/Doctrine/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 150 and defined in /var/www/vhost/issue/htdocs/externals/Doctrine/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 207
0.2773  12011956    Doctrine\ORM\AbstractQuery->getArrayResult( )   ../IndexController.php:18
0.2773  12012164    Doctrine\ORM\AbstractQuery->execute( )  ../AbstractQuery.php:378
0.3262  12217064    Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll( ) ../AbstractQuery.php:527
0.3263  12199568    Doctrine\ORM\Internal\Hydration\ArrayHydrator->_hydrateAll( )   ../AbstractHydrator.php:99
0.3276  12219368    Doctrine\ORM\Internal\Hydration\ArrayHydrator->_hydrateRow( )   ../ArrayHydrator.php:62
0.3277  12223840    Doctrine\ORM\Internal\Hydration\ArrayHydrator->updateResultPointer( )   ../ArrayHydrator.php:150
Originally created by @doctrinebot on GitHub (Jan 12, 2011). Originally assigned to: @guilhermeblanco on GitHub. Jira issue originally created by user tbo: I have the following MySQL tables + data ``` sql CREATE TABLE `agent` ( `agentID` bigint(20) NOT NULL AUTO_INCREMENT, `company` varchar(255) DEFAULT NULL, PRIMARY KEY (`agentID`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COMMENT='module=agent'; CREATE TABLE `file` ( `fileID` bigint(20) NOT NULL AUTO_INCREMENT, `filename` varchar(100) DEFAULT NULL, `mimetype` varchar(100) DEFAULT NULL, `extension` varchar(5) DEFAULT NULL, `path` varchar(255) DEFAULT NULL, PRIMARY KEY (`fileID`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COMMENT='module=agent'; CREATE TABLE `agentFile` ( `agentID` bigint(20) NOT NULL COMMENT 'orderBy=orderNr&order=asc', `fileID` bigint(20) NOT NULL, `orderNr` int(11) DEFAULT NULL, PRIMARY KEY (`agentID`,`fileID`), KEY `agentFileAgent` (`agentID`), KEY `agentFileFile` (`fileID`), CONSTRAINT `agentFileAgent` FOREIGN KEY (`agentID`) REFERENCES `agent` (`agentID`) ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT `agentFileFile` FOREIGN KEY (`fileID`) REFERENCES `file` (`fileID`) ON DELETE CASCADE ON UPDATE NO ACTION ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='module=agent'; INSERT INTO `agent` (agentID,company) VALUES (1,'Company 1'); INSERT INTO `agent` (agentID,company) VALUES (2,'Company 2'); INSERT INTO `file` (fileID,filename,mimetype,extension,path) VALUES (1,'logoCompany2',NULL,NULL,NULL); INSERT INTO `agentFile` (agentID,fileID,orderNr) VALUES (2,1,0); ``` Everything works fine if I do the following: ``` $query = $em->createQuery('SELECT a, af, f FROM Agent*Model_Agent a LEFT JOIN a._agentFileRefAgent af WITH af._orderNr=0 LEFT JOIN af.*file f'); $results = $query->getResult(); ``` But I get an error when I replace getResult with getArrayResult. ``` $query = $em->createQuery('SELECT a, af, f FROM Agent*Model_Agent a LEFT JOIN a._agentFileRefAgent af WITH af._orderNr=0 LEFT JOIN af.*file f'); $results = $query->getArrayResult(); ``` Error: ``` Catchable fatal error: Argument 1 passed to Doctrine\ORM\Internal\Hydration\ArrayHydrator::updateResultPointer() must be an array, string given, called in /var/www/vhost/issue/htdocs/externals/Doctrine/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 150 and defined in /var/www/vhost/issue/htdocs/externals/Doctrine/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php on line 207 0.2773 12011956 Doctrine\ORM\AbstractQuery->getArrayResult( ) ../IndexController.php:18 0.2773 12012164 Doctrine\ORM\AbstractQuery->execute( ) ../AbstractQuery.php:378 0.3262 12217064 Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll( ) ../AbstractQuery.php:527 0.3263 12199568 Doctrine\ORM\Internal\Hydration\ArrayHydrator->_hydrateAll( ) ../AbstractHydrator.php:99 0.3276 12219368 Doctrine\ORM\Internal\Hydration\ArrayHydrator->_hydrateRow( ) ../ArrayHydrator.php:62 0.3277 12223840 Doctrine\ORM\Internal\Hydration\ArrayHydrator->updateResultPointer( ) ../ArrayHydrator.php:150 ```
admin added the Bug label 2026-01-22 13:06:26 +01:00
admin closed this issue 2026-01-22 13:06:27 +01:00
Author
Owner

@doctrinebot commented on GitHub (Aug 16, 2011):

Comment created by @guilhermeblanco:

Could you please include your Model mappings too?

@doctrinebot commented on GitHub (Aug 16, 2011): Comment created by @guilhermeblanco: Could you please include your Model mappings too?
Author
Owner

@doctrinebot commented on GitHub (Dec 11, 2011):

Comment created by @guilhermeblanco:

Hi,

This special situation is not really possible.
You are not allowed to create a cross-reference Entity without defining an own @Id.
The situation you exposed here is due to it. Issue was left open but now after some tests it can be closed. In 2.2-DEV we added a better explanation for your problem, I hope the message is clear enough for you:

Entity of type Doctrine\Tests\ORM\Functional\Ticket\DDC979AgentFile has identity through a foreign entity Doctrine\Tests\ORM\Functional\Ticket\DDC979Agent, however this entity has no identity itself. 
You have to call EntityManager#persist() on the related entity and make sure that an identifier was generated before trying to persist 'Doctrine\Tests\ORM\Functional\Ticket\DDC979AgentFile'. 
In case of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call EntityManager#flush() between both persist operations.

Marking the issue as won't fix.

@doctrinebot commented on GitHub (Dec 11, 2011): Comment created by @guilhermeblanco: Hi, This special situation is not really possible. You are not allowed to create a cross-reference Entity without defining an own @Id. The situation you exposed here is due to it. Issue was left open but now after some tests it can be closed. In 2.2-DEV we added a better explanation for your problem, I hope the message is clear enough for you: ``` Entity of type Doctrine\Tests\ORM\Functional\Ticket\DDC979AgentFile has identity through a foreign entity Doctrine\Tests\ORM\Functional\Ticket\DDC979Agent, however this entity has no identity itself. You have to call EntityManager#persist() on the related entity and make sure that an identifier was generated before trying to persist 'Doctrine\Tests\ORM\Functional\Ticket\DDC979AgentFile'. In case of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call EntityManager#flush() between both persist operations. ``` Marking the issue as won't fix.
Author
Owner

@doctrinebot commented on GitHub (Dec 11, 2011):

Issue was closed with resolution "Won't Fix"

@doctrinebot commented on GitHub (Dec 11, 2011): Issue was closed with resolution "Won't Fix"
Author
Owner

@doctrinebot commented on GitHub (Dec 11, 2011):

Comment created by @guilhermeblanco:

Added the testcase I have used.

@doctrinebot commented on GitHub (Dec 11, 2011): Comment created by @guilhermeblanco: Added the testcase I have used.
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/8ac7443367a0d8fd35de

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/8ac7443367a0d8fd35de - [11129_DDC979Test.php](https://gist.github.com/8ac7443367a0d8fd35de#file-11129_DDC979Test-php)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#1223