Extension talk:EditNotify

From mediawiki.org
Latest comment: 10 months ago by JeremiPlazas in topic Can't get this to work on MW 1.35.10

Related documentation[edit]

Thanks for the documentation! When you consider the extension ready to be used by others, please add links from related documentation, like the MediaWiki core feature Manual:$wgUsersNotifiedOnAllChanges. Nemo 08:39, 1 September 2016 (UTC)Reply

Exclude some namespaces[edit]

This extension could be very useful if one can exclude notifications from some namespaces (action => create), i.e. "File" namespace, because it produces enormous amount of notifications. 217.108.170.8 15:04, 20 December 2016 (UTC)Reply

filed as bug https://phabricator.wikimedia.org/T240656 --Wikinaut (talk) 08:09, 13 December 2019 (UTC)Reply
and another one, allow only one unread notification for one page, i.e. if some one made multiple edits of one page in an hour 217.108.170.8 10:50, 21 December 2016 (UTC)Reply

Warnings and notices[edit]

Setup

  • MediaWiki 1.27.1 (36b636d) 20:26, 11. Jan. 2017
  • PHP 5.6.29-0+deb8u1 (apache2handler)
  • MariaDB 10.0.29-MariaDB-0+deb8u1
  • Page Forms 4.1 (f97847f) 18:30, 15. Nov. 2016
  • Edit Notify 1.0.0
  • Edit Notify Connector 0.1.0

Issue

Warning: Invalid argument supplied for foreach() in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 807
Warning: Invalid argument supplied for foreach() in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 807
Notice: Undefined variable: categoryUserArray in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 850
Warning: array_diff(): Argument #1 is not an array in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 850
Warning: array_unique() expects parameter 1 to be array, null given in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 850
Warning: array_merge(): Argument #2 is not an array in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 853
Warning: Invalid argument supplied for foreach() in /.../w/extensions/EditNotify/EditNotify.hooks.php on line 855

This armada of notices and warnings is emitted multiple times when editing a page using the Page Forms extension.

Cheers --[[kgh]] (talk) 23:12, 14 February 2017 (UTC)Reply

@Yaron Koren: FYI.

It sounds like the problem might be just that you haven't set $wgEditNotifyAlerts. (Although the code should itself set a default value of a blank array for that variable, to prevent these error messages - that's a bug.) What's "Edit Notify Connector", by the way - an extension of yours? Yaron Koren (talk) 15:19, 15 February 2017 (UTC)Reply
Oops, I indeed set nothing to $wgEditNotifyAlerts. EditNotify was added to the BlueSpice software bundle which also includes the Edit Notify Connector extension integrating this extension into the bundle. I just deployed Edit Notify without further thought. It is automatically invoked via one of the config files they provide so I relied on this. Having a default value preventing the error messages from happening will indeed be cool. Cheers --[[kgh]] (talk) 21:03, 15 February 2017 (UTC)Reply
Oh, good to know. Yaron Koren (talk) 01:12, 16 February 2017 (UTC)Reply

Track certain namespaces pages creation[edit]

