Extension talk:Favorites


Purpose

I'm a little confused about what this extension is trying to achieve. Is its purpose just to create an embeddable watchlist? —Emufarmers(T|C) 01:31, 26 July 2011 (UTC)

Not at all - this extension is meant to be completely separate from the watchlist and is designed to allow the end-user to be able to create a list of documents that they will access frequently. According to some, this functionality is unnecessary because it is included in your browser. However, in my environment, we have users who access our intranet through a virtual Citrix browser. In this case, the browser favorites are not persistent between sessions. Therefore, we had to come up with a different solution to allow these users to "bookmark" documents that they feel are important to them.
The watchlist serves its own purpose of notifying you of changes, but we didn't want to base the user's favorites on this list - we specifically wanted two separate lists. This is mostly because the admins didn't want a long list of favorites because of the various documents they are watching. Jlemley 14:20, 26 July 2011 (UTC)

Monobook?

Finally! I waited quite a while for such an extension. Unfortunatly it only seems to work in Vector? What about Monobook? --Subfader 22:36, 29 July 2011 (UTC)

Hi Subfader! It was you and the others on the various forums that made me want to release this to the community, and I hope you find it as useful as we do.
I did code this specifically for Vector, so I had never tested with another skin. I modified it in trunk and in the snapshots to function with other skins, so it should work for you now. Let me know if you have any problems or suggestions.
Thanks! Jlemley 05:11, 31 July 2011 (UTC)
Oh cool that my nagging created a public demand :D Nice of you to share it!
I tested it and it works for Monobook on 1.17.0 and 1.16alpha. For 1.16a I had to create the table maunally.
This is super dope. I'll stay tuned for suggestions and reports ;) Subfader 14:40, 31 July 2011 (UTC)

tab IDs

One minor thing: The tab has the unspecific li id="newtab". Just like the watch tab it should be id="favorite" and id="unfavorite". In Favorites_body.php / function favoritesTabs() I changed it to $content_actions[$mode]. --Subfader 14:41, 31 July 2011 (UTC)

Nice catch - I'll update the releases today. Thanks! Jlemley 17:35, 31 July 2011 (UTC)

Performance in 1.16a

In case anyone else runs into this issue, the solution was to change the column type on fl_title in the favoritelist table to match the page_title column in the page table. This should only be a problem on databases that started out on an older version of MediaWiki - before page_title changed to varbinary(255).

MW 1.16a: Special:Favoritelist and <favorites/> kill teh server performance (loading takes 2 minutes at 100% CPU usage for MySQL). The problem seems to be that addFeedLink() was not available in 1.16a yet. --Subfader 15:11, 31 July 2011 (UTC)

Sorry about that, but I'm not sure I want to go back and fix it for an older version. If you find a solution, though, I'll be happy to implement it. Jlemley 17:32, 31 July 2011 (UTC)
I understand that. After some further testing on my 1.17 version (which uses a db dump of my 1.16 installation) it's now slow too. Special:Favoritelist and <favorites/> became super slow after adding 25 articles to my favorites. If you can't reproduce the slowness it might be the large ammount of pages on my wiki? Subfader 23:54, 31 July 2011 (UTC)
Very strange. We have about 1000 articles on our production wiki, and I added over 40 items to my favorites list without any performance hit at all. We are running MW 1.16.5 with PHP 5.3.6 and MySQL 5.5. We're also running on a dual-core Windows XP box using Abyss webserver. We are NOT using any sort of caching at this time (no memcached or other).
Can you email me a dump of your Special:Version page so I can better understand your environment? Jlemley 16:46, 1 August 2011 (UTC)
Will check this again on a blank MW 1.16.5 and wait if others may report the same. Subfader 07:05, 4 August 2011 (UTC)
Sounds good, though I am curious about caching. We haven't felt the need to enable it on our installation, yet, but I wonder if that could be part of the problem - assuming, of course, that you are using some sort of caching method. Jlemley 14:15, 4 August 2011 (UTC)
Yes, I use
$wgMainCacheType = CACHE_ACCEL;
$wgParserCacheType = CACHE_ACCEL;
$wgUseFileCache = true;
But the problem remains with having these and all other extensions disabled on 1.17.0 (not tested in 1.16a, but should be the same). Subfader 14:26, 4 August 2011 (UTC)
In case anyone else runs into this issue, the solution was to change the column type on fl_title in the favoritelist table to match the page_title column in the page table. This should only be a problem on databases that started out on an older version of MediaWiki - before page_title changed to varbinary(255). Jlemley 23:39, 5 August 2011 (UTC)

Redirect bug

After moving a page in your favorites, you got both in your favorites: the new page title and the old page (redirect). The redirect shouldn't be there. Subfader 17:30, 1 August 2011 (UTC)

I forgot about that one - thanks for pointing it out. While debugging, I also noticed that deleted pages stay on the list. I could debate whether this should be the right behavior or not, but I went ahead and set it to remove deleted pages from the favorites list, as well. Update is available in trunk (FavoritedItem.php and Favorites.php). I'll update the snapshots when you let me know that this is working as desired. Jlemley 03:24, 3 August 2011 (UTC)
Thanks, works fine :) Subfader 18:20, 3 August 2011 (UTC)
Updated. I also made a number of other bug fixes (mostly formatting) and added an edit link option for the tag. Let me know if you run into any further issues.
Thanks again for your help! Jlemley 01:15, 4 August 2011 (UTC)

My favorites public

<favorites/> atm only returns the favorites the favorites of the user who si watching at the output. That's limits the use of the tag to help or project pages only. But what if a user wants to display his favorites to everyone on his user page (or a subpage of it)?

I understand that I shouldn't be able to retrieve the favorites of other users if they did not post them theirselves.

Would it be possible that <favorites user="Foo" /> (or any other parameter) displays the favorites of user Foo if the BASEPAGENAME is Foo? Subfader 22:15, 5 August 2011 (UTC)

I think I got it - check FavParser.php and Favorites.php in trunk. It wouldn't hurt to grab SpecialFavoritelist.php, too, as I cleaned up that code a bit.
The new parameter for the <favorites /> tag is "userpage=true". It will only work on a userpage, and it will display the favorites for the user to whom the page belongs. Of course, this means that in an open wiki you could add this to anyone's user page to see their favorites, but I'm sure there are ways to prevent editing other users' pages, if so desired.
Let me know if this works for you. Jlemley 02:34, 6 August 2011 (UTC)
Yep, works as desired. On user page it's the userpage's favs, on other NS it's the watching user's favs. Awesome! Subfader 09:32, 6 August 2011 (UTC)

Thanks for making this

Hey, I've wondered about something like this, and I finally found it. Thank you! Badon 00:20, 9 August 2011 (UTC)

favorites.css

For performance reasons it is better to add the content of favorites.css to your MediaWiki:Common.css instead of embedding the css file.

Actually it's nothing special in favorites.css so I think it can be removed completely anyway(?)  :) Subfader 10:46, 10 August 2011 (UTC)

Good point - the CSS is technically only needed if you are using the icon. Otherwise, it's unnecessary. I should be able to modify it to load only if the user elects to display the icon.
Thanks! Jlemley 15:08, 10 August 2011 (UTC)
Well, it's not an elegant solution, but the css will now only load if the icon is going to be used. I couldn't get ResourceLoader to work on my 1.17 test box, so this will have to do for now.
Thanks for the suggestion! Jlemley 01:57, 12 August 2011 (UTC)

