Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make detect_extender_valuetype() return only valid types. (Trac #2878) #2878

Closed
elgg-gitbot opened this issue Feb 16, 2013 · 15 comments
Closed
Labels
Milestone

Comments

@elgg-gitbot
Copy link

Original ticket http://trac.elgg.org/ticket/2878 on 41110145-09-08 by trac user tomv, assigned to unknown.

Elgg version: 1.7

In some cases, some admin users, calling

get_user_notification_settings($guid)

generates a:

InstallationException

Type is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.

This happens on the notification settings for their personal notifications only (first block on ...pg/notifications/personal), but at times also when sending messages.

Inserting:

case '' :
  return ($this->attributes['value']);

after line 45 in engine/lib/extender.php solves the issue and it seems to work all again.
Running 1.7.7, problem on 3 different installs, localdev and testing servers, all Ubuntu.
Also see [http://community.elgg.org/pg/forum/topic/691093/]

@elgg-gitbot
Copy link
Author

cash wrote on 41110330-05-28

I was able to reproduce by going into my database and deleting the type on a metadata. You'll have to repair your database.

I think throwing the exception is probably the right thing to do as it lets you know there is a problem.

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 41110362-09-22

ok, went into PhpMyAdmin, then

SELECT * FROM `elggmetadata` WHERE value_type=''

Resulted in two records that did not have the value_type set, changed that value_type to 'text' and now it works.

Still no clue how it happened... we will watch this closely...

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 41110373-10-13

But only on one server. The test server returned zero records when we performed:

SELECT *
FROM `elggmetadata`
WHERE (
value_type != 'text'
AND value_type != 'integer'
)

So even though database seems correct, still same error :( ... to be continued

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 41110499-03-28

Now wondering: how is it possible that in ElggExtender get($name),

$this->attributes['value_type']==''

even though all metadata value_types are either text or integer?

Ok... if we dont have some revelation, we will fresh install test/dev sites ...but that means we never know cause of error ... :((

@elgg-gitbot
Copy link
Author

cash wrote on 41111266-06-27

Tom - when that happens write out the id of the metadata and then check the database.

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 41112467-12-07

Well... this is getting interesting. The current warning is now:

name=[value] attr_name=[mytestemailhotmail.com] value_type=[] id=[svn:49779] entity_guid=[svn:2] owner=[svn:2] Type is not supported. This indicates an error in your installation, most likely caused by an incomplete upgrade.

Metadate with id=49779 looks good, value_type =integer.

But this is getting interesting -and really weird- 'mytestemailhotmail.com' is an old email address used once for testing only! (I think with a now deleted user, but can not be 100% sure, could have been admin as well).

So, then tried to find it in ALL elggtables in phpmyadmin with LIKE %% and... strange !..it does NOT exist anymore in database!
Scanned all files in www folder again to be sure - and also no hit for 'mytestemail'.
And now I am running out of SQL knowledge... an old value still in database, but not showing up when searching??? Hmm... sounds like the database got corrupt at one stage or another. Executred repair command... no luck.

Need coffee now ... ;)

@elgg-gitbot
Copy link
Author

cash wrote on 41113044-06-12

It would be in the metastrings table if it is in there. Also "mytestmailhotmail.com" is a string and your database is saying that 49779 is an integer. My guess is that you are looking through a different database than the one this particular test site is using.

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 41115916-05-14

Shame-shame..., last call I executed indeed on wrong database. On active db it resulted in 6 records without value_type, which we set to 'text' and it works again.
So why did value_types get empty in first place? Maybe a malfunctioning invitation-plugin has something to do with it, as the metastrings with empty values were either email addresses or and invitation code...
Will post back if we know what went wrong...

@elgg-gitbot
Copy link
Author

trac user tomv wrote on 41123635-06-05

ok, I open this one, as we found the bug. After running a certain plugin once, the Elgg database is corrupted. The plugin contains a call:

create_metadata($user_guid, "invitation_code", $invitecode, "string", 0, ACCESS_PUBLIC, true);

Obviously, "string" is not a valid type.. but the function that should check it, detect_extender_valuetype, does not care and happily returns this db corrupting value. Until there is clever solution, we suggest, very simple:

00270 function detect_extender_valuetype($value, $value_type = "") {
00274 
00275     // This is crude
00276     if ($value_type='integer' || is_int($value)) {
00277         return 'integer';
00278     }
00283 
00284     return 'text';
00285 }

@elgg-gitbot
Copy link
Author

brettp wrote on 41124385-09-09

Thanks for taking the time to debug this! Confirmed that the above code will crash a site when trying to access metadata with an invalid type.

@elgg-gitbot
Copy link
Author

Milestone changed to Elgg 1.7.8 by brettp on 41124385-09-09

@elgg-gitbot
Copy link
Author

Title changed from InstallationExcpetion on calling get_user_notification_settings() to Make detect_extender_valuetype() return only valid types. by brettp on 41124385-09-09

@elgg-gitbot
Copy link
Author

ewinslow wrote on 41124506-02-08

Careful with the suggested fix -- need to change the "=" to a "==", otherwise you'll just always get stuck with 'integer'

@elgg-gitbot
Copy link
Author

cash wrote on 41204894-08-08

(In [svn:8727]) Fixes #2878 detect_extender_valuetype() makes sure passed value type is valid

@elgg-gitbot
Copy link
Author

cash wrote on 41253389-12-09

(In [svn:8913]) Refs #2878 fixes detect_extender_valuetype() in trunk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

1 participant