filed as bug https://phabricator.wikimedia.org/T240656 --Wikinaut (talk) 08:09, 13 December 2019 (UTC)Reply
EditNotify.hooks.php: ↓
	public static function onPageContentInsertComplete( WikiPage $wikiPage, User $user, $content, $summary,
		$isMinor,$isWatch, $section, $flags, Revision $revision ) {

		//notify locally by echo event
		$title = $wikiPage->getTitle();
		$NSnum = $title->getNamespace();

		$condstr = 'up_property = "editnotify-prefs-local-create-ns' . $NSnum . '"';

		$dbr = wfGetDB( DB_SLAVE );
		$rows = $dbr->select(
			'user_properties',
			array( 'up_user' ),
			$condstr,
			__METHOD__,
			array()
		);

		foreach( $rows as $row) {
			self::pageCreateNotify( $title, 'edit-notify-page-create', $row->up_user );
		}

		//notify by email

		global $wgSitename, $wgPasswordSender;
		$username = $user->getName();
		$from = new MailAddress( $wgPasswordSender,
			wfMessage( 'emailsender' )->inContentLanguage()->text() );
		$prefixText = $title->getPrefixedText();
		$subject = wfMessage( 'emailallchanges-subject' )->params( $wgSitename, $prefixText )->plain();

		$body = wfMessage( 'emailallchanges-body1' )->params(
			$wgSitename,
			$user->getRealName(),
			$prefixText
		)->plain();
		$body .=" \n" . $title->getFullURL() . "\n\n";
		$body .= wfMessage( 'emailallchanges-body2' )->params(
			ContentHandler::getContentText( $content )
		)->plain();

		$replyto = null;

		$condstr = 'up_property = "editnotify-prefs-email-create-ns' . $NSnum . '"';

		$rows = $dbr->select(
			'user_properties',
			array( 'up_user' ),
			$condstr,
			__METHOD__,
			array()
		);

		foreach( $rows as $row) {
			$OUser = User::newFromId( $row->up_user );
			$to = MailAddress::newFromUser( $OUser );

			UserMailer::send( $to, $from, $subject, $body, $replyto );
		}
	}

	/**
	 * @param $pageTitle
	 * @param $pageType
	 * @param $user
	 * @return bool
	 */
	public static function pageCreateNotify( $pageTitle, $pageType, $user ) {
		EchoEvent::create( array(
			'type' => $pageType,
			'extra' => array(
				'title' => $pageTitle,
				'user-id' => $user,
			),
			'title' => $pageTitle
		) );
		return true;
	}

	/**
	 * @param $user
	 * @param $preferences
	 * @return bool
	 */
	public static function onGetPreferences( $user, &$preferences ) {

		global $wgExtraNamespaces;

		$NSList = $wgExtraNamespaces;
		$NSList[0] = '(main)';
		$NSList[10] = 'Template';
		$NSList[12] = 'Help';
		asort($NSList);

		foreach( array_keys($NSList) as $currNS) {
			if (($currNS % 2) == 0) {
				$currNSName = $NSList[$currNS];
				$rows[$currNSName] = 'ns' . $currNS;
			}
		}

		$columns = array(
			'Email' => 'email-create',
			'Local' => 'local-create',
		);

		$preferences['editnotify-prefs'] = array(
			'class' => 'HTMLCheckMatrix',
			'section' => 'newnotifications/page-create-notifs',
			'rows' => $rows,
			'columns' => $columns,
			'prefix' => 'editnotify-prefs-',
		);

		return true;
	}

you will get ability to track certain namespaces pages creation and every user can toggle this in settings manually. But you need to add hook and some strings to language files

	"Hooks": {
		"BeforeCreateEchoEvent": [
			"EditNotifyHooks::onBeforeCreateEchoEvent"
		],
		"EchoGetDefaultNotifiedUsers": [
			"EditNotifyHooks::onEchoGetDefaultNotifiedUsers"
		],
		"PageContentSave": [
			"EditNotifyHooks::onPageContentSave"
		],
		"PageContentInsertComplete": [
			"EditNotifyHooks::onPageContentInsertComplete"
		],
		"GetPreferences": [
			"EditNotifyHooks::onGetPreferences"
		]
	},
"prefs-newnotifications": "New Notifications",
  "prefs-page-create-notifs": "Page creation",
  "prefs-page-edit-notifs": "Page edit"

217.108.170.8 15:15, 10 April 2017 (UTC)Reply

Namespaces ang page creation notification[edit]

Hi and thank you for this very useful extension.

in 6 Issues of the extension you say that "when you are subscribing for create page notifications, don t include namespace"