Instead of manually putting the favorites link on the sidebar, where site-wide stuff is expected to be, it would be better if it were at the top of mediawiki, where all the user-specific links are. Can that be done? Badon 03:04, 18 August 2011 (UTC)

It's not currently possible, but I'll look at adding it. Jlemley 04:38, 18 August 2011 (UTC)
I hardcoded that in next to the "watchlist"-link. The problem with available hooks is that it adds new links behind the array of the existing links (to the very right next to "log out"). Subfader 14:20, 18 August 2011 (UTC)
A parameter was added to the Favorites.php file loaded in trunk.
Favorites.php
To display the "My Favorites" link in your personal urls area, add this to your localsettings.php:
$wgFavoritesPersonalURL=true;
If this works for you, let me know and I'll add it to the releases and document the new parameter on the Extension page. Jlemley 05:20, 19 August 2011 (UTC)
This did not work for me. If you hop onto #mediawiki on Freenode, I can give you login credentials so you can see it in action. Badon 05:44, 19 August 2011 (UTC)
Confirmed. Doesn't work on 2 tested 1.16.5 wikis. Subfader 11:27, 19 August 2011 (UTC)
Sorry, guys - I just tried it on a fresh install of 1.16.5 and got the personal "My
Favorites" link to appear with no problem.
By the way, if you try a snapshot of trunk, the only difference between the 1.16 version and the trunk version is the css file - 1.17 requires a few changes to the css. Again, this is only if you are using the icon, and you are using Vector.
Also, make sure you put the $wgUseIconFavorite=true; line above require_once in LocalSettings.php, not below. Jlemley 23:42, 19 August 2011 (UTC)
Ah, Monobook and no icon here. Subfader 19:34, 20 August 2011 (UTC)
I tested this, and it only works when $wgUseIconFavorite=true; is ABOVE. That was the only thing that was wrong.
But, now that I've gotten it to work, I decided I don't like it because it's confusing. It's hijacking another UI function (the watchlist star tab star icon thing), repurposing it, and still just showing a non-descript icon. So, I've put $wgUseIconFavorite=true; UNDER so I can get the "Favorite" and "Unfavorite" text tab, which is clear what it is, and really easy to use.
It's a bug, but I think it ought to be a feature! Badon 03:57, 21 August 2011 (UTC)
Oh, and I got the "My Favorites" link working. Very easy to find, clear exactly what it is. Badon 03:58, 21 August 2011 (UTC)
I updated the documentation so it's easier to understand how to use this extension to get it to do what you want. Thanks very much for this! I do recommend that the tab text "Favorite" and "Unfavorite" bug/feature become standardized as the default behavior, since there's no possibility of confusing it for the watchlist, and it's very clear exactly what it is. Plus, it can be easily translated (how do you translate a non-descript icon?). Badon 04:19, 21 August 2011 (UTC)
Thanks, but I would prefer to add this as a feature with a proper configuration option rather than document a bug as such. I removed the references to it from the documentation. I'll add them back once I have a properly functioning (and correctly named) configuration option added to the code. Jlemley 03:53, 22 August 2011 (UTC)

Special page can't be edited, needs instructions

The special page can't be edited, and I think it should contain instructions for a user on how they can use the favorite tag to display their favorites. What do you think? Badon 03:05, 18 August 2011 (UTC)

The tag was meant to be implemented by a site administrator, but with the new userpage option, it could just as easily be implemented by a user. However, I was going to leave it up to the site admin to document this as they please to let their users know how to use the tag.
On the other hand, if you would like to change the blurb on the "Edit" portion of the Special:Favoritelist page, that can be accomplished by editing MediaWiki:Favoritelistedit-normal-explain. The raw page is MediaWiki:favoritelistedit-raw-explain.
Unfortunately, there is no text on the "View" portion of the special page. However, you could edit the title using MediaWiki:Favoritelist. Note that whatever you put in there, however, will also affect the title of the Special:Favoritelist page, as well. I would suggest perhaps a link to a page where the user can find instructions, rather than placing the instructions on the special page itself.
I hope this helps! Jlemley 04:37, 18 August 2011 (UTC)

Uninstall instructions?

Since this modifies the database, how does one uninstall it? Don't worry, I love it, I'm not going to uninstall it. I just think that the information should be here, just in case somebody needs it. Badon 03:28, 18 August 2011 (UTC)

Good question. It's as simple as removing the favoritelist table from the database. Jlemley 04:04, 18 August 2011 (UTC)
I'm clueless about how to do that. I'm guessing you could make an SQL file that can do it? Badon 04:30, 18 August 2011 (UTC)
If you have access to your database using a tool like PHPMyAdmin, you can just delete the table. For commandline access or to use a script, you would use this command:
drop table favoritelist; Jlemley 04:43, 18 August 2011 (UTC)

Star icon didn't work for me

I'm using MW 1.17, and I set $wgUseIconFavorite = true; I got a text labeled tab, but no star icon. The watch functions, and other functions, are all in a dropdown. Is this standard, or do I have something odd about my installation? Maybe something has changed in 1.17 that the Favorites extension isn't compatible with? Badon 05:50, 18 August 2011 (UTC)

I have it running on a 1.17 installation with the icon. I'll have to try it on a fresh install to see what's going on. By the way, are you using Vector for your skin? Jlemley 13:42, 18 August 2011 (UTC)
Yes, the default Vector skin. The only thing I don't know is if something has been changed by someone else, and where to look for the change. I haven't changed it. Badon 15:56, 18 August 2011 (UTC)
Please try the Favorites.php loaded in trunk.
Favorites.php
As long as you have the favorites.css file in the Favorites folder, it should work. Jlemley 05:16, 19 August 2011 (UTC)
This did not work for me. If you hop onto #mediawiki on Freenode, I can give you login credentials so you can see it in action. Badon 05:44, 19 August 2011 (UTC)
Basically what's happening here is that the css file is not being found. The extension is looking for "favorites.css" in the "Favorites" folder. If it's not in that exact location (case sensitive if on a *nix os), then it will not be loaded. If you need to change where it looks for the css, you can edit the Favorites.php file to change the path. It's on line 136.
If this doesn't help, you can email me directly from my mediawiki.org userpage. Jlemley 23:46, 19 August 2011 (UTC)
By the way, please make sure you are putting the configuration parameter ($wgUseIconFavorite=true;) above the require_once line in the LocalSettings.php file, and not below. I just tested putting it below, and got the same results (a tab with text, but no icon). Jlemley 02:10, 20 August 2011 (UTC)

Option to tag favorites

Dunno how far your ambitions with the extensions go, but this might be a cool addition: tag your favorites (on action=favorite and or editable on Special:Favoritelist). An option would be to tag them only with existing category names (like the HotCat gadget on Commons) or to allow own tag names.

This would offer new parameters for the tag and could split the output of Special:Favoritelist. Subfader 00:59, 23 August 2011 (UTC)

