User login

IRC discussion: adding a taxonomy term to all nodes

Assigning a taxonomy term to all nodes

(Colloquy lost the beginning, buh.)

ben-agaric: SQL
[07:55am] lyricnz: ben-agaric: all I did was point php executable at a different php.ini, with bigger memory settings.
[07:56am] lyricnz: php -c /other/php.ini yourprogram.php
[07:56am] ben-agaric: lyricnz: cool, my issue was my CLI php.ini had /lower/ settings than my Apache php.ini
[07:56am] jredding: ya. SQL would work but it'd take me a while to relearn SQL looping.. unless you've got a good example..
[07:56am] ben-agaric: once I understood there was another one, and found it
[07:56am] ben-agaric: I did it
[07:56am] ben-agaric: jredding: no looping
[07:56am] lyricnz: I've been doing that with big data-loads (since I never really figured out why I run out of memory anyway - appears to be lame garbage collection)
[07:56am] jredding: no looping? eh..
[07:57am] ben-agaric: nope, which nodes do you want to touch?
[07:57am] jredding: all
[07:57am] desbeers: chx: wow! All usability improvements from your path-patch in http://drupal.org/node/154517 are committed now!
[07:57am] Druplicon: http://drupal.org/node/154517 => path module usability and fixes => Drupal, path.module, critical, active, 17 IRC mentions
[07:57am] ben-agaric: INSERT INTO {
[07:57am] ben-agaric: (darn, ben-agaric has auto)
[07:57am] NikLP joined the chat room.
[07:57am] ben-agaric: -tabby thingies on his brackets
[07:58am] jredding: ben-agaric: maybe pastebin?
[07:58am] jredding: pastebin?
[07:58am] Druplicon: Please don't paste code directly into IRC. Use http://drupalbin.com or http://drupal.pastebin.com or http://pastebin.ca or http://pastebin.org or http://pastie.textmate.org instead.
[07:58am] jredding: and I see where you're going.. I completely forgot about doing something like that..
[07:58am] aljaber joined the chat room.
[07:59am] ben-agaric: actually it is more complicated than I thought, but SQL is definitely the way to go. Let me know what your query is
[07:59am] • ben-agaric not actually an SQL master at all
[07:59am] ben-agaric: not query, I mean, conditions on the nodes you want
[07:59am] buzztracker left the chat room. (Remote closed the connection)
[08:00am] buzztracker joined the chat room.
[08:00am] lyricnz left the chat room. ("Leaving")
[08:01am] ben-agaric: but you could put the for loop in PHP, it would be able to run 1,000s of simple SQL inserts no problem
[08:04am] catch__ left the chat room. (Read error: 110 (Connection timed out))
[08:04am] jredding: ya.. and I was thinking that if I did it in PHP it would defend against duplicate entries..
[08:04am] jredding: because taxonomy_node_save does all those wonderful things for you.
[08:05am] brenda003: you just want all nodes to have one term? that should be easy in sql...
[08:06am] jredding: brenda003: yes.. I just want to add a new term to all existing nodes.
[08:06am] brenda003: since nodes all have a unique id, there's no duplicating. just drop all the entries where the tid is set in that table
[08:06am] ben-agaric: jredding: And because the node is never loaded, you should be able to power through easily
[08:06am] brenda003: imagine your tid is 3
[08:06am] ben-agaric: Just "SELECT " all the nids I care about and then run them through taxonomy_node_save
[08:06am] • ben-agaric wants to see what brenda003 has
[08:07am] brenda003: it's much simpler.
[08:07am] brenda003: sec, lemme get into mysql.
[08:07am] • ben-agaric thought it was a one-line statement for a second, and then actually thought
[08:07am] jredding: ben-agaric: I was about to do what you just said.. just from the CLI b/c it'll time out.. there are thousands upon thousands of nodes..
[08:09am] Saied left the chat room. (Remote closed the connection)
[08:09am] ben-agaric: jredding: but at no point is node_load called if you do the first statement with straight SQL, so I don't think you'll have a problem. You can use a limit query to do X at a time. There are new cron hooks and stuff too... we should we writing a module for this
[08:10am] jredding: well the module is pretty straightforward.. just in my experience I've had timeouts when running via the web.. so..
[08:10am] jredding: but its a really dead simple query I'm doing.
[08:10am] • ben-agaric still wants to see brenda bust out some SQL-fu more though
[08:11am] jredding: ya I'm waiting too.. b/c even though I'm pretty positive it can be done. I can't think of it off the top of my head.
[08:11am] jredding: so I go with what I know
[08:11am] Saied joined the chat room.
[08:11am] chx: desbeers: good news. could you please turn your attention to the search patch? Nothing to code, just testing per Dries' request
[08:12am] WimLeers joined the chat room.
[08:13am] desbeers: chx: ok; after I update the path issue (wil take just another 10 minutes).
[08:13am] brenda003: it is a little tricker
[08:13am] brenda003: but gimma a sec...
[08:13am] jredding: I think this'll do it.. INSERT INTO term_node (nid, 6) SELECT nid from node
[08:13am] jredding: ok.. damnit.. now I'm going the SQL route..
[08:14am] jredding: b/c I'm a sucker for punishment..
[08:14am] brenda003: that's only pulling one row
[08:15am] morphir left the chat room. (Remote closed the connection)
[08:15am] Saied left the chat room. (Remote closed the connection)
[08:15am] Saied joined the chat room.
[08:16am] StevenTyler left the chat room.
[08:16am] • jredding creating test database to play on
[08:16am] chx: whao
[08:16am] chx: that's some scary scammer tactic
[08:17am] chx: my gmail and ebay user name are the same
[08:17am] chx: so they sent me one very authentic looking mail
[08:17am] chx: including the ebay user name
[08:17am] chx: about some stuff i bid on
[08:17am] • chx shakes head
[08:17am] DawnLight: sounds nasty
[08:17am] chx: but the mail has sender headers from .cz
[08:17am] chx: the item is in Canada
[08:18am] chx: that does not mesh
[08:18am] chx: and also
[08:18am] chx: if it'd be real, it'd be in my ebay messages folder
[08:18am] DawnLight: did you tell ebay?
[08:19am] chx: what can they do?
[08:19am] DawnLight: they are omnipotent
[08:19am] chx: haha
[08:19am] NikLP: presumably except when it comes to resolving paypal matters...
[08:19am] NikLP: when they are impotent...?
[08:22am] • ben-agaric waits for jredding's results
[08:22am] • ben-agaric prepares to bow to brenda003
[08:23am] amorfati joined the chat room.
[08:26am] • brenda003 pffts at ben-agaric
[08:26am] • jredding still waiting for the test database to finish so I can perform queries on it.
[08:26am] jredding: as an aside.. while I'm still doing the SQL query thing..
[08:27am] jredding: I've already fixed it.. I just ran it from the CLI.. Select nid from node.. taxonomy_node_save.. took about 3 or so minutes for the script to run.
[08:28am] • jredding test database done.. fun begins!
[08:28am] snufkin joined the chat room.
[08:28am] Daisy joined the chat room.
[08:29am] greggles left the chat room.
[08:30am] killes: http://www.freerice.com/
[08:30am] desbeers: chx: you mean http://drupal.org/node/146466 I suppose. An Dies' comment #96?
[08:30am] Druplicon: http://drupal.org/node/146466 => Remove temporary table usage from search module => Drupal, search.module, critical, patch (ready to be committed), 28 IRC mentions
[08:32am] aymerick joined the chat room.
[08:33am] • desbeers reading the issue
[08:35am] chx: yes he asked for comparing resultsets
[08:36am] ben-agaric: jredding: so how did you pick your site from the CLI?
[08:36am] tha_sun left the chat room. ("dreaming of drupal")
[08:36am] jredding: fake the server headers
[08:36am] jredding: i.e. $_SERVER['HTTP_HOST'] = $host;
[08:37am] ben-agaric: ha!

See also:
http://agaricdesign.com/note/agaric-wants-be-able-add-taxonomy-terms-en-masse-checking-off-nodes-list

Resolution

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.