guestbook not saved on page revision

Permalink
Hi there,

I'm having a tinker with the guestbook block, and I'm a bit puzzled. Specifically, I'm seeing if I can make the comments searchable; I haven't yet, but this has turned up the following problem.

(Or at least an inconsistency, and as I'm new to C5, I'm wondering if anybody has any ideas.)

I have a page with a guestbook on it. If I look in the db, I can see the following:-

mysql> select CollectionVersionBlocks.*, BlockTypes.btHandle from CollectionVersionBlocks join Blocks on CollectionVersionBlocks.bID = Blocks.bID join BlockTypes ON BlockTypes.btId=Blocks.btId where (cID=1 and cvID >= 13)  order by cvID asc, arHandle asc, cbDisplayOrder;
+-----+------+-----+------------+----------------+------------+---------------------------+--------------+-----------+
| cID | cvID | bID | arHandle   | cbDisplayOrder | isOriginal | cbOverrideAreaPermissions | cbIncludeAll | btHandle  |
+-----+------+-----+------------+----------------+------------+---------------------------+--------------+-----------+
|   1 |   13 |   1 | Header Nav |              0 | 0          |                         0 |            0 | autonav   |
|   1 |   13 |  92 | Main       |              0 | 0          |                         0 |            0 | html      |
|   1 |   13 |  84 | Main       |              1 | 0          |                         0 |            0 | autonav   |
|   1 |   13 |  88 | Main       |              2 | 1          |                         0 |            1 | guestbook |
|   1 |   13 |   4 | Sidebar    |              0 | 0          |                         0 |            0 | content   |
+-----+------+-----+------------+----------------+------------+---------------------------+--------------+-----------+


Now, I edit the page, fiddling with another block (e.g. the content block above the guestbook). Edit, exit edit mode, save. Everything looks like before (I've still got my guestbook).

But, If I run the same query:-

mysql> select CollectionVersionBlocks.*, BlockTypes.btHandle from CollectionVersionBlocks join Blocks on CollectionVersionBlocks.bID = Blocks.bID join BlockTypes ON BlockTypes.btId=Blocks.btId where (cID=1 and cvID >= 13)  order by cvID asc, arHandle asc, cbDisplayOrder;
+-----+------+-----+------------+----------------+------------+---------------------------+--------------+-----------+
| cID | cvID | bID | arHandle   | cbDisplayOrder | isOriginal | cbOverrideAreaPermissions | cbIncludeAll | btHandle  |
+-----+------+-----+------------+----------------+------------+---------------------------+--------------+-----------+
|   1 |   13 |   1 | Header Nav |              0 | 0          |                         0 |            0 | autonav   |
|   1 |   13 |  92 | Main       |              0 | 0          |                         0 |            0 | html      |
|   1 |   13 |  84 | Main       |              1 | 0          |                         0 |            0 | autonav   |
|   1 |   13 |  88 | Main       |              2 | 1          |                         0 |            1 | guestbook |
|   1 |   13 |   4 | Sidebar    |              0 | 0          |                         0 |            0 | content   |
|   1 |   14 |   1 | Header Nav |              0 | 0          |                         0 |            0 | autonav   |
|   1 |   14 |  93 | Main       |              0 | 1          |                         0 |            0 | html      |
|   1 |   14 |  84 | Main       |              1 | 0          |                         0 |            0 | autonav   |
|   1 |   14 |   4 | Sidebar    |              0 | 0          |                         0 |            0 | content   |
+-----+------+-----+------------+----------------+------------+---------------------------+--------------+-----------+


Hmm - 5 blocks in v13, but only 4 blocks in v14. It's the guestbook block which is missing in v14.

Now, I noticed this because the query used in concrete/libraries/database_indexed_search.php filters on cID and cvID, so I was never getting the guestbook content. I'm a little puzzled as to why the guestbook block is still there!

Any ideas folks? :)

 
randomgurn replied on at Permalink Reply
Aaah, I think I've answered my own question.

Looking in concrete/models/collection.php, the where clause is slightly different to that in concrete/libraries/database_indexed_search.php: the former makes use of the cbIncludeAll flag, whereas the latter does not.

So, trivial fix: update the query in database_indexed_search thus:-
select bID, arHandle from CollectionVersionBlocks where cID = ? and (cvID = ? or cbIncludeAll=1)


Longer term fix: update it to use the $c->getBlocks() method, so this only has to be changed in one place in the future! :)
randomgurn replied on at Permalink Best Answer Reply 1 Attachment
Patch attached to use getBlocks() instead of "manually" getting the blocks in concrete/libraries/database_indexed_search.php.