I'm guessing you would want that so you could more easily sort your favorites list? That would make sense, especially if you're a power user with thousands of them.
Another thought I had was doing this natively within Semantic MediaWiki. It might be easy to do, with all the features you can imagine. I haven't tried it out yet, because I'm spoiled with this extension, but maybe I'll give it a look. It might be possible to provide some wiki code that basically functions as a plugin "script" for getting an SMW favorites system. If so, and I come up with it, I'll share it. Badon 06:23, 24 August 2011 (UTC)
I had something similar in mind: an integration with Intersection and or DPL. Subfader 13:30, 25 August 2011 (UTC)
How would it work with intersection and DPL? Badon 18:09, 25 August 2011 (UTC)
Sorry, guys - I can't quite visualize what you're looking for on this one, and I'm not sure how I would integrate something like this into the extension. Perhaps you could send me a private email on it with a little more detail on how you feel this would work. It sounds like it would end up being a pretty big update, including a patch to the database table. Jlemley 14:39, 7 October 2011 (UTC)
The tag option isn't important for me anymore.
Integration in Intersection and or DPL would be tho. E.g.
{{#dpl:
|namespace=File
|category:Foo
|infavorites=1
}}
would output a list of files in Category:Foo which are in my favorites. Subfader 02:47, 9 October 2011 (UTC)

Split the tag output into namespaces

Would it be possible to split the tag output on a user page into namespaces as on Special:Favoritelist? I quite don't know which class to copy. Subfader 19:43, 6 October 2011 (UTC)

It would take a bit of hacking, but the code you're looking for is in FavoritelistEditor.php in the buildRemoveList function. Specifically, I think it's these three lines:
$heading = htmlspecialchars( $this->getNamespaceHeading( $namespace ) );
$anchor = "editfavoritelist-ns" . $namespace;
$list .= $skin->makeHeadLine( 2, ">", $anchor, $heading, "" );
It may be as simple as putting those three lines into the buildRemoveList function in FavParser.php. However, this will cause it to display the namespace headings for every favorites list, not just the ones on the user page. If you only want it to work for user pages, you would probably want to break it out into a separate function or set some sort of variable at the class-level, and then you can add the extra layers you are looking for. It's all totally possible, it would just take a little effort to make it work. Let me know if you get stuck and I'll try to take a look when I get some time. Jlemley 14:35, 7 October 2011 (UTC)
Thanks that worked. I copied buildRemoveList() partly and getNamespaceHeading() above it. Subfader 15:16, 8 October 2011 (UTC)

UNIQ...QINU parser problem

In FavParser.php I try to return different output for certain namespace. For one namespace I have to pass the title to a template:

$list .= wfMsgExt( 'templateName', array( 'parseinline' ), $title );

The problem is that the same parser is used twice then. Solutions are offered here: QINU fix. But I don't know hot to apply it to FavParser.php. It seems to be the solution using

function exampleExtension( $input, $argv, &$parser ) {
	# do some stuff

	$output = $parser->parse(
		$stuff_to_parse, $parser->mTitle,
		$parser->mOptions, true, false
	);
	return $output->getText();
}

Could you have a look please? Subfader 15:25, 5 November 2011 (UTC)

Interesting. I'm not familiar with the QINU issues. The Favorites code calls FavParser from SpecialFavoritelist. $wgOut is used several times in that code. It will take a bit of time and research to figure out how to clean this up. Jlemley 00:03, 12 December 2011 (UTC)
Ok, this is an extremely roundabout and horrible way to do this, but here's something to try:
$localparser = new Parser();
$parseroptions = new ParserOptions();
$list .= $localparser->parse(
   wfMessage( 'templateName', $title->getEscapedText() )->text(),
   $title,$parseroptions)->mText;
If you don't want the full namespace and title in there, then change $title->getEscapedText() to $title->getText()
I just could not find a better method without either incurring the wrath of the QINU monster, or completely ignoring any markup that is in the message. By the way, if you don't care about wiki markup (like bold), then just do this:
$list .= wfMessage( 'templateName', $title->getEscapedText())->text();
It's not a real fix, but I hope this helps with what you are trying to accomplish. Jlemley 04:03, 12 December 2011 (UTC)
Thanks, wfMessage seems to be 1.17+ or 1.18+. With wfMsgExt in 1.16 I get "Fatal error: Call to a member function text() on a non-object". Seems to work in 1.18, at least the QINU error is indeed gone. Thanks again! Subfader 16:59, 12 December 2011 (UTC)
Yeah, sorry, I forgot to mention I was working in 1.17 at the time. I did not test anything in 1.16. 65.41.147.195 17:36, 12 December 2011 (UTC) 17:34, 12 December 2011 (UTC)

Ajax (un)favorite action without page reload like (un)watch

Would it be possible to (un)favroite pages like the watch feature? It uses inline ajax and doesn't require a landing page so the user stays on the page. Subfader 13:38, 11 December 2011 (UTC)

Favorites code is based on the watchlist code. I actually removed all the ajax stuff at one point because it was not working in 1.16. I'll have to see if I can hack the latest watchlist code and make some updates, but it's likely that the fancy stuff will only work in 1.17+. Jlemley 00:09, 12 December 2011 (UTC)
I also want this feature, it is very cool! How about lots of 1.17+ MW siteholders? Luft-on (talk) 19:33, 7 October 2012 (UTC)

Keep adding date on page move

I added a table column "fl_added" to store the timestamp when the user added a page to his favorites (lets me sort favorites by adding date, quite useful). Unfortunatly, on page move the date is renewed too and it looks like the page was added to favorites recently while it was just renamed.

I found moveToFav() and it looks like the entry is deleted and replaced by a new one. How could I keep the row (and with it the original "fl_added" and only replace the old title with the new title? Subfader (talk) 11:27, 19 February 2012 (UTC)

MediaWiki 1.18+

I tried installing in 1.18 but clicking the My Favorites link caused a php server error.

This is caused by the use of 'Xml::hidden' (no longer supported in MediaWiki from 1.18). I just replaced all occurrences of Xml::hidden in the files, to 'Html::hidden' and it's now working fine.

Might be useful for others using MediaWiki 1.18+ James uk (talk) 22:52, 13 June 2012 (UTC)

Thank you ... I had an error but I did as you had said and it works fine! But the star icon and the link in the menu are not displayed! Fokebox (talk) 16:51, 14 June 2012 (UTC)

$wgUseIconFavorite and $wgFavoritesPersonalURL don't work!

1) $wgUseIconFavorite = true; and $wgFavoritesPersonalURL = true; dont't work at my wiki! I use Mediawiki 1.18.3 2) Shall I launch update.php after installation, if I have updated mysql manually? What do I have to do? Fokebox (talk) 16:48, 14 June 2012 (UTC)

Well it does work =) I had worng order in php ) But it is displayed not like on the screen shot of the example page
Add caption here
I have marked a red line what looks wrong
There is also a strange line in the bottom of my favorite page
Add caption here
And I had to chage SpecialFavoritelist.php ('Xml::hidden' to 'Html::hidden'), 'caouse there was a php error. Fokebox (talk) 20:06, 14 June 2012 (UTC)
Well it does work =) I had worng order in php ) But it is displayed not like on the screen shot of the example page
Add caption here
I have marked a red line what looks wrong
There is also a strange line in the bottom of my favorite page
Add caption here
And I had to chage SpecialFavoritelist.php ('Xml::hidden' to 'Html::hidden'), 'caouse there was a php error. Fokebox (talk) 20:06, 14 June 2012 (UTC)

