Bug #67077
PHP error on page creation
Status: | Needs Feedback | Start date: | 2015-05-21 | |
---|---|---|---|---|
Priority: | Should have | Due date: | ||
Assigned To: | alexis nicolas | % Done: | 0% |
|
Category: | DBAL | Spent time: | - | |
Target version: | - | |||
TYPO3 Version: | 7 | Is Regression: | No | |
PHP Version: | 5.5 | Sprint Focus: | ||
Complexity: | hard |
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.
Related issues
History
#1 Updated by Markus Klein 2 months ago
Are you testing on latest master branch?
Is your DB up to date?
#2 Updated by alexis nicolas 2 months ago
Yes, I'm on latest master branch and PostgreSQL is up to date.
#3 Updated by Markus Klein 2 months 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.)
#4 Updated by alexis nicolas 2 months 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.
#5 Updated by Andreas Fernandez 2 months 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
?
#6 Updated by Andreas Fernandez 2 months ago
- Status changed from New to Needs Feedback
#7 Updated by alexis nicolas 2 months 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).
#8 Updated by Markus Klein 2 months 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
#9 Updated by alexis nicolas 2 months 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.
#10 Updated by Markus Klein 2 months 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.
#11 Updated by Markus Klein 2 months ago
The int-cast thing will be solved with: #67138
#12 Updated by alexis nicolas 2 months 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
#13 Updated by alexis nicolas 2 months 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?
#14 Updated by Markus Klein 2 months ago
when I echo $record['uid'] i get both root id (0) and my page id (60)
you mean $record['uid'] holds 2 values??
#15 Updated by alexis nicolas 2 months ago
Exactly, on echo $record['uid'] I get 060
#16 Updated by Markus Klein 2 months 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.
#17 Updated by alexis nicolas 2 months ago
?? Do you have workspaces installed? ??
I don't actually know... How can I check this?
#18 Updated by Markus Klein 2 months ago
Extension Manager. Extension is called "workspaces"
#19 Updated by alexis nicolas 2 months ago
Worspaces is already inactive.
#20 Updated by Markus Klein 2 months ago
Then the DB driver delivers very strange results. You've to check BackendUtility::getRecord then.
#21 Updated by Markus Klein 2 months ago
- Category changed from Pagetree to DBAL
- Assigned To set to alexis nicolas
- Complexity set to hard
#22 Updated by alexis nicolas 2 months 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!
#23 Updated by alexis nicolas 2 months 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.
#24 Updated by Morton Jonuschat 2 months 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.
#25 Updated by alexis nicolas 2 months 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;