Download & Extend

Allow node_load($nid)

Project:Drupal core
Component:node system
Category:feature request
Priority:normal
Assigned:chx
Status:closed (fixed)

Issue Summary

I am fed up writing node_load(array('nid' => $nid)) all the time.

BTW. if this is accepted, next is node_view to accept a $nid.

AttachmentSizeStatusTest resultOperations
node_load.patch2.23 KBIgnored: Check issue status.NoneNone

Comments

#1

AttachmentSizeStatusTest resultOperations
node_load_0.patch2.23 KBIgnored: Check issue status.NoneNone

#2

I am going to +1 this.

node_load(x) is much more natural to type. Having it use an array if found is useful too though.

#3

Dries, if I remember correctly, you favoured this approach.

AttachmentSizeStatusTest resultOperations
node_load_1.patch27.89 KBIgnored: Check issue status.NoneNone

#4

PHPdoc.

AttachmentSizeStatusTest resultOperations
node_load_2.patch27.97 KBIgnored: Check issue status.NoneNone

#5

+1
It's not only about lazy developers -which I am ;-)- it's also about shorter code => less errors, easier to catch

#6

The patch and its consequences makes me love the version at http://drupal.org/node/25634#comment-33584 more, but Dries will be the one to decide.

#7

A few things slipped in from another patch which should not be here.

AttachmentSizeStatusTest resultOperations
node_load_3.patch18.95 KBIgnored: Check issue status.NoneNone

#8

Same problem as above.

AttachmentSizeStatusTest resultOperations
node_load_4.patch15.31 KBIgnored: Check issue status.NoneNone

#9

I like this! Is there a similar issue for user_load()?

#10

I definitely prefer the version where we simply allow $conditions to be passed as an integer, rather than introducing additional parameters.

It matches PHP's convention of having "mixed" argument types for some functions for shorthands (e.g. str_replace allows array arguments to compact multiple replacements in one statement). And not unimportant: it does not break backwards compatibility for what it essentially syntactic sugar.

#11

Steven. Dries did not like that version hence the additional parameter.

Dries, now that even Steven is on my side, would you please reconsider :) ?

#12

I concurr about the mixed parameter.

#13

let me weigh in +1 on the mixed parameter side ... let's get away from blowing up backwards compatibility unless it's justified and/or unavoidable for the sake of progress. please :)

#14

AttachmentSizeStatusTest resultOperations
nodeload.patch15.46 KBIgnored: Check issue status.NoneNone

#15

poor book module remained unpatched.

AttachmentSizeStatusTest resultOperations
nodeload_0.patch18.98 KBIgnored: Check issue status.NoneNone

#16

wrong version.

AttachmentSizeStatusTest resultOperations
nodeload_1.patch18.15 KBIgnored: Check issue status.NoneNone

#17

I thought this had hit the trunk some days ago.. Chx, can you or Dries confirm and mark this issue as "Fixed"?

#18

Status:needs review» fixed

This has been committed. Marking it 'fixed'.

#19

#20

#21

#22

#23

#24

Status:fixed» closed (fixed)
nobody click here