View and edit favorites option don't work

Hello I use mediawiki 1.18.3. and | View and edit favorites option don't work. I check some titles and press "remove titles" then I have a page where " title was removed from your favorites", but the title is still there! How to remove this bug? I had to also edit some php files I had to change 'Xml::hidden' to 'Html::hidden' becouse of php error. Please help me 213.87.128.81 08:09, 17 June 2012 (UTC)

dont show star if not loggedin

hi,im love this extension,but,a little question,it's show in not loggedin user,so i make a little change:

edit the FavoritesHooks.php:

	public static function onSkinTemplateNavigation( $skin, &$links ) {
		global $wgUseIconFavorite, $wgRequest, $wgUser;

		$action = $wgRequest->getText( 'action' );
		$title =  $skin->getTitle();
	
		if ( $title->getNamespace() >= NS_MAIN  && $wgUser->isLoggedIn() ) { //if not loggedin then dont show icon
			if ( $wgUseIconFavorite ) {
					$class = 'icon ';
					$place = 'views';
				} else {
					$class = '';
					$place = 'actions';
				}

				$fl = FavoritedItem::fromUserTitle( $wgUser, $title );

				$mode = $fl->isFavorited() ? 'unfavorite' : 'favorite';
				$links[$place][$mode] = array(
					'class' => $class . ( ( $action == 'favorite' || $action == 'unfavorite' ) ? ' selected' : false ),
					'text' => wfMsg( $mode ), // uses 'favorite' or 'unfavorite' message
					'href' => $title->getLocalUrl( 'action=' . $mode )
				);
		}
		return true;
	}

Theslboat (talk) 08:48, 5 September 2012 (UTC)

"Favorites" Snapshot missing?

When I try to download the Favorites snapshot it comes up empty. It's not in the mediawiki.org list. Help? 128.158.1.169 16:09, 11 September 2012 (UTC)

Can't edit my Favoritelist

On page /Special:Favoritelist&action=edit where I have one record favorited I mark it and press delete, it says that one record was deleted and one record still in my favorited list, it actually do not delete pages from list in such way. I think it is all because of CopyPaste from Watchlist. Can you fix it? Luft-on (talk) 19:42, 7 October 2012 (UTC)

Did you ever find a solution to this? We are having the same issue and we really need to be able to edit the watchlist. 98.195.63.176 16:43, 28 June 2013 (UTC)

API favoriting

Just wanted to thank you :) 217.247.165.60 (talk) 12:59, 18 August 2015 (UTC)

Bugfix

(really hating this discussion system) Setting $wgFavoritesPersonalURL = true; messes up the keys of the other links, so I copied some code from Extension:AdminLinks to fix that. Find:

		if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
			$url['userpage'] = array_shift( $personal_urls );
			$url[] = array_shift( $personal_urls );
			$url[] = array_shift( $personal_urls );
	
			$url[] = array( 'text' => wfMessage( 'myfavoritelist' )->text(),
					'href' => SpecialPage::getTitleFor( 'Favoritelist' )->getLocalURL() );
			$personal_urls = $url + $personal_urls;
		}

Replace with:

    //taken from AdminLinks_body.php of the AdminLinks-Extension
		if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
			$al = SpecialPage::getTitleFor( 'Favoritelist' );
			$href = $al->getLocalURL();
			$favorites_vals = array(
				'text' => wfMessage( 'myfavoritelist' )->text(),
				'href' => $href,
				'active' => ( $href == $wgTitle->getLocalURL() )
			);

			// find the location of the 'my preferences' link, and
			// add the link to 'AdminLinks' right before it.
			// this is a "key-safe" splice - it preserves both the
			// keys and the values of the array, by editing them
			// separately and then rebuilding the array.
			// based on the example at http://us2.php.net/manual/en/function.array-splice.php#31234
			$tab_keys = array_keys( $personal_urls );
			$tab_values = array_values( $personal_urls );
			$watch_location = array_search( 'watchlist', $tab_keys );
			array_splice( $tab_keys, $watch_location, 0, 'Favoritelist' );
			array_splice( $tab_values, $watch_location, 0, array( $favorites_vals ) );

			$personal_urls = array();
			for ( $i = 0; $i < count( $tab_keys ); $i++ ) {
				$personal_urls[$tab_keys[$i]] = $tab_values[$i];
			}
		}

Baumgeist (talk) 09:41, 5 October 2015 (UTC)

I did something similar. To add the Favorites link after the Watchlist link, all you need to do is edit FavoritesHooks.php from
public static function onPersonalUrls( &$personal_urls, &$title ) {
	global $wgFavoritesPersonalURL, $wgUser;
	if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
		$url['userpage'] = array_shift( $personal_urls );
		$url[] = array_shift( $personal_urls );
		$url[] = array_shift( $personal_urls );
		$url[] = array( 'text' => wfMessage( 'myfavoritelist' )->text(),
				'href' => SpecialPage::getTitleFor( 'Favoritelist' )->getLocalURL() );
		$personal_urls = $url + $personal_urls;
	}
	return true;
}
to
public static function onPersonalUrls( &$personal_urls, &$title ) {
	global $wgFavoritesPersonalURL, $wgUser;
	if ( $wgFavoritesPersonalURL && $wgUser->isLoggedIn() ) {
		$url[] = array( 'text' => wfMessage( 'myfavoritelist' )->text(),
				'href' => SpecialPage::getTitleFor( 'Favoritelist' )->getLocalURL() );
		$personal_urls = wfArrayInsertAfter( $personal_urls, $url, 'watchlist' );
	}
	return true;
}
James Martindale (talk) 03:10, 18 October 2016 (UTC)

Favorite Counter

Would it be possible to show the number of times that a page has been made favorite in the page? 91.117.213.127 (talk) 12:39, 9 November 2015 (UTC)

I hacked that into action=info :) Subfader (talk) 11:46, 18 November 2015 (UTC)
Could you please provide more details on how did you achieve this?
Thanks in advance. Jupajups (talk) 23:30, 24 April 2016 (UTC)
I hard coded that into /includes/actions/InfoAction.php. Not recommended. The extension should do it. That was my intention with the post. Subfader (talk) 10:51, 8 May 2016 (UTC)

i18n - German Translation available

With this post I provide a german translation of the en.json file provided within the favorites project. Perhaps it can be part of the project source.

Please feel free to add this as "de.json" in the folder Favorites/i18n/:

{

   "@metadata": {
       "authors": ["Tim Koester"]
   },
   "favorites-desc": "Erstelle Favoriten-Liste",
   "favoritethis"                       : "Zu Favoriten hinzufügen",
   "prefs-favoritelist"              : "Favoriten",
   "prefs-favoritelist-token"        : "Favoriten token:",
   "prefs-advancedfavoritelist"      : "Erweiterte Optionen",
   "favoritelist"           : "Favoriten",
   "myfavoritelist"         : "Favoriten",
   "favoritelistfor"        : "(for $1)",
   "nofavoritelist"         : "You have no items in your favorites.",
   "favoritelistanontext"   : "Bitte $1 um Favoriten anzuzeigen oder zu bearbeiten.",
   "favoritenologin"        : "Anmeldung erforderlich",
   "favoritenologintext"    : "Sie müssen angemeldet sein, um mit Favoriten zu arbeiten.",
   "addedfavorite"          : "Zu Favoriten hinzugefügt",
   "addedfavoritetext"      : "Die Seite $1 wurde zu ihren Favoriten hinzugefügt.",
   "removedfavorite"        : "Aus Favoriten entfernt",
   "removedfavoritetext"    : "Die Seite $1 wurde aus ihren Favoriten entfernt.",
   "favorite"               : "+Favorit",
   "favoritethispage"       : "Zu Favoriten hinzufügen.",
   "unfavorite"             : "-Favorit",
   "unfavoritethispage"     : "Aus Favoriten entfernen.",
   "favoritelist-options"   : "Favoriten Optionen",
   "favoriteerrortext"         : "Ein Fehler trat auf beim Ändern der Favoriten Einstellungen für $1.",
   "unfavoriteing"             : "Entfernen ...",
   "favoriteing"             : "Hinzufügen ...",
   "tooltip-pt-favoritelist": "Liste der Seite, deren Änderungen sie überwachen.",
   "tooltip-ca-favorite"      : "Fügt diese Seite zu ihren Favoriten hinzu.",
   "tooltip-ca-unfavorite"  : "Entfernt diese Seite aus ihren Favoriten.",
   "tooltip-favorite"          : "Fügt diese Seite zu ihren Favoriten hinzu.",
   "favoritelistedit-numitems"    : "Ihre Favoritenliste enthält $1 Titel.",
   "favoritelistedit-noitems" : "Your favorites contain no titles.",
   "favoritelistedit-normal-title" : "Favoriten bearbeiten",
   "favoritelistedit-normal-legend" : "Titel aus den Favoriten entfernen",
   "favoritelistedit-normal-explain" : "Titel in den Favoriten werden unten angezeigt. 
Zu entfernende Titel mittels Checkbox markieren und mit Button '⧼Favoritelistedit-normal-submit⧽' entfernen.
Alternativ können Sie den Quelltext editieren.
", "favoritelistedit-normal-submit" : "Titel entfernen", "favoritelistedit-normal-done" : "$1 titles were removed from your favorites:", "favoritelistedit-raw-title" : "Quelltext der Favoritenliste bearbeiten", "favoritelistedit-raw-legend" : "Quelltext bearbeiten", "favoritelistedit-raw-explain" : "Dit Titel ihrer Favoritenliste werden unten angezeigt. Sie können Titel aus der Liste löschen oder auch weitere Titel hinzufügen. Jeder Titel steht dabei einzeln in einer Zeile.
Nach Abschluss der Bearbeitung auf Button '⧼Favoritelistedit-raw-submit⧽' klicken.

Sie können auch die normale Bearbeitungsseite wählen.
", "favoritelistedit-raw-titles" : "Titel:", "favoritelistedit-raw-submit" : "Favoriten aktualisieren", "favoritelistedit-raw-done" : "Ihre Favoriten wurden aktualisiert.", "favoritelistedit-raw-added" : "$1 Titel wurde hinzugefügt:", "favoritelistedit-raw-removed" : "$1 Titel wurde entfernt:", "favoritelisttools-view" : "Favoriten anzeigen", "favoritelisttools-edit" : "Favoriten anzeigen und bearbeiten", "favoritelisttools-raw" : "Favoriten Quelltext bearbeiten"

} 195.182.60.200 (talk) 10:11, 17 February 2016 (UTC)

Request it on Phabricator. See How to report a bug. Shirayuki (talk) 22:18, 17 February 2016 (UTC)
I just sent a commit to Gerrit. Now we just gotta wait for it to be merged. Thanks for your work! James Martindale (talk) 15:27, 18 October 2016 (UTC)

How to remove star icon?

$wgVectorUseIconWatch = false; It does not seem to work (in localsettings.php) MW1.25.1. Any suggestions? Abhidevananda (talk) 02:41, 20 May 2016 (UTC)

Bugged display in Installation section

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Is it just me or is the Installation section bugged? I see things like

1>download-link</> and place the file(s) in a directory called <tvar|name>Favorites</> in your <tvar|ext>extensions/</> folder.</translate>

Can someone fix this? Also the download link is not given! 134.106.87.67 (talk) 13:25, 4 July 2016 (UTC)

Fixed - thank you! Jlemley (talk) 18:45, 4 August 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

MW 1.27 errors

undefined method User::getSkin()

https://www.mediawiki.org/wiki/Release_notes/1.27 > User::getSkin() was removed (deprecated since 1.18)

In SpecialFavoritelist.php just change $this->user-getSkin() to $this->user

undefined method User::editToken()

InFavoritelistEditor.php just change $user->editToken() to $user->getEditToken() Subfader (talk) 10:29, 8 September 2016 (UTC)

Call to undefined function wfMsg()

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


Mediawiki 1.27

PHP Fatal error:  Call to undefined function wfMsg() in /path/to/wiki/extensions/Favorites/FavParser.php on line 32 Mkepler (talk) 06:26, 27 September 2016 (UTC)

Cause: edit page, and submit. Mkepler (talk) 14:03, 27 September 2016 (UTC)
Solution: replace wfMsg wfMessage Mkepler (talk) 14:08, 27 September 2016 (UTC)
Manual:Messages API#Help with replacing deprecated wfMsg.2A functions Mkepler (talk) 14:08, 27 September 2016 (UTC)
The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

Hook TitleMoveComplete broken in MW 1.27.1

FavoritesHooks.php >

public static function onTitleMoveComplete( &$title, &$nt, &$user, $pageid, $redirid ) {...}

>

public static function onTitleMoveComplete( &$title, &$nt, $user, $pageid, $redirid ) {...} Subfader (talk) 15:58, 2 October 2016 (UTC)

Error on Empty Favorites List [MW1.27.1]

I created an empty page with <favorites editlink=true /> when I had an empty favorites list, and it resulted in Error from line 145 of extensions/Favorites/FavParser.php: Call to undefined method FavParser::msg(). James Martindale (talk) 00:44, 17 October 2016 (UTC)

===== Solution =====
Edit line 145 of FavParser.php:
private function showNormalForm( $output, $user ) {
	if ( $this->countFavoritelist($user ) > 0 ) {
		$form = $this->buildRemoveList( $user );
		$output .=  $form ;
		return $output;
	} else {
		$output = $this->msg('nofavoritelist')->text();
		return $output;
	}
}
to
		$output = wfMessage('nofavoritelist')->text();
James Martindale (talk) 18:25, 17 October 2016 (UTC)

Undefined method User::getSkin() in MW 1.28

We recently upgraded to MW 1.28.0 from 1.25.0, and we're getting this error when trying to access the "My favorites" page:

PHP Fatal error:  Call to undefined method User::getSkin() in /srv/www/devwiki/extensions/Favorites/SpecialFavoritelist.php on line 94

This results in a 500 Internal Server Error and all users cannot access their favorites.

The method User::getSkin has been deprecated since 1.18. The code comment says to "use ->getSkin() in the most relevant outputting context you have."

I changed all instances of $this->user->getSkin() to $this->context->getSkin() on my copy of the extension, and now it seems to work fine. TyrelHa (talk) 18:31, 13 February 2017 (UTC)

Thank you for the breadcrumb! I'm upgrading 1.17.0 to 1.29.3 in a time when 1.33.0 is king. Some additional help for the next person:
Outside of a class context, you can replace with:
$sk = RequestContext::getMain()->getSkin();
And a useful manual page: https://www.mediawiki.org/wiki/Manual:RequestContext.php Julie C. (talk) 19:13, 17 October 2019 (UTC)

No such action in MW 1.32

Product Version
MediaWiki 1.32.0
PHP 7.2.17-0ubuntu0.18.04.1 (apache2handler)
MariaDB 10.1.38-MariaDB-0ubuntu0.18.04.1

Installed the last version of Favourites and run the maintenance/update.php, I get this error using the extension (i.e. clicking on the star icon):

No such action

The action specified by the URL is invalid. You might have mistyped the URL, or followed an incorrect link. This might also indicate a bug in the software used by ....

and the "mistyped" url is:

https://tunearch.org/w/index.php?title=Harlequin_Tune_(3)&action=favorite&token=8506e116643ceea83a82e35f8987a3ee5ce2b492%2B%5C



Silkwood (talk) 14:14, 20 May 2019 (UTC)

I get the same, did you ever find a fix? Brickscrap (talk) 08:51, 25 July 2019 (UTC)
Someone is taking care of it.
See: https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Favorites/+/549679/7..7/includes/FavoriteAction.php Silkwood (talk) 09:01, 30 November 2019 (UTC)
Unfortunately, not. Silkwood (talk) 08:27, 19 August 2019 (UTC)
Did someone find a solution to this problem?
I tried the 1.1.3 version (cloning gerrit repo) but I got the same error: "No such action".
Please help! Silkwood (talk) 17:09, 7 November 2019 (UTC)

Javascript error: Exception in module-execute in module ext.favorites

When any Wiki page is called (MW 1.31, Favorites 1.1.2) Chrome reports the following console error:


JQMIGRATE: Migrate is installed with logging active, version 3.0.1

Exception in module-execute in module ext.favorites:

TypeError: Cannot set property 'favorite' of undefined

   at load.php?debug=false&lang=de&modules=ext.favorites|skins.pivot.js&skin=pivot&version=1h4he9h:2

   at mw.loader.implement.addedfavoritetext (load.php?debug=false&lang=de&modules=ext.favorites|skins.pivot.js&skin=pivot&version=1h4he9h:3)

   at runScript (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:162)

   at checkCssHandles (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:162)

   at execute (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:163)

   at handlePending (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:159)

   at markModuleReady (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:161)

   at runScript (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:162)

   at checkCssHandles (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:162)

   at execute (load.php?debug=false&lang=de&modules=jquery%2Cmediawiki&only=scripts&skin=pivot&version=0hrympo:163)

JQMIGRATE: jQuery(window).on('load'...) called after load event occurred S0ring (talk) 12:04, 18 November 2019 (UTC)

File "extension.json" doesn't exist in 1.34

The error begins: "Fatal error: Uncaught Exception: Unable to open file /var/www/mediawiki-1.34.0/extensions/Favorites/extension.json ... and indeed the only .json files in the Favorites folder (from the current tar download) are composer.json, gitinfo.json, package-lock.json and package.json. Should one of those be symlinked as "extension.json"?


Note that was with the new way. The old spec of 'require_once "$IP/extensions/Favorites/Favorites.php";' doesn't error out on that nonexistent file, but instead, "

No such action


The action specified by the URL is invalid. You might have mistyped the URL, or followed an incorrect link. This might also indicate a bug in the software used by eiswiki. WhitWye (talk) 20:39, 18 February 2020 (UTC)

I am now trying to install the Favorites extension. When I run the "php update.php" in the maintenance folder I get the same error:
PHP Fatal error: Uncaught Exception: Unable to open file /var/www/vhosts/.../extensions/Favorites/extension.json: filemtime(): stat failed for /var/www/vhosts/.../extensions/Favorites/extension.json in /var/www/vhosts/.../includes/registration/ExtensionRegistry.php:136
Stack trace:
  1. 0 /var/www/vhosts/.../includes/GlobalFunctions.php(52): ExtensionRegistry->queue()
  2. 1 /var/www/vhosts/.../LocalSettings.php(177): wfLoadExtension()
  3. 2 /var/www/vhosts/.../includes/Setup.php(124): require_once('/var/www/vhosts...')
  4. 3 /var/www/vhosts/.../maintenance/doMaintenance.php(83): require_once('/var/www/vhosts...')
  5. 4 /var/www/vhosts/.../maintenance/update.php(277): require_once('/var/www/vhosts...')
  6. 5 {main}
thrown in /var/www/vhosts/.../includes/registration/ExtensionRegistry.php on line 136
Anyone have a fix? Lwangaman (talk) 23:40, 11 April 2020 (UTC)
请问你解决了吗? 2403:AC00:0:1001:0:0:2:5C9E (talk) 09:52, 15 May 2023 (UTC)
To fix the issue, you'll need to comment the following line, inside the LocalSettings.php file.
require_once( "$IP/includes/DefaultSettings.php" ); 188.27.50.189 (talk) 13:17, 14 August 2024 (UTC)

JS TypeError: Cannot set property 'favorite' of undefined

In MW 1.31.10 LTS I get this console error

 Exception in module-execute in module ext.favorites:
 load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:177 TypeError: Cannot set property 'favorite' of undefined
   at load.php?debug=false&lang=en&modules=ext.favorites|site&skin=monobook&version=1f4gm5l:2
   at mw.loader.implement.addedfavoritetext (load.php?debug=false&lang=en&modules=ext.favorites|site&skin=monobook&version=1f4gm5l:3)
   at runScript (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:162)
   at checkCssHandles (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:162)
   at execute (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:163)
   at handlePending (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:159)
   at markModuleReady (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:161)
   at runScript (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:162)
   at checkCssHandles (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:162)
   at execute (load.php?debug=false&lang=en&modules=jquery%2Cmediawiki&only=scripts&skin=monobook&version=1e4vcjv:163) Subfader (talk) 19:41, 17 November 2020 (UTC)

Empty Favorit icon

Extension is work, button is work too. But no show "yellow star" icon. Mkepler (talk) 06:21, 9 April 2021 (UTC)

Call to a member function getFormattedNsText() on null

The following discussion is closed. Please do not modify it. Subsequent comments should be made on the appropriate discussion page. No further edits should be made to this discussion.


[e4c2c43c004f9a9a2587068b] /wiki/index.php/Especial:Favoritelist Error: Call to a member function getFormattedNsText() on null

Backtrace:

from /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/extensions/Favorites/specials/SpecialFavoritelist.php(362)

#0 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/extensions/Favorites/specials/SpecialFavoritelist.php(334): ViewFavorites->getNamespaceHeading(integer)

#1 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/extensions/Favorites/specials/SpecialFavoritelist.php(314): ViewFavorites->buildRemoveList(User)

#2 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/extensions/Favorites/specials/SpecialFavoritelist.php(119): ViewFavorites->showNormalForm(OutputPage, User)

#3 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/extensions/Favorites/specials/SpecialFavoritelist.php(105): ViewFavorites->viewFavList(User, OutputPage, WebRequest, boolean)

#4 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/extensions/Favorites/specials/SpecialFavoritelist.php(27): ViewFavorites->wfSpecialFavoritelist(NULL)

#5 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/includes/specialpage/SpecialPage.php(646): SpecialFavoritelist->execute(NULL)

#6 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/includes/specialpage/SpecialPageFactory.php(1386): SpecialPage->run(NULL)

#7 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/includes/MediaWiki.php(309): MediaWiki\SpecialPage\SpecialPageFactory->executePath(Title, RequestContext)

#8 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/includes/MediaWiki.php(913): MediaWiki->performRequest()

#9 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/includes/MediaWiki.php(546): MediaWiki->main()

#10 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/index.php(53): MediaWiki->run()

#11 /data/web/a1/eb/4e/laplumaazul.tk/htdocs/wiki/index.php(46): wfIndexMain()

#12 {main}


what should i do? Uvas magicas (talk) 17:38, 10 September 2021 (UTC)

The discussion above is closed. Please do not modify it. No further edits should be made to this discussion.

missing checkbox for "Add this page to your Favorites" after upgrade

Hello All

We just upgraded Mediawiki from version 1.28.0 to 1.36.2

We also updated Favorites extension from version 1.1.2 (7c891a7) to 1.1.3 (b874145)

Before the upgrade / update, there use to be a checkbox that would show up right beside the star on the top of the page.

After the upgrade, we can't see the checkbox to "Add this page to your Favorites.

Can someone help? do we need to configure something. Did we forget to do something in the upgrade.

How can we enable the checkbox to "Add this page to your Favorites" show up again?

Thanks Abid.Jaffery (talk) 15:32, 28 October 2021 (UTC)

Edit raw favorites

There seems to be a bug in the 1.1.3 favorites extension.

-- If I add a favorite to my favorites list and then view my favorites, I can successfully see my favorite I just added.

-- If I then select Edit raw favorites, I can see the raw text of my favorite I just added. Copy that text, then delete it and select Update favorites button, then view your favorites from my favorites link. You should now have no favorites (if this was initially your only one you added like I did in my case).

-- From there, select Edit raw favorites, past in the raw text of your favorite and then select Update favorites button.

-- Select view and edit favorites to see your favorites and you end up with an error (Internal error) something like this:

[2302d489c484acd6ac97a5f7] 2021-11-01 17:46:08: Fatal exception of type "Error"

-- Go back to Edit raw favorites list and remove this raw text you just pasted and select Update favorites button and view favorites. Things now work again with no error.


This seems like a weird case to try, but this issue is because of Favorites upgrade from 1.1.2 to 1.1.3. Once I upgrade, I can't see any of my favorites because I get an error like the above. If I go into Edit raw favorites list, I can see my favorites, but I can't view outside of raw mode. If I delete all the raw text and Update my favorites, I don't get any error anymore when looking at my favorites, but of course, now all my favorites are gone. It seems the upgrade and\or the copy and pasting of raw favorites text causes issues and throws this Internal Error.


Any help would be appreciated!!! Kodaren (talk) 17:50, 1 November 2021 (UTC)

Ok, seems that the patch work to the .php files are required even though the documentation said 1.36 mediawiki. We are using a newer version, but the updated to FavoritelistEditor.php and SpecialFavoritelist.php are still required and sort of fixes our favorites issue. There is still issues with edit raw and add/removing. Kodaren (talk) 18:52, 1 November 2021 (UTC)
@Kodaren, the extension have problems with add / remove favorites because the hook TitleMoveComplete was removed in the version stable of mediawiki (1.37) the extension need migrate of the new hook PageMoveComplete Uvas magicas (talk) 15:43, 24 November 2021 (UTC)

hook removed

this extension use the hook TitleMoveComplete that removed in the version 1.37 of mediawiki, how could it be replaced by the new hook PageMoveComplete? Gota de agua (talk) 03:05, 20 November 2021 (UTC)

"an error occurred ..." MW 1.35.4, 1.35.5

MW 1.35.4, PHP 7.4.24


Howdy,

when clicking "+Favorite", a small message box appears "An error occurred when changing the favorites setting for ..."

By activating the debug options in LocalSettings, I find the following log entry in the Apache error log:

AH01071: Got error 'PHP message: PHP Deprecated:  Use of InternalParseBeforeSanitize hook (used in VariablesHooks::onInternalParseBeforeSanitize) was deprecated in MediaWiki 1.35. [Called from MediaWiki\\HookContainer\\HookContainer::run in [........]/mediawiki/includes/HookContainer/HookContainer.php at line 132] in [........]/mediawiki/includes/debug/MWDebug.php on line 430', referer: [...page name.....]


Anyone else having the same problem? What can I do to find out more ? 2003:C2:3F1C:100:A11D:7FB3:D263:8A51 (talk) 13:16, 31 January 2022 (UTC)

Disable Deprecated errors in production:
https://serverfault.com/questions/263167/disabling-php-deprecation-warnings-and-notices
This doesn't seem to be the error you're getting, however. If that doesn't fix it, hit F12 to open your browser's console and check the network tab, and try again. You may see a more meaningful error message inspecting the response from the server on the network tab Ciencia Al Poder (talk) 14:50, 31 January 2022 (UTC)
... not really. The network tab shows an answer of "200" on a post request, and the detailed view tells me:
{"error":{"code":"internal_api_error_Error","info":"[ad70de264e45ab8a9f92a964] Caught exception of type Error","errorclass":"Error"}}
so it seems the extension itself handles an exception. All well-known debug options in LocalSettings are set, the Mediawiki log file is empty. 2003:C2:3F1C:100:A11D:7FB3:D263:8A51 (talk) 15:10, 31 January 2022 (UTC)
In PHP, deprecation warnings are off:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
but this seemingly does not work as Apache reports the warnings as "AH01071 Got error". 2003:C2:3F1C:100:A11D:7FB3:D263:8A51 (talk) 15:15, 31 January 2022 (UTC)
Set $wgShowExceptionDetails to true in LocalSettings.php to get a more descriptive error message. Ciencia Al Poder (talk) 19:38, 31 January 2022 (UTC)
$wgShowExceptionDetails = true and I thought it had been so before ... after some try&error, I still can't find no stacktrace nowhere, neither in the Mediawiki log nor in the Apache logfile. But eventually the browser network viewer tab tells me a little bit more:
"internal_api_error_Error"
"[792bf7348e100b98b656ca9a] Exception caught: Call to undefined method ApiFavorite::dieUsageMsg()"
"Error at [.......]/extensions/Favorites/api/ApiFavorite.php(41)\n
#0 [.......]/includes/api/ApiMain.php(1593): ApiFavorite->execute()\n
#1 [.......]/includes/api/ApiMain.php(529): ApiMain->executeAction()\n
#2 [.......]/api/ApiMain.php(500): ApiMain->executeActionWithErrorHandling()\n
#3 [.......]/api.php(90): ApiMain->execute()\n
#4 [.......]/api.php(45): wfApiMain()\n
#5 {main}"
Obviously part of our installation is outdated, the extension or some of the core functions. Mediawiki = 1.35.4, PHP = 7.4.3, Favorites = 1.1.3 (downloaded few days ago via ExtensionDistributor). Do I have the wrong extension version? 2003:C2:3F1C:100:3946:3285:873C:3F66 (talk) 10:20, 1 February 2022 (UTC)
ApiFavorites line 29-42:
               if ( $params['unfavorite'] ) {
                       $res['unfavorited'] = '';
                       $res['message'] = $this->msg( 'removedfavoritetext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
                       $success = false;
                       //$success = UnfavoriteAction::doUnfavorite( $title, $user );
               } else {
                       $res['favorited'] = '';
                       $res['message'] = $this->msg( 'addedfavoritetext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
                       $success = false;
                       //$success = FavAction::doFavorite( $title, $user );
               }
               if ( !$success ) {
                       $this->dieUsageMsg( 'hookaborted' );
               }
$success is always st to false!? 2003:C2:3F1C:100:3946:3285:873C:3F66 (talk) 10:24, 1 February 2022 (UTC)
APIBase::dieUsageMsg was removed in MediaWiki 1.32:
Release_notes/1.32#Action_API_internal_changes_in_1.32
Looks like this extension is not compatible with MediaWiki 1.36 despite what the extension infobox says... Ciencia Al Poder (talk) 11:03, 1 February 2022 (UTC)
Sadly I see. Repairing the code is far beyond my skill. I hope someone someday will take the necessary steps.
Many thanks for your support. 2003:C2:3F1C:100:9464:F8C6:FD5E:F88F (talk) 15:17, 1 February 2022 (UTC)
i test the extension and i thought it was the problem due to the use of the Titlemovecomplete hook that was removed in mediawiki 1.37, so I left a warning on the extension page but I see that it is something else, if someone could make a patch in gerrit I would be grateful because the extension is still interesting Gota de agua (talk) 00:57, 1 April 2022 (UTC)
I'm having the same issue using Mediawiki 1.38.4-1, mariadb 10.9.3-3, PHP 8.1.12-2. Rdrg109 (talk) 21:29, 5 November 2022 (UTC)
The extension now have a patch for fix that problems Gota de agua (talk) 18:32, 28 October 2023 (UTC)
@Rdrg109
@2003:C2:3F1C:100:A11D:7FB3:D263:8A51
you must fix the extension with the next patch: https://gerrit.wikimedia.org/r/969298 Gota de agua (talk) 05:08, 31 October 2023 (UTC)
Patch is your answer? Really? What a joke.
The documentation page states the extension is stable. I can either download via Extension Distributor or I can use the git repository download. In either case I get an extension that does not work, problems are the same as described above. We have a test installation of 1.39 now, nothing has changed, problems are the same. as with 1.35.
I don't have the knowledge to apply a patch nor am I willing to learn that. You are distributing an extension that crashes, you are able to patch, so why won't you just correct that piece of software so that the extension distributor and the git repository are up do date.
No words could express what I'm feeling. Ground control to spaceship Mediawiki, please do your job then I'll do mine. 2003:C2:3F21:FD00:134:BD68:4409:6542 (talk) 07:23, 23 April 2024 (UTC)
Jobs are normally paid. However, in the Open Source ecosystem, most work is unpaid and volunteer, so this is not anyone's job to do. You got what you paid for. Ciencia Al Poder (talk) 07:28, 23 April 2024 (UTC)
You're right. Everyone get what they paid for. Nothing is for free. 2003:C2:3F21:FD00:134:BD68:4409:6542 (talk) 10:11, 23 April 2024 (UTC)
Can someone please explain how to apply the patch? I'm not a git expert, but due to the patch not being merged, I couldn't find out how to check it out.
I ended up checking out the parent commit of this patch and copied/overwrote the content of all files that were modified in the patch with those.
But it still gave an error (under PHP 8.3.6): "Exception caught: Non-static method FavoriteAction::doAction() cannot be called statically".
To make it run under PHP 8.0+ (I think), I had to change the following:
if ( $params['unfavorite'] ) {
$res['unfavorited'] = ;
$res['message'] = $this->msg( 'removedfavoritetext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
$success = UnfavoriteAction::doAction( $dbw, $title->getNamespace(), $user, $title );
} else {
$res['favorited'] = ;
$res['message'] = $this->msg( 'addedfavoritetext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
- $success = FavoriteAction::doAction( $dbw, $title->getNamespace(), $user, $title );
+ $makePage = new WikiPage( $title );
+ $fix_static= new FavoriteAction( $makePage );
+ $success = $fix_static->doAction( $dbw, $title->getNamespace(), $user, $title );
Sadly, the analogous changes don't work on the UnfavoriteAction part, so I can put pages on the Favorite list, but only remove them on Special:FavoriteList. WhichBrain (talk) 19:00, 8 February 2025 (UTC)

addGoodLinkObj() Error, unable to load Special:FavoriteList

Hello, I am getting this error when trying to access Special:FavoriteList. Thank you for any assistance.

/Special:Favoritelist Error: Call to undefined method MediaWiki\Cache\LinkCache::addGoodLinkObj()

Backtrace:

from [filepath]/extensions/Favorites/includes/specials/SpecialFavoritelist.php(278)
#0 [filepath]/extensions/Favorites/includes/specials/SpecialFavoritelist.php(359): ViewFavorites->getFavoritelistInfo(MediaWiki\User\User)
#1 [filepath]/extensions/Favorites/includes/specials/SpecialFavoritelist.php(340): ViewFavorites->buildRemoveList(MediaWiki\User\User)
#2 [filepath]/extensions/Favorites/includes/specials/SpecialFavoritelist.php(147): ViewFavorites->showNormalForm(MediaWiki\Output\OutputPage, MediaWiki\User\User)
#3 [filepath]/extensions/Favorites/includes/specials/SpecialFavoritelist.php(127): ViewFavorites->viewFavList(MediaWiki\User\User, MediaWiki\Output\OutputPage, MediaWiki\Request\WebRequest, boolean)
#4 [filepath]/extensions/Favorites/includes/specials/SpecialFavoritelist.php(30): ViewFavorites->wfSpecialFavoritelist(NULL)
#5 [filepath]/includes/specialpage/SpecialPage.php(719): SpecialFavoritelist->execute(NULL)
#6 [filepath]/includes/specialpage/SpecialPageFactory.php(1669): MediaWiki\SpecialPage\SpecialPage->run(NULL)
#7 [filepath]/includes/actions/ActionEntryPoint.php(504): MediaWiki\SpecialPage\SpecialPageFactory->executePath(string, MediaWiki\Context\RequestContext)
#8 [filepath]/includes/actions/ActionEntryPoint.php(145): MediaWiki\Actions\ActionEntryPoint->performRequest()
#9 [filepath]/includes/MediaWikiEntryPoint.php(199): MediaWiki\Actions\ActionEntryPoint->execute()
#10 [filepath]/index.php(58): MediaWiki\MediaWikiEntryPoint->run()
#11 {main} SylvanianClub (talk) 04:47, 19 August 2024 (UTC)

Category:Talk pages using deprecated source tags Category:Talk pages with syntax highlighting errors