Last modified: 2014-07-30 04:52:38 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T68233, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 66233 - Cite should warn/stop the user from saving if the page is invalid
Cite should warn/stop the user from saving if the page is invalid
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
Cite (Other open bugs)
master
All All
: High enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-06-06 01:18 UTC by James Forrester
Modified: 2014-07-30 04:52 UTC (History)
2 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description James Forrester 2014-06-06 01:18:16 UTC
Multiple easy mistakes cause horrible, ugly red text:

* <ref name="foo" /> but not <ref>
* <ref />, unnamed
* <ref> but no <references />
* <references /> but no <ref>

This is what PageContentSave exists for. Let's use it…
Comment 1 Deepak Sharma 2014-07-30 04:52:38 UTC
(In reply to James Forrester from comment #0)
> Multiple easy mistakes cause horrible, ugly red text:
> 
> * <ref name="foo" /> but not <ref>
> * <ref />, unnamed
> * <ref> but no <references />
> * <references /> but no <ref>
> 
> This is what PageContentSave exists for. Let's use it…

Hi James,

I would like to try and fix this bug if no one else is already working on it.

Since, I am just a beginner, so please correct me if I am wrong somewhere.
Instead of using PageSaveContent hook, I think it would be better off to use EditFilter Hook which we can use to halt editing and print out the error message on top of Edit Page (which I think is exactly that you want).

So, I gave it a quick try (just to find out if it'll work):

/***********/
// declared a flag variable to find if error has occurred
var $err=false;

// and put $this->err = true; whenever error occured
// and we can also make an errors array to store all the errors that are
// encountered on the way.
...

// declared callback for the EditFilter hook in setHooks function in
// Cite_body.php

...
if ( !Cite::$hooksInstalled ) {
...
$wgHooks['EditFilter'][] =  array( $parser->extCite, 'validate');
...

function validate($editPage, $text, $section, &$hookError, $summary ){
  if ( $this->err ) {
    $hookError = "There's some problem with your refs";
  }
  error_log('function validate called');
  return true;
}

/***********/


But, the problem I am encountering is that validate function is never being called, it is as if callback function for EditFilter hook was never set.

Can you please let me know, where am I going wrong?

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links