Updated to 5.x

pobster - May 10, 2007 - 08:19
Project:Attached Node
Version:4.7.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Obviously create attached_node.info;

; $Id$
name = Attached Node
description = A utility module to attach nodes to other nodes.

You don't even really need to run the patch, all it does is remove the modules description (as that's been moved to the .info file).

Enjoy!

Pobster

AttachmentSize
attached_node.patch477 bytes

#1

tinthing - July 26, 2007 - 12:30

I gave this a try because I'd really like to be able to embed nodes (e.g. image nodes whose body text is a key for the image) within a main story. It *almost* works, but there are a couple of nasty faults (can't tell if they are related). I've not used drupal versions prior to v5 so can't compare how well this module works under v4 releases.

The problems I get are:
The following error message after submitting any change once the module is enabled -

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 WHERE cid = 'filter'' at line 1 query: DELETE FROM 1 WHERE cid = 'filter' in /var/www/html/karoscene/includes/database.mysql.inc on line 172.

An embedded image node with a plain HTML body with a table (it's a parts diagram and matching key) is displayed with a thumbnail, but the div block it appears in isn't closed properly, leading to all the remaining page text appearing withing the block, with the table data at the end - very mashed :-(

The trouble probably all stems from the SQL error, but I'm not knowledgable enough about drupal internals to track it down.

#2

pobster - July 26, 2007 - 20:15

That's unlikely to be connected to this module I'd have thought. Line 172 is within a helper function for db_query and I'd have thought the error stems from the strange '1' in the query. Attached_node doesn't have any database associated with it, so to hazard a guess... Do you perhaps store your table in the database? Does the node you're trying to embed contain any custom php? I'm afraid I'll need to know a whole lot more before its evident where the problem lies...

Pobster

#3

tinthing - July 27, 2007 - 13:12

Yes, I would have thought so too. I've not got a particularly exotic set of additional modules, but started again from scratch to reproduce the problem. Here's the setup:

  • Fedora Core 6 (N.B. selinux set to 'permissive' - previously had lots of grief if set 'enforcing')
  • Drupal 5.1 install:
    • unzip drupal in /var/www/html: tar xzvf drupal-5.1.tar.gz
    • rename directory: mv drupal-5.1 foo
    • chown -R root.apache foo
    • chmod 664 foo/sites/default/settings.php
    • create mysql database 'foo'
    • point browser at http://localhost/foo
    • fill out install form (db name, password etc.)
    • complete install, run cron, create writable files directory,
  • Create test story, no error.
  • Add attached_node module:
    • unzip module in modules directory: tar xzvf attached_node-4.7.x-1.x-dev.tar.gz
    • set file owner/group: chown -R root.apache attached_node
    • copy/paste module info from here into attached_node.info
    • copy/paste patch from here to attached_node.patch
    • apply patch: patch attached_node.module attached_node.patch
    • enable module under http://localhost/foo/?q=admin/build/modules
    • enable input filter under http://localhost/foo/?q=admin/settings/filters/1 (is this the mysterious 1 in the error?)
  • Return to test article, and edit to add some text (not even using new filter)
  • SQL error as above.

    My guess is that there is something going wrong when the input filters are applied. Any ideas?
    cheers

  • #4

    pobster - July 27, 2007 - 17:46

    I wouldn't have thought that was causing the error as I mentioned before attached_node doesn't do any db_queries at all?

    And here's a live site with it working just fine for me; http://www.ciclosuno.com/node/685

    Hmmm... I take it that your site being 'localhost' isn't online then? So I couldn't take a look myself at what's going on?

    Pobster

    #5

    tinthing - July 28, 2007 - 23:14

    No, the site isn't online - it's as I described, a vanilla drupal install with just attached_node added.

    Having gone grepping, it seems that the source of the bad SQL is the clear_cache_all() function in cache.inc:

    function cache_clear_all($cid = NULL, $table = NULL, $wildcard = FALSE)

    Almost the last line of the file is where the "DELETE FROM .. WHERE cid = .." query appears. This function is called by attached_node.module here:

    function attached_node_nodeapi(&$node, $op) {
      if($op == "update") {
        // since this is a node-specific filter, clear the cache when nodes are updated
        cache_clear_all('filter', true);
      }
    }

    I'm not sure what this is trying to do, but the parameters being passed don't seem to line up with those expected by the function. Commenting it out stops the error but (obviously) no longer does what was intended either.

    Any help?

    #6

    pobster - July 29, 2007 - 07:49

    Aha! Yes, well found :o) Of course, this isn't affecting me as I don't use the cache - just change it to the new drupal 5.x api, so something like...

    <?php
    /**
    * Clears the filter cache when any node is updated
    */
    function attached_node_nodeapi(&$node, $op) {
      if(
    $op == "update") {
       
    // since this is a node-specific filter, clear the cache when nodes are updated
       
    cache_clear_all(null, 'cache_filter');
      }
    }
    ?>

    My reasoning for losing the wildcard = TRUE is that now as the caches are separate, you *can* just completely empty the filter table, whereas before the function was emptying out 'filter****' matches (so effectively the same thing).

    Pobster

    #7

    tinthing - July 29, 2007 - 14:22

    Yup, that's much better!

    My other issue with duff HTML appears to be caused by the point at which the teaser block is cut - my embedded image node has a plain HTML table in the body text, but it's getting cut off after a few rows. If I put

    <!--break-->

    at the end of the body text then the page rendering works fine. So, things are starting to look good.

    My remaining issue is that filter text like [node:20,res="original"] doesn't seem to give me a full size image, just the thumbnail. Am I doing this right? Seems to be as described in the help, although when I look at the attached_node help page where it lists the parameters which can be overridden for each node type, none are listed.

    cheers

    #8

    pobster - July 29, 2007 - 15:36

    I'm afraid that was an issue before and well... I didn't write the module so it's not something I'm particularly qualified to answer...

    ...But I will anyway ;o)

    The 'break off' point is always a problem when you're using filters no matter what they are, that kind of behaviour is expected I'm afraid. What you're doing is the best way to 'counter' its action though.

    Now the res part... This *does* work but you need to fiddle a little... According to the module you need to go to; (eg) admin/filters/3/configure and add the valid parameters here for each node type but... Submitting them doesn't 'take'... So... Manually alter your db (variable) find 'attached_node_allowed_vars_image' and enter s:3:"res"; as the value. Should now work... I can't really debug this as it shouldn't actually be causing any problems as far as I can tell?

    Pobster

    #9

    tinthing - July 30, 2007 - 13:40

    Ah, OK I hadn't twigged that you have to configure the filter with the params to be allowed. Having added title,res,width I can use [node:20,res="original",title="foobar"] and get just what I expect. Can't seem to get any difference when trying to specify a width though.

    I didn't have to go fiddling with the database to get this to work. However, I have had problems elsewhere in filter config with settings not being applied. E.g. I added some extra HTML tags to the HTML filter and found that they didn't 'take' when saving settings from the Configure form, but *did* if I then switched back to the View form and saved there too.

    Getting width to work would make this module perfect - extremely useful for layouts of more elaborate articles. Can achieve the same effect by editing the CSS, but of course that's global.

    #10

    Duncan Pierce - September 1, 2007 - 16:14

    Nice work.

    I've rerolled the patch with the cache fix and added the module info file needed by Drupal 5.x. Seems to work for me.

    AttachmentSize
    attached_node-5.x.patch 1.34 KB

    #11

    TomChiverton - September 30, 2007 - 12:26

    I can confirm the 4.7 attached_node, patched as per this issue, runs fine on 5.2.

    This should be pushed out.

    #12

    shane - October 11, 2007 - 15:18

    +1 for rolling this out as a package - I upgraded from 4.7.7 to 5.2 and patcher per this node info, and it works fine.

    FYI - I WOULD love to see attached_node ported to 6.x as well - I'll be rolling to 6.x ASAP - and I dearly rely on the attached_node - I think attached_node should be a part of core ... It's one of those "duh" modules, the ability to include chunks of text into other nodes. Take a "news" page for example, each news article gets a footer with "About ... " information on the company ... just create a node and include it - BOOM! Done! Thanks for listening. Thanks for maintaining the code!

    #13

    pobster - October 12, 2007 - 07:32

    I'll do it when I need it, I rely heavily on this module.

    Pobster

    #14

    David_Rothstein - January 21, 2008 - 05:43

    There is a new module available for 5.x which more or less does the same thing as Attached Node:
    http://drupal.org/project/InsertNode

    It might be a good idea to do any new development there, seeing as how Attached Node looks like it's near death... ;)

     
     

    Drupal is a registered trademark of Dries Buytaert.