Bug #67077
closedEpic #64459: Make TYPO3 run on PostgreSQL
PHP error on page creation
Added by alexis nicolas over 9 years ago. Updated about 6 years ago.
100%
Description
In 7.2 when trying to create a page, pagetree remain stuck on "Please wait..." and exception is raised:
PHP Catchable Fatal Error: Argument 2 passed to TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord() must be of the type array, null given, called in C:\wamp\www\typo3_7.2\typo3\sysext\backend\Classes\Tree\Pagetree\Commands.php on line 349 and defined in C:\wamp\www\typo3_7.2\typo3\sysext\backend\Classes\Utility\IconUtility.php line 693
Logging in faulty files displays nothing, but the trouble seems to be caused by 'pages' table row number used by the newly created page.
Updated by Markus Klein over 9 years ago
Are you testing on latest master branch?
Is your DB up to date?
Updated by alexis nicolas over 9 years ago
Yes, I'm on latest master branch and PostgreSQL is up to date.
Updated by Markus Klein over 9 years ago
Ah ok, then I was mislead. You didn't mention that DBAL is active ;-)
So you need to search backwards where this second argument stems from. I guess from some DB query that fails.
Did you enable the Development-Preset in the Install Tool? A failed SQL query should show up then in the BE.
(If it happens in an AJAX request, check the content returned by that request, it will contain the backtrace.)
Updated by alexis nicolas over 9 years ago
Develoment preset is active and I find no SQL related error. But you're right, a syntaxe error is returned in a JSON answer from typo3/ajax.php?ajaxID=ExtDirect::route&namespace=TYPO3.Components.PageTree:
And this problem remains in master dev branch.
Updated by Andreas Kienast over 9 years ago
The error itself it caused by $record
being NULL, but $record['uid'] !== 0
returns TRUE. We can patch this for now, but the cause has to be tackled down to it's source.
Can you please head to the method getNodeRecord
in typo3/sysext/backend/Classes/Tree/Pagetree/Commands.php
and debug the content of $record
?
Updated by Andreas Kienast over 9 years ago
- Status changed from New to Needs Feedback
Updated by alexis nicolas over 9 years ago
$record
is empty in getNodeRecord
. But tracking further to getRecordWSOL
in BackendUtility.php
I loose any error information (though the error message is still here).
Updated by Markus Klein over 9 years ago
The problem is an unsafe comparison
if ($record['uid'] !== 0) {
I'm sure that $record comes from DB directly and therefore 'uid' is of type string and not int, so the comparison is wrong.
Can you try changing this to:
if ((int)$record['uid'] !== 0) {
This line dates back to #24250
Updated by alexis nicolas over 9 years ago
When I cast $record['uid']
to int
and I try to add a new page, I get an exception [1.4.14]: Attempt to move record '[root-level]' (pages:) without having permissions to do so.
Updated by Markus Klein over 9 years ago
So you have the proof that your $record is not there. The cast to int now gives 0 for the uid, which is the "[root-level]".
You have to trace back, where $record gets its data from. There is something wrong.
Updated by Markus Klein over 9 years ago
The int-cast thing will be solved with: #67138
Updated by alexis nicolas over 9 years ago
I deleted every page records, attempted tp add a new standard page below root: it creates a new root page with no id, [No Title] and a new page below... Strange, isn't it?
I'm trying to trace $record
back.
EDIT: $record
gets its data from BackendUtility::getRecordWSOL
Updated by alexis nicolas over 9 years ago
Basically there is a thing I hardly understand: in my database, I have only 1 page record (with id=60), when I echo $record['uid']
i get both root id (0) and my page id (60): so if ((int)$record['uid'] !== 0)
comparison results both TRUE and FALSE, is it a normal behaviour?
Updated by Markus Klein over 9 years ago
when I echo $record['uid'] i get both root id (0) and my page id (60)
you mean $record['uid'] holds 2 values??
Updated by alexis nicolas over 9 years ago
Exactly, on echo $record['uid'] I get 060
Updated by Markus Klein over 9 years ago
That is for sure a major problem. I debugged it here locally and this is always a normal record for me.
Do you have workspaces installed? If so, please disable it and try if it works without it.
Updated by alexis nicolas over 9 years ago
?? Do you have workspaces installed? ??
I don't actually know... How can I check this?
Updated by Markus Klein over 9 years ago
Extension Manager. Extension is called "workspaces"
Updated by Markus Klein over 9 years ago
Then the DB driver delivers very strange results. You've to check BackendUtility::getRecord then.
Updated by Markus Klein over 9 years ago
- Category changed from Pagetree to 999
- Assignee set to alexis nicolas
- Complexity set to hard
Updated by alexis nicolas over 9 years ago
Everything looks fine in BackendUtility::getRecord(). But a strange things occures: $record is created in Commands.php:getNodeRecord() from an instance of BackendUtility::getRecordWSOL(); result viewed in getRecordWSOL() is an array containing data taken from my only page record (each field is a string), but in getNodeRecord() it is null and the user right exception is raised!
Updated by alexis nicolas over 9 years ago
Exception message "[1.4.14]: Attempt to move record '[root-level]' (pages:) without having permissions to do so." is originated in ExtdirectTreeCommands:insertNodeAfterDestination(). There, the try bloc seems not to be executed.
Updated by Morton Jonuschat over 9 years ago
I think this is due to a bug exec_INSERTquery() in the DBAL DataseConnection.php
If you look at line 524 you'll see that the last_insert_id isn't updated after the statement, as a result a subsequent call to sql_insert_id() will return a possibly wrong value (of a previous statement or the default value 0). Returning the default value seems to be what is happening here.
Updated by alexis nicolas over 9 years ago
Thanks for pointing things out Markus and Morton, I think i solved the problem (at least it works on my local).
EDIT: since I can't commit a patch for review (for now), here is the raw change I made in [[https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/dbal/Classes/Database/DatabaseConnection.php#L524]]:
524 $sqlResult = $this->handlerInstance[$this->lastHandlerKey]->_query($this->lastQuery, FALSE); 525 (ADDED) $new_id = $this->handlerInstance[$this->lastHandlerKey]->Insert_ID($table, $this->cache_autoIncFields[$table]); 526 (ADDED) $this->handlerInstance[$this->lastHandlerKey]->last_insert_id = $new_id;
Updated by Alexander Opitz about 9 years ago
- Status changed from Needs Feedback to Accepted
- Assignee changed from alexis nicolas to Morton Jonuschat
Hi Morton,
can you please bring this as patch into TYPO3? (If you don't have time, please assign it back to me).
Updated by Gerrit Code Review about 9 years ago
- Status changed from Accepted to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/43187
Updated by Morton Jonuschat about 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset af79a94fad4ed01f90a9edb98d52b172f5130cb6.