but in 4 Usage you put an example with a namespace for page creation notification. :(

Can I remove the line 'namespace' => 'namespace name',

Thanks,

Nicolas NALLET Wiki-Valley.com, Semantiki.fr (talk) 09:41, 23 March 2017 (UTC)Reply

User-subscribed notifications[edit]

So this extension requires an admin with access to LocalSettings.php to manage the list of users to whom the notifications are sent both via web (Echo) and via email. How do I add the notification types enabled by this extension to User preferences for Notifications (Echo) so that they manage their own notifications?

Ultimately, I want to allow users to opt-in to notifications for changes to pages on their watchlist. MW already allows email notifications, but I like to provide an option to receive only Web notifications. I figured this extension is the closest thing I've found so far that might allow this.

--Tommy H (talk) 02:07, 29 June 2019 (UTC)Reply

@Tommy H, any plans on implementing this feature yourself soon? We also have a need for it on my wiki. If not, I might do it in the coming months. Tinss (talk) 22:20, 19 September 2019 (UTC)Reply
@Tinss, not really, my skillset in this area is very limited and haven't had the opportunity to get over the learning curve. Tommy H (talk) 00:18, 25 September 2019 (UTC)Reply
@Tommy H, no worries, I'll try to inform you if I ever get to making an extension for this. I might then need your help for some testing :) Tinss (talk) 22:32, 26 September 2019 (UTC)Reply

Support for group[edit]

Is it possible to set these settings for members of an entire group? Even if there were some other code we could use to yank all the members of a group into an array and then use that when calling the "users" argument. --Realsalt (talk) 17:56, 16 April 2021 (UTC)Reply

Extension notifies using the article title instead of the category[edit]

Even though I put the category filter on my code, the extension only notifies when a change is made on an article with the category title. Example: the following code notifies when a change is made in the article with the title 'Example' inside the Example category, but not on others articles on that same category.

$wgEditNotifyAlerts = array (

  array(
    'action' => 'edit',
    'category' => 'Example',
    'users' => array('Ghosth96')
      )

);

Wiki version: 1.36.1

  • Edit: it was corrected by changing a line on the *Notification for edit in non template pages* section, replacing this line inside the first if:

$categories[$row->cl_to] = $title->getFullText();

with this line:

$categories[$title->getFullText()]=$row->cl_to;

EditNotify - How to assign action to a user group rather than a user[edit]

I would like to assign EventNotify action to a user group rather than a user. Is this possible? Jamesyoungottawa (talk) 17:58, 3 November 2022 (UTC)Reply

PageContentSave Depricated in 1.35.0[edit]

Since PageContentSave was depricated in 1.35.0 could it cause EditNotify to have Internal Errors happen after editing and saving pages on a wiki?

I am currently using MediaWiki 1.35.6 on my Wiki.

Error Message I am getting at the very top of the page: "Warning: strcmp() expects two parameter 2 to be a string, array given C:\...\...\extensions\EditNotify\EditNotify.hooks.php on line 289."

Error Message I am getting on the page: "INTERNAL ERROR ... Object of class ENPageComponent could not be converted to string. Backtrace ..."

LINKS:

Manual:Hooks/PageContentSave - MediaWikihttps://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/EditNotify/+/refs/heads/REL1_35/EditNotify.hooks.php#:~:text=public%20static%20function-,onPageContentSave,-(%20WikiPage%20%26https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/EditNotify/+/refs/heads/REL1_35/EditNotify.hooks.php#:~:text=if%20(%20strcmp,%24name%5D%3B 216.123.208.21 14:08, 31 January 2023 (UTC)Reply

Can't get this to work on MW 1.35.10[edit]

Hi everyone,

I can't get this extension to work properly. Setting $wgEditNotifyAlerts either works for every single edits and creations for all users mentioned with action=create; or it doesn't work at all if i try action=edit. The category, namespace, template, and templateField parameters don't seem to make any difference either way. The only parameter that works properly is the "users" one.

Any clues anyone?

I have seen this Phabricator post, T240656, and have subscribed to it. I was just wondering if anyone else had a solution.

Cheers!

Jeremi Plazas (talk) 21:37, 21 June 2023 (UTC)Reply