mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #15194
[Bug 1024271] Re: return value not strictly integer for ArtefactTypeFolder::get_folder_id
This is actually pretty standard behavior throughout Mahara. It comes
from our DB layer. When you're creating a new record, you go through the
insert_record() method, which returns the ID of the new record, and it
casts it to an INT. When you're fetching an existing record, you go
through the get_records_*() family of functions, and those return each
column as a string.
However, the string you get, will be a string that contains the ID
integer. Like, instead of getting (int) 15, you get (string) "15". And
normally it doesn't pose any problems PHP does automatic type juggling
to convert an integer string into a real integer when a real integer is
needed: http://php.net/manual/en/language.types.type-juggling.php
It's also worth noting there's no @return phpdoc tag in the
get_folder_id() comment header, and there doesn't appear to be anywhere
that we do claim that the return value will be a proper integer. Also,
this function returns mixed integer|boolean, because under some
conditions it will return boolean false.
Anyway, I'll update this to "Won't Fix".
** Changed in: mahara
Status: Triaged => Won't Fix
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1024271
Title:
return value not strictly integer for
ArtefactTypeFolder::get_folder_id
Status in Mahara ePortfolio:
Won't Fix
Bug description:
Extending Mahara and recursively calling
ArtefactTypeFolder::get_folder_id to create user folders, we've
noticed that the return value is not always strictly integer as
claimed.
When a record (folder) already exists, the returned id from the database is of type string.
Thus, recursively calling ArtefactTypeFolder::get_folder_id with the returned id *WILL* fail.
The error is in the last line, which reads "return $record->id;"
Using a mysql database (and possibly others), the return value IS numeric, but returned as a string.
The last line, imho, should therefore read "return (int)$record->id;"
Mahara version: 1.5.1
OS: Linux
Database: mysql
browser: not relevant (core code problem)
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1024271/+subscriptions
References