View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
1031 | RackTables | default | public | 2013-10-15 14:39 | 2013-11-10 18:19 |
Reporter | arichard | Assigned To | adoom42 | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 0.20.5 | ||||
Target Version | 0.20.6 | Fixed in Version | 0.20.6 | ||
Summary | 1031: Search and object update fails and return a blank page | ||||
Description | Searching an object returns a blank page. Modifying an object returns a blank page. In the httpd log : [Tue Oct 15 12:09:37 2013] [error] [client 192.168.0.3] PHP Fatal error: Call to a member function execute() on a non-object in /opt/RackTables-0.20.5/wwwroot/inc/database.php on line 3733, referer: http://racktables/index.php?page=object&tab=edit&object_id=17 The line 3733 is the line $prepared->execute ยง$args); in the function usePreparedSelectBlade : function usePreparedSelectBlade ($query, $args = array()) { global $dbxlink; try { $prepared = $dbxlink->prepare ($query); $prepared->execute ($args); return $prepared; } catch (PDOException $e) { throw convertPDOException ($e); } } | ||||
Steps To Reproduce | A simple search : http://racktables/index.php?page=search&last_page=object&last_tab=default&q=uranus301 triggers the problem. | ||||
Additional Information | After debugging, I have found and corrected several errors : 1) no test for $dbxlink->prepare() returning null in usePreparedSelectBlade After adding some debug, I found out that $dbxlink->prepare ($query); returns a null object without triggering an exception (this is a well known beavior of PDO). It seams that a new select was issued on the transaction without fetching the previous results. 2) The real fault is in getStickerSearchResults function getStickerSearchResults ($tablename, $what) { $result = usePreparedSelectBlade ( 'SELECT object_id, attr_id FROM AttributeValue AV ' . "INNER JOIN ${tablename} O ON AV.object_id = O.id " . 'WHERE string_value LIKE ? ORDER BY object_id', array ("%${what}%") ); $map = getAttrMap(); $ret = array(); while ($row = $result->fetch (PDO::FETCH_ASSOC)) { if ($map[$row['attr_id']]['type'] == 'string') { $ret[$row['object_id']]['id'] = $row['object_id']; $ret[$row['object_id']]['by_sticker'][] = $row['attr_id']; } } return $ret; } Here the call to $map = GetAttrMap() use the same transaction and triggers the problem. A very simple correction is to put $map = GetAttrMap() on the top of the function : function getStickerSearchResults ($tablename, $what) { $map = getAttrMap(); $result = usePreparedSelectBlade ( 'SELECT object_id, attr_id FROM AttributeValue AV ' . "INNER JOIN ${tablename} O ON AV.object_id = O.id " . 'WHERE string_value LIKE ? ORDER BY object_id', array ("%${what}%") ); $ret = array(); while ($row = $result->fetch (PDO::FETCH_ASSOC)) { if ($map[$row['attr_id']]['type'] == 'string') { $ret[$row['object_id']]['id'] = $row['object_id']; $ret[$row['object_id']]['by_sticker'][] = $row['attr_id']; } } return $ret; } This will correct the search case. 3) Syntax error in update query The update of an object fails because of a syntax error in commitIdateAttrValue. There is a missing space in the first select : $result = usePreparedSelectBlade ( "SELECT type AS attr_type, av.* FROM Attribute a " . "LEFT JOIN AttributeValue av ON a.id = av.attr_id AND av.object_id = ?" . "WHERE a.id = ?", array ($object_id, $attr_id) ); You need to add a space between the ? and the WHERE clause : $result = usePreparedSelectBlade ( "SELECT type AS attr_type, av.* FROM Attribute a " . "LEFT JOIN AttributeValue av ON a.id = av.attr_id AND av.object_id = ? " . "WHERE a.id = ?", array ($object_id, $attr_id) ); | ||||
Tags | No tags attached. | ||||
Would you like to author a git commit to fix these issues? | |
I was unable to reproduce the errors, but committed your changes anyway as they seem reasonable. Thanks for the patch. | |
Date Modified | Username | Field | Change |
---|---|---|---|
2013-10-15 14:39 | arichard | New Issue | |
2013-10-17 16:59 | infrastation | Note Added: 0001869 | |
2013-11-10 18:19 | adoom42 | Note Added: 0001927 | |
2013-11-10 18:19 | adoom42 | Assigned To | => adoom42 |
2013-11-10 18:19 | adoom42 | Status | new => closed |
2013-11-10 18:19 | adoom42 | Resolution | open => fixed |
2013-11-10 18:19 | adoom42 | Fixed in Version | => 0.20.6 |
2013-11-10 18:19 | adoom42 | Target Version | => 0.20.6 |