code logs -> 2015 -> Thu, 27 Aug 2015< code.20150826.log - code.20150828.log >
--- Log opened Thu Aug 27 00:00:08 2015
00:29 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code
00:29 mode/#code [+qo Vornicus Vornicus] by ChanServ
00:29 Vornotron [Vorn@ServerAdministrator.Nightstar.Net] has joined #code
00:30 Vornotron [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection closed]
00:34 catadroid [catalyst@Nightstar-bc1af3.dab.02.net] has quit [[NS] Quit: Bye]
00:45
<&McMartin>
"DESCRIPTION: *Never* *use* *this* *function*."
01:02 Derakon[AFK] is now known as Derakon
01:07
<~Vornicus>
Nice
01:09
<&McMartin>
That's for gets
01:09
<&McMartin>
OSX's manpage is a little more subtle about it
01:10
<&McMartin>
It is the caller's responsibility to ensure that the input line, if any, is sufficiently short to fit in the string.
01:10
<&McMartin>
I can just imagine Alan Rickman saying that drily with a raised eyebrow over a glass of expensive brandy.
01:27 McMartin [mcmartin@Nightstar-rpcdbf.sntcca.sbcglobal.net] has quit [[NS] Quit: reboot]
01:30
< [R]>
Linux Man page is about halfway.
01:30
< [R]>
Says that it can cause buffer overflows in the description (last sentence 2nd para), and directs you to the BUGS section where it explains that it's a security risk to use this function.
01:33
< [R]>
OpenBSD's man page is... odd. On one hand, it explains fully why not to use gets() (with code samples), but kind of sells gets() before it tells you not to use it.
01:35
<&ToxicFrog>
[R]: which linux? On SUSE it does in fact open with "Never use this function."
01:35
<&ToxicFrog>
RETURN VALUE
01:35
<&ToxicFrog>
gets() returns s on success, and NULL on error or when end of file occurs while no characters have been read. However, given the lack of buffer overrun checking, there can be no guarantees that this function will even return.
01:37
< [R]>
I'm reading Slack's 13.37 manual
01:37
< [R]>
COLOPHON
01:37
< [R]>
This page is part of release 3.32 of the Linux man-pages project. A
01:37
< [R]>
description of the project, and information about reporting bugs, can be
01:37
< [R]>
found at http://www.kernel.org/doc/man-pages/.
01:37
<&ToxicFrog>
This is SUSE TW, man pages release 4.02
01:37
< [R]>
2008-08-06
01:37
<&ToxicFrog>
Wow. Ancient.
01:37
< [R]>
Also my OpenBSD install is... not new.
01:37
<&ToxicFrog>
2015-03-02.
01:38
< [R]>
Yeah
01:38
<&ToxicFrog>
It also mentions that gets() was deprecated in LSB and POSIX'08, removed entirely in C11, and isn't exposed in the glibc header files anymore if building in C11 mode.
01:39
< [R]>
Yeah, I get similar notices (but not the C11 obv)
01:39
< [R]>
OpenBSD 4.8 June 2, 2009
01:41 McMartin [mcmartin@Nightstar-rpcdbf.sntcca.sbcglobal.net] has joined #code
01:41 mode/#code [+ao McMartin McMartin] by ChanServ
01:48
< Turaiel>
Anyone care to critique some PHP for me? :)
01:48
<&Derakon>
Not I. No PHP for me, thanks, I just ate dinner.
01:49
< Turaiel>
xD
01:54
< [R]>
I might
01:59
< Turaiel>
Alright, give me a sec
02:00
< Turaiel>
http://pastebin.com/U4jGwNWf
02:00
< Turaiel>
It feels messy, but I'm not really sure of any ways to make it better
02:03 * [R] begins rolling the newspaper up at "SELECT *"
02:04
< Turaiel>
Is there a problem with that?
02:05
< [R]>
Yes, if your schema ever changes you'll pulling stuff you don't need, which can be a network issue in the future.
02:06
< [R]>
The only member that's actually part of the class is __construct. All the other supposedly-member functions aren't actually so.
02:06
< [R]>
Or nm
02:06
< [R]>
The indentation confused me
02:08
< [R]>
$db = new DatabaseConnection(); // this can get called multiple times per instance.
02:09
< Turaiel>
Yes. That class just establishes a PDO connection to mysql with a provided configuration. It's set to keep the connection persistent by default.
02:09
< [R]>
That's an odd way to do it.
02:10
< Turaiel>
I'm just trying to abstract away the database connection code
02:10
< [R]>
Also you've repeated those same two lines 3 times. IMO you might want to have a utility function return the Connection object directly.
02:10
< Turaiel>
Yeah, I thought about that.
02:11
< [R]>
Maybe DI in a system engine, or a class that returns the required connection object?
02:11
< Turaiel>
Mind elaborating on that first part?
02:12
< [R]>
Dependancy Injection. Basically instead of having the class instantize an object, you make the class ask for an interface that does what it needs done, then feed it something that implements that interface at runtime.
02:12
< Turaiel>
I'm not familiar with that
02:13
< [R]>
Also, IIRC PDO modify an object directly, that'll save you a number of lines of code. (IE: don't so the FETCH_ASSOC in the constructor)
02:14
< [R]>
unset($db); <-- I'm assuming you're forcing a side-effect here.
02:14
< Turaiel>
It calls the destructor which will terminate the connection
02:14
< [R]>
Yeah, that's a side effect. Shouldn't be a required call.
02:15
< [R]>
$this->id = $con->query("SELECT LAST_INSERT_ID() FROM `images`;"); // IIRC this is a race condition.
02:15
< Turaiel>
MySQL returns it for the active session only
02:15
< Turaiel>
It will not be affected by inserts that occur in the mean time
02:15
< Turaiel>
("active session" is poor wording on my part)
02:15
< [R]>
A session that you're persisting.
02:16
< [R]>
$comicst = $con->prepare("DELETE FROM `comics` WHERE `image`=?"); $imgst = $con->prepare("DELETE FROM `images` WHERE `id`=?"); // Rely on Foriegn Keys instead, here?
02:16
< Turaiel>
Foreign keys aren't available
02:16
< Turaiel>
I wish they were
02:17
< Turaiel>
But the server admin forced MyISAM on me
02:17
< [R]>
You missed a call to unset($db); in delete.
02:17
< [R]>
D:
02:17
< Turaiel>
That's okay, I'll be getting rid of that :P
02:17
< [R]>
MySQL has UPSERTs
02:20
< Turaiel>
Oh, I see.
02:26
< [R]>
...
02:26
< [R]>
Wait.
02:27
< [R]>
What kind of "Administrator" forces MYISAM and blocks InnoDB.
02:27
< Turaiel>
The kind that is overoptimizing
02:27
< Turaiel>
Also the kind that doesn't believe in SQL caching improving performance :P
02:28
< Turaiel>
It's irritating, really
02:28
< [R]>
So basically a drunk idiot.
02:28
< Turaiel>
Also the kind that will go in and modify my code because it's "not fast enough"
02:33
< Turaiel>
I had a schema all set up with triggers and foreign keys. I sent it to the admin and she changed all the tables to MyISAM and blew away the foreign keys. The triggers didn't apply properly either.
02:36 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has joined #code
02:47 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has quit [Connection closed]
02:48 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has joined #code
03:00
< Turaiel>
[R], I modified the database code. Does this look okay? http://pastebin.com/ZnYYKPBB
03:01
< Turaiel>
The image class looks like this now: http://pastebin.com/Xvb0VaDE
03:19
< [R]>
You still FETCH_ASSOC, does the other mode not work on existing objects?
03:20
< [R]>
You're missing the Database::disconnect() call as I noted before still
03:22
< [R]>
I'm not seeing any validation on $id (constructor)
03:22
< [R]>
(I know PDO kind of protects you there)
03:22
< Turaiel>
The FETCH_CLASS mode can only instantiate a new object. Thanks for the reminder on the disconnect
03:23
< Turaiel>
Wait, there is a call to disconnect in delete.
03:24
< Turaiel>
Updated the paste
03:24
< [R]>
(The catch)
03:25
< Turaiel>
OH, right.
03:25
< [R]>
$stmt->execute(array($user, $artist, $category, $add_date, $publish_date, $transcript, $description, $title, $alt_text, $image_file, $thumb_file, $href)); // PHP dropped the $this-> requirement?
03:25
< Turaiel>
Good call.
03:26
< [R]>
Also did you look into upserts?
03:26
< Turaiel>
I did. I'm having trouble understanding the syntax
03:27
< Turaiel>
https://dev.mysql.com/doc/refman/5.1/en/insert-on-duplicate.html <-- I'm not sure what the extra bit after "UPDATE" is.
03:30
< [R]>
https://dev.mysql.com/doc/refman/5.1/en/replace.html
03:31
< [R]>
REPLACE is apparently wonky if you have FKs though
03:32
< Turaiel>
It looks like REPLACE deletes and inserts
03:32
< Turaiel>
I like the behavior of the other better. I just wound up using id=LAST_INSERT_ID(id) for the part after UPDATE
03:35 ion [Owner@Nightstar-h5r554.vs.shawcable.net] has quit [Ping timeout: 121 seconds]
03:48 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has quit [Connection closed]
03:49 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has joined #code
03:52
< Turaiel>
Well, I think that'll be all for the night. Thanks a lot for your suggestions!
03:59 Checkmate [Z@Nightstar-r9lk5l.cust.comxnet.dk] has quit [Ping timeout: 121 seconds]
04:22 macdjord|slep is now known as macdjord
04:40 ion [Owner@Nightstar-h5r554.vs.shawcable.net] has joined #code
04:55 Kindamoody[zZz] is now known as Kindamoody
04:55 Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Connection reset by peer]
05:11 Derakon is now known as Derakon[AFK]
05:14 Kindamoody [Kindamoody@Nightstar-0lgkcs.tbcn.telia.com] has quit [Connection closed]
05:14 Kindamoody|autojoin [Kindamoody@Nightstar-0lgkcs.tbcn.telia.com] has joined #code
05:14 mode/#code [+o Kindamoody|autojoin] by ChanServ
05:15 Kindamoody|autojoin is now known as Kindamoody
07:02 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has quit [Connection closed]
07:03 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has joined #code
07:16 celticminstrel [celticminst@Nightstar-0eqglv.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
07:57 Kindamoody is now known as Kindamoody|afk
09:25 abudhabi [abudhabi@Nightstar-7nkq9k.de] has quit [Connection closed]
09:27 abudhabi [abudhabi@Nightstar-7nkq9k.de] has joined #code
09:49 GreenGuy [GreenGuy@Nightstar-fik25i.gnomino.eu] has joined #code
10:45 Checkmate [Z@Nightstar-r9lk5l.cust.comxnet.dk] has joined #code
10:45 mode/#code [+o Checkmate] by ChanServ
10:54 kourbou_ [kourbou@Nightstar-deqg8j.fbx.proxad.net] has joined #code
10:54 kourbou_ is now known as kourbou
11:54 catadroid [catalyst@Nightstar-kc6e78.dab.02.net] has joined #code
13:58 kourbou is now known as kourbou|foodz
14:10 macdjord is now known as macdjord|wurk
14:19 lexforceterror [lexforceter@Nightstar-usg.cjt.95.2.IP] has joined #code
14:23 kourbou|foodz is now known as kourbou
14:43 Meatyhandbag [sebastianfe@Nightstar-86t.ukq.53.184.IP] has quit [Client exited]
15:31 Netsplit *.net <-> *.split quits: kourbou, catadroid, @Tamber, @macdjord|wurk, grindhold, @himi, Xires, tripflag, @jerith, @Derakon[AFK]
15:32 Netsplit over, joins: @Tamber, &jerith, &Derakon[AFK], @macdjord|wurk, catadroid, @himi, kourbou, Xires, grindhold, tripflag
16:00 GreenGuy [GreenGuy@Nightstar-fik25i.gnomino.eu] has quit [Connection closed]
16:07 Meatyhandbag [sebastianfe@Nightstar-1ur.kfe.84.149.IP] has joined #code
16:12 Meatyhandbag [sebastianfe@Nightstar-1ur.kfe.84.149.IP] has quit [Ping timeout: 121 seconds]
16:12 Meatyhandbag [sebastianfe@Nightstar-0da2jd.res.rr.com] has joined #code
16:13 catadroid` [catalyst@Nightstar-kn3hvn.dab.02.net] has joined #code
16:13 catadroid` [catalyst@Nightstar-kn3hvn.dab.02.net] has quit [[NS] Quit: Bye]
16:16 catadroid [catalyst@Nightstar-kc6e78.dab.02.net] has quit [Ping timeout: 121 seconds]
16:20 kourbou_ [kourbou@Nightstar-deqg8j.fbx.proxad.net] has joined #code
16:20 kourbou [kourbou@Nightstar-deqg8j.fbx.proxad.net] has quit [NickServ (RECOVER command used by kourbou_)]
16:20 kourbou_ is now known as kourbou
16:27 Meatyhandbag [sebastianfe@Nightstar-0da2jd.res.rr.com] has quit [Client exited]
16:44 Checkmate [Z@Nightstar-r9lk5l.cust.comxnet.dk] has quit [Ping timeout: 121 seconds]
16:47 catadroid [catalyst@Nightstar-mvu07s.dab.02.net] has joined #code
16:52 Netsplit *.net <-> *.split quits: kourbou, @Tamber, @macdjord|wurk, grindhold, @himi, Xires, @jerith, tripflag, @Derakon[AFK]
16:53 Netsplit over, joins: @Tamber, &jerith, &Derakon[AFK], @macdjord|wurk, @himi, Xires, grindhold, tripflag, kourbou
17:01 gizmore [kvirc@Nightstar-grreaf.dip0.t-ipconnect.de] has joined #code
17:07 Checkmate [Z@Nightstar-ev6.6um.94.83.IP] has joined #code
17:07 mode/#code [+o Checkmate] by ChanServ
17:36 himi [fow035@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds]
17:45 himi [fow035@Nightstar-v37cpe.internode.on.net] has joined #code
17:46 mode/#code [+o himi] by ChanServ
18:03 GreenGuy [GreenGuy@Nightstar-fik25i.gnomino.eu] has joined #code
18:14 celticminstrel [celticminst@Nightstar-0eqglv.dsl.bell.ca] has joined #code
18:14 mode/#code [+o celticminstrel] by ChanServ
18:33 kourbou [kourbou@Nightstar-deqg8j.fbx.proxad.net] has quit [[NS] Quit: Iām not a psychopath. Iām a high-functioning sociopath. Do your research.]
19:00 Netsplit *.net <-> *.split quits: tripflag, @Tamber, @macdjord|wurk, grindhold, Xires, @jerith, @Derakon[AFK]
19:01 GreenGuy [GreenGuy@Nightstar-fik25i.gnomino.eu] has quit [Connection closed]
19:01 Netsplit over, joins: @Tamber, &jerith, &Derakon[AFK], @macdjord|wurk, Xires, grindhold, tripflag
19:15 Meatyhandbag [sebastianfe@Nightstar-d7h.cgd.224.136.IP] has joined #code
19:47 Meatyhandbag [sebastianfe@Nightstar-d7h.cgd.224.136.IP] has quit [Client exited]
19:52 Meatyhandbag [sebastianfe@Nightstar-d7h.cgd.224.136.IP] has joined #code
19:53 Meatyhandbag [sebastianfe@Nightstar-d7h.cgd.224.136.IP] has quit [Client exited]
20:37 gizmore|2 [kvirc@Nightstar-grreaf.dip0.t-ipconnect.de] has joined #code
20:39 catadroid [catalyst@Nightstar-mvu07s.dab.02.net] has quit [[NS] Quit: Bye]
20:39 [R] [rstamer@genoce.org] has quit [Operation timed out]
20:39 catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has joined #code
20:40 gizmore [kvirc@Nightstar-grreaf.dip0.t-ipconnect.de] has quit [Ping timeout: 121 seconds]
21:06 Xires is now known as ^Xires
21:14 ^Xires is now known as Xires
21:19 Checkmate [Z@Nightstar-ev6.6um.94.83.IP] has quit [Ping timeout: 121 seconds]
21:28 Kindamoody|afk is now known as Kindamoody
21:29 Checkmate [Z@Nightstar-r9lk5l.cust.comxnet.dk] has joined #code
21:29 mode/#code [+o Checkmate] by ChanServ
22:10 gizmore|2 [kvirc@Nightstar-grreaf.dip0.t-ipconnect.de] has quit [[NS] Quit: KVIrc 4.3.1 Aria http://www.kvirc.net/]
22:15 Kindamoody is now known as Kindamoody[zZz]
22:46 Turaiel is now known as TurCycle
22:54 Alek [Alek@Nightstar-03ja8q.il.comcast.net] has quit [[NS] Quit: brb]
22:58 Alek [Alek@Nightstar-03ja8q.il.comcast.net] has joined #code
22:58 mode/#code [+o Alek] by ChanServ
--- Log closed Fri Aug 28 00:00:24 2015
code logs -> 2015 -> Thu, 27 Aug 2015< code.20150826.log - code.20150828.log >

[ Latest